~sinzui/ubuntu/wily/juju-core/wily-1.24.7

« back to all changes in this revision

Viewing changes to src/gopkg.in/goose.v1/identity/userpass.go

  • Committer: Package Import Robot
  • Author(s): Curtis C. Hovey
  • Date: 2015-09-22 15:27:01 UTC
  • mfrom: (1.1.36)
  • Revision ID: package-import@ubuntu.com-20150922152701-lzq2yhn2uaahrdqu
Tags: 1.24.6-0ubuntu1
* New upstream release (LP: #1481556).
* d/copyright updated for Juju 1.24.6 (Last verified commit changes).
* d/tests/* Run tests with upstart when Juju version before 1.23.
* Prefer gccgo-5 for ppc64el and arm64 in build-deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package identity
 
2
 
 
3
import (
 
4
        goosehttp "gopkg.in/goose.v1/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
}