Parse out auth response and fill in access object
diff --git a/authenticate.go b/authenticate.go
index 09ee36f..4d3254f 100644
--- a/authenticate.go
+++ b/authenticate.go
@@ -22,11 +22,58 @@
Password string `json:"password"`
}
-type ProviderAccess interface {
- // ...
+// Access encapsulates the API token and its relevant fields, as well as the
+// services catalog that Identity API returns once authenticated. You'll probably
+// rarely use this record directly, unless you intend on marshalling or unmarshalling
+// Identity API JSON records yourself.
+type Access struct {
+ Token Token
+ ServiceCatalog []CatalogEntry
+ User User
}
-func (c *Context) Authenticate(provider string, options AuthOptions) (ProviderAccess, error) {
+// Token encapsulates an authentication token and when it expires. It also includes
+// tenant information if available.
+type Token struct {
+ Id, Expires string
+ Tenant Tenant
+}
+
+// Tenant encapsulates tenant authentication information. If, after authentication,
+// no tenant information is supplied, both Id and Name will be "".
+type Tenant struct {
+ Id, Name string
+}
+
+// User encapsulates the user credentials, and provides visibility in what
+// the user can do through its role assignments.
+type User struct {
+ Id, Name string
+ XRaxDefaultRegion string `json:"RAX-AUTH:defaultRegion"`
+ Roles []Role
+}
+
+// Role encapsulates a permission that a user can rely on.
+type Role struct {
+ Description, Id, Name string
+}
+
+// CatalogEntry encapsulates a service catalog record.
+type CatalogEntry struct {
+ Name, Type string
+ Endpoints []EntryEndpoint
+}
+
+// EntryEndpoint encapsulates how to get to the API of some service.
+type EntryEndpoint struct {
+ Region, TenantId string
+ PublicURL, InternalURL string
+ VersionId, VersionInfo, VersionList string
+}
+
+func (c *Context) Authenticate(provider string, options AuthOptions) (*Access, error) {
+ var access *Access
+
p, err := c.ProviderByName(provider)
if err != nil {
return nil, err
@@ -46,6 +93,11 @@
TenantId: options.TenantId,
},
},
+ Results: &struct{
+ Access **Access `json:"access"`
+ }{
+ &access,
+ },
})
- return nil, err
+ return access, err
}