forked from go-goose/goose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
userpass.go
37 lines (30 loc) · 805 Bytes
/
userpass.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package identity
import (
goosehttp "gopkg.in/niedbalski/goose.v3/http"
)
type passwordCredentials struct {
Username string `json:"username"`
Password string `json:"password"`
}
type authRequest struct {
PasswordCredentials passwordCredentials `json:"passwordCredentials"`
TenantName string `json:"tenantName"`
}
type authWrapper struct {
Auth authRequest `json:"auth"`
}
type UserPass struct {
client *goosehttp.Client
}
func (u *UserPass) Auth(creds *Credentials) (*AuthDetails, error) {
if u.client == nil {
u.client = goosehttp.New()
}
auth := authWrapper{Auth: authRequest{
PasswordCredentials: passwordCredentials{
Username: creds.User,
Password: creds.Secrets,
},
TenantName: creds.TenantName}}
return keystoneAuth(u.client, auth, creds.URL)
}