Update interface to add provider and make secret optional

This commit is contained in:
Ben Toogood
2020-03-31 19:01:43 +01:00
parent cffb0a1eae
commit 82bc3cbf8d
6 changed files with 153 additions and 79 deletions

View File

@@ -32,9 +32,9 @@ type Auth interface {
// Options set for auth
Options() Options
// Generate a new account
Generate(id, secret string, opts ...GenerateOption) (*Account, error)
Generate(id string, opts ...GenerateOption) (*Account, error)
// Login to an existing account
Login(id, secret string) (*Account, error)
Login(id string, opts ...LoginOption) (*Account, error)
// Grant access to a resource
Grant(role string, res *Resource) error
// Revoke access to a resource
@@ -61,10 +61,12 @@ type Resource struct {
// Account provided by an auth provider
type Account struct {
// Type of the account, e.g. service
Type string `json:"type"`
// ID of the account e.g. email
ID string `json:"id"`
// Type of the account, e.g. service
Type string `json:"type"`
// Provider who issued the account
Provider string `json:"provider"`
// RefreshToken used to renew the account
RefreshToken string `json:"refresh_token"`
// Roles associated with the Account