From 8dbb5153f4851c72d6e9f695daff8520241564f1 Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Tue, 31 Mar 2020 17:01:51 +0100 Subject: [PATCH] Tweak Auth Interface --- auth/auth.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index 4c175110..6bb9e479 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -33,7 +33,9 @@ type Auth interface { // Options set for auth Options() Options // Generate a new account - Generate(id string, opts ...GenerateOption) (*Account, error) + Generate(id, secret string, opts ...GenerateOption) (*Account, error) + // Login to an existing account + Login(id, secret string) (*Account, error) // Grant access to a resource Grant(role string, res *Resource) error // Revoke access to a resource @@ -42,8 +44,8 @@ type Auth interface { Verify(acc *Account, res *Resource) error // Inspect a token Inspect(token string) (*Account, error) - // Token generated using an account ID and secret - Token(id, secret string, opts ...TokenOption) (*Token, error) + // Token generated using refresh token + Token(id, refreshToken string, opts ...TokenOption) (*Token, error) // String returns the name of the implementation String() string } @@ -60,10 +62,12 @@ type Resource struct { // Account provided by an auth provider type Account struct { - // ID of the account (UUIDV4, email or username) + // Type of the account, e.g. service + Type string `json:"type"` + // ID of the account e.g. email ID string `json:"id"` - // Secret used to renew the account - Secret string `json:"secret"` + // RefreshToken used to renew the account + RefreshToken string `json:"refresh_token"` // Roles associated with the Account Roles []string `json:"roles"` // Any other associated metadata