Tweak Auth Interface
This commit is contained in:
parent
2674790694
commit
8dbb5153f4
16
auth/auth.go
16
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user