Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(255)

Side by Side Diff: identity/identity.go

Issue 13360044: client/Client: Add API for non-validating SSL
Patch Set: Created 11 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/local_test.go ('k') | identity/identity_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // goose/identity - Go package to interact with OpenStack Identity (Keystone) AP I. 1 // goose/identity - Go package to interact with OpenStack Identity (Keystone) AP I.
2 2
3 package identity 3 package identity
4 4
5 import ( 5 import (
6 "fmt" 6 "fmt"
7 "os" 7 "os"
8 "reflect" 8 "reflect"
9
10 goosehttp "launchpad.net/goose/http"
9 ) 11 )
10 12
11 // AuthMode defines the authentication method to use (see Auth* 13 // AuthMode defines the authentication method to use (see Auth*
12 // constants below). 14 // constants below).
13 type AuthMode int 15 type AuthMode int
14 16
15 const ( 17 const (
16 AuthLegacy = AuthMode(iota) // Legacy authentication 18 AuthLegacy = AuthMode(iota) // Legacy authentication
17 AuthUserPass // Username + password authentication 19 AuthUserPass // Username + password authentication
18 AuthKeyPair // Access/secret key pair authentication 20 AuthKeyPair // Access/secret key pair authentication
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 v := reflect.ValueOf(cred).Elem() 92 v := reflect.ValueOf(cred).Elem()
91 t := v.Type() 93 t := v.Type()
92 for i := 0; i < v.NumField(); i++ { 94 for i := 0; i < v.NumField(); i++ {
93 f := v.Field(i) 95 f := v.Field(i)
94 if f.String() == "" { 96 if f.String() == "" {
95 err = fmt.Errorf("required environment variable not set for credentials attribute: %s", t.Field(i).Name) 97 err = fmt.Errorf("required environment variable not set for credentials attribute: %s", t.Field(i).Name)
96 } 98 }
97 } 99 }
98 return 100 return
99 } 101 }
102
103 // NewAuthenticator creates an authenticator matching the supplied AuthMode.
104 // The httpclient is allowed to be nil, the Authenticator will just use the
105 // default http.Client
106 func NewAuthenticator(authMode AuthMode, httpClient *goosehttp.Client) Authentic ator {
107 if httpClient == nil {
108 httpClient = goosehttp.New()
109 }
110 switch authMode {
111 default:
112 panic(fmt.Errorf("Invalid identity authorisation mode: %d", auth Mode))
113 case AuthLegacy:
114 return &Legacy{client: httpClient}
115 case AuthUserPass:
116 return &UserPass{client: httpClient}
117 case AuthKeyPair:
118 return &KeyPair{client: httpClient}
119 }
120 }
OLDNEW
« no previous file with comments | « client/local_test.go ('k') | identity/identity_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b