@@ -21,20 +21,40 @@ type auth_struct struct {
21
21
Scope string `json:"scope"`
22
22
}
23
23
24
- type scoped_auth_request_struct struct {
25
- Auth scoped_auth_struct `json:"auth"`
24
+ type scoped_auth_token_request_struct struct {
25
+ Auth scoped_auth_token_struct `json:"auth"`
26
26
}
27
27
28
- type scoped_auth_struct struct {
29
- Identity auth_identity_struct `json:"identity"`
30
- Scope auth_scope_struct `json:"scope"`
28
+ type scoped_auth_password_request_struct struct {
29
+ Auth scoped_auth_password_struct `json:"auth"`
30
+ }
31
+
32
+ type scoped_auth_token_struct struct {
33
+ Nocatalog bool `json:"nocatalog"`
34
+ Identity auth_scoped_identity_struct `json:"identity"`
35
+ Scope auth_scope_struct `json:"scope"`
36
+ }
37
+
38
+ type scoped_auth_password_struct struct {
39
+ Nocatalog bool `json:"nocatalog"`
40
+ Identity auth_identity_struct `json:"identity"`
41
+ Scope auth_scope_struct `json:"scope"`
42
+ }
43
+
44
+ type auth_scoped_identity_struct struct {
45
+ Methods []string `json:"methods"`
46
+ Token auth_token_method_struct `json:"token"`
31
47
}
32
48
33
49
type auth_identity_struct struct {
34
50
Methods []string `json:"methods"`
35
51
Password auth_password_method_struct `json:"password"`
36
52
}
37
53
54
+ type auth_token_method_struct struct {
55
+ Id string `json:"id"`
56
+ }
57
+
38
58
type auth_password_method_struct struct {
39
59
User auth_user_struct `json:"user"`
40
60
}
@@ -92,28 +112,39 @@ type project_struct struct {
92
112
93
113
// Authentication Section Section
94
114
type Auth_data struct {
95
- Server string
96
- Domain string
97
- Username string
98
- Password string
99
- Project string
115
+ Server string
116
+ Domain string
117
+ Username string
118
+ Password string
119
+ Project string
120
+ UnscopedToken string
100
121
//response
101
122
Token string
102
123
Expiration string
103
124
Roles []auth_roles_struct
104
125
}
105
126
106
127
func AuthenticateScoped (data * Auth_data ) error {
107
- var auth_post scoped_auth_request_struct
108
- auth_post .Auth .Identity .Methods = []string {"password" }
109
- auth_post .Auth .Identity .Password .User .Name = data .Username
110
- auth_post .Auth .Identity .Password .User .Password = data .Password
111
- auth_post .Auth .Identity .Password .User .Domain .Name = data .Domain
112
- auth_post .Auth .Scope .Project .Domain .Name = data .Domain
113
- auth_post .Auth .Scope .Project .Name = data .Project
114
- b , _ := json .Marshal (auth_post )
115
-
116
- return authenticate (data , b )
128
+ if data .UnscopedToken != "" {
129
+ var auth_post scoped_auth_token_request_struct
130
+ auth_post .Auth .Identity .Methods = []string {"token" }
131
+ auth_post .Auth .Identity .Token .Id = data .UnscopedToken
132
+ auth_post .Auth .Scope .Project .Domain .Name = data .Domain
133
+ auth_post .Auth .Scope .Project .Name = data .Project
134
+ b , _ := json .Marshal (auth_post )
135
+ return authenticate (data , b )
136
+ } else {
137
+ var auth_post scoped_auth_password_request_struct
138
+ auth_post .Auth .Nocatalog = true
139
+ auth_post .Auth .Identity .Methods = []string {"password" }
140
+ auth_post .Auth .Identity .Password .User .Name = data .Username
141
+ auth_post .Auth .Identity .Password .User .Password = data .Password
142
+ auth_post .Auth .Identity .Password .User .Domain .Name = data .Domain
143
+ auth_post .Auth .Scope .Project .Domain .Name = data .Domain
144
+ auth_post .Auth .Scope .Project .Name = data .Project
145
+ b , _ := json .Marshal (auth_post )
146
+ return authenticate (data , b )
147
+ }
117
148
}
118
149
119
150
func AuthenticateUnscoped (data * Auth_data ) error {
0 commit comments