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 set for auth
|
||||||
Options() Options
|
Options() Options
|
||||||
// Generate a new account
|
// 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 access to a resource
|
||||||
Grant(role string, res *Resource) error
|
Grant(role string, res *Resource) error
|
||||||
// Revoke access to a resource
|
// Revoke access to a resource
|
||||||
@ -42,8 +44,8 @@ type Auth interface {
|
|||||||
Verify(acc *Account, res *Resource) error
|
Verify(acc *Account, res *Resource) error
|
||||||
// Inspect a token
|
// Inspect a token
|
||||||
Inspect(token string) (*Account, error)
|
Inspect(token string) (*Account, error)
|
||||||
// Token generated using an account ID and secret
|
// Token generated using refresh token
|
||||||
Token(id, secret string, opts ...TokenOption) (*Token, error)
|
Token(id, refreshToken string, opts ...TokenOption) (*Token, error)
|
||||||
// String returns the name of the implementation
|
// String returns the name of the implementation
|
||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
@ -60,10 +62,12 @@ type Resource struct {
|
|||||||
|
|
||||||
// Account provided by an auth provider
|
// Account provided by an auth provider
|
||||||
type Account struct {
|
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"`
|
ID string `json:"id"`
|
||||||
// Secret used to renew the account
|
// RefreshToken used to renew the account
|
||||||
Secret string `json:"secret"`
|
RefreshToken string `json:"refresh_token"`
|
||||||
// Roles associated with the Account
|
// Roles associated with the Account
|
||||||
Roles []string `json:"roles"`
|
Roles []string `json:"roles"`
|
||||||
// Any other associated metadata
|
// Any other associated metadata
|
||||||
|
Loading…
Reference in New Issue
Block a user