~sinzui/ubuntu/vivid/juju-core/vivid-1.24.6

« back to all changes in this revision

Viewing changes to src/launchpad.net/goose/identity/userpass.go

  • Committer: Curtis Hovey
  • Date: 2015-09-30 14:14:54 UTC
  • mfrom: (1.1.34)
  • Revision ID: curtis@hovey.name-20150930141454-o3ldf23dzyjio6c0
Backport of 1.24.6 from wily. (LP: #1500916)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package identity
2
 
 
3
 
import (
4
 
        goosehttp "launchpad.net/goose/http"
5
 
)
6
 
 
7
 
type passwordCredentials struct {
8
 
        Username string `json:"username"`
9
 
        Password string `json:"password"`
10
 
}
11
 
 
12
 
type authRequest struct {
13
 
        PasswordCredentials passwordCredentials `json:"passwordCredentials"`
14
 
        TenantName          string              `json:"tenantName"`
15
 
}
16
 
 
17
 
type authWrapper struct {
18
 
        Auth authRequest `json:"auth"`
19
 
}
20
 
 
21
 
type UserPass struct {
22
 
        client *goosehttp.Client
23
 
}
24
 
 
25
 
func (u *UserPass) Auth(creds *Credentials) (*AuthDetails, error) {
26
 
        if u.client == nil {
27
 
                u.client = goosehttp.New()
28
 
        }
29
 
        auth := authWrapper{Auth: authRequest{
30
 
                PasswordCredentials: passwordCredentials{
31
 
                        Username: creds.User,
32
 
                        Password: creds.Secrets,
33
 
                },
34
 
                TenantName: creds.TenantName}}
35
 
 
36
 
        return keystoneAuth(u.client, auth, creds.URL)
37
 
}