Tie AccessProvider back to service Provider.
To issue a revokation request, I needed to know the Identity API
endpoint. This endpoint exists in the Provider used to create the
AccessProvider. This change threads a link back to the Provider.
diff --git a/authenticate.go b/authenticate.go
index 7665304..edd447c 100644
--- a/authenticate.go
+++ b/authenticate.go
@@ -44,6 +44,7 @@
Token Token
ServiceCatalog []CatalogEntry
User User
+ provider Provider `json:"-"`
}
// Token encapsulates an authentication token and when it expires. It also includes
@@ -125,6 +126,9 @@
&access,
},
})
+ if err == nil {
+ access.provider = p
+ }
return access, err
}
@@ -142,5 +146,12 @@
// See AccessProvider interface definition for details.
func (a *Access) Revoke(tok string) error {
- return nil
+ url := a.provider.AuthEndpoint + "/" + tok
+ err := perigee.Delete(url, perigee.Options{
+ MoreHeaders: map[string]string{
+ "X-Auth-Token": a.AuthToken(),
+ },
+ OkCodes: []int{204},
+ })
+ return err
}