Documentation ¶
Index ¶
- Variables
- type API
- type APIMock
- func (m *APIMock) CheckScope(target Scope, required Scope) bool
- func (m *APIMock) CheckSecret(hashed, secret string) (bool, error)
- func (m *APIMock) CreateEntity(ctx context.Context, id string, secret []byte, scope Scope, attrs Attrs) error
- func (m *APIMock) CreateToken(subject string, scope []string, ttl time.Duration) Token
- func (m *APIMock) GetEntity(ctx context.Context, id string) (Entity, error)
- func (m *APIMock) ParseToken(t string) (TokenClaims, error)
- func (m *APIMock) SecretKey() string
- func (m *APIMock) UpdateEntity(ctx context.Context, id string, secret []byte, scope Scope, attrs Attrs) error
- type Attrs
- type Claims
- type ClaimsMock
- type DefaultAPI
- func (a *DefaultAPI) CheckScope(target Scope, required Scope) bool
- func (a *DefaultAPI) CheckSecret(hashed, secret string) (bool, error)
- func (a *DefaultAPI) CreateEntity(ctx context.Context, id string, secret []byte, scope Scope, attrs Attrs) error
- func (a *DefaultAPI) CreateToken(subject string, scope []string, ttl time.Duration) Token
- func (a *DefaultAPI) GetEntity(ctx context.Context, id string) (Entity, error)
- func (a *DefaultAPI) ParseToken(token string) (TokenClaims, error)
- func (a *DefaultAPI) SecretKey() string
- func (a *DefaultAPI) UpdateEntity(ctx context.Context, id string, secret []byte, scope Scope, attrs Attrs) error
- type DefaultToken
- type Entity
- type ErrInvalidArg
- type Scope
- type Token
- type TokenClaims
- type TokenMock
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotFound = errors.New("not found")
)
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { SecretKey() string CheckSecret(hashed, secret string) (bool, error) CreateEntity(ctx context.Context, id string, secret []byte, scope Scope, attrs Attrs) error UpdateEntity(ctx context.Context, id string, secret []byte, scope Scope, attrs Attrs) error GetEntity(ctx context.Context, id string) (Entity, error) CheckScope(target Scope, required Scope) bool CreateToken(subject string, scope []string, ttl time.Duration) Token ParseToken(token string) (TokenClaims, error) }
type APIMock ¶
func (*APIMock) CreateEntity ¶
func (*APIMock) CreateToken ¶
func (*APIMock) ParseToken ¶
func (m *APIMock) ParseToken(t string) (TokenClaims, error)
type ClaimsMock ¶
func (*ClaimsMock) GetExpirationTime ¶
func (m *ClaimsMock) GetExpirationTime() (*jwt.NumericDate, error)
type DefaultAPI ¶
type DefaultAPI struct {
// contains filtered or unexported fields
}
func NewDefault ¶
func (*DefaultAPI) CheckScope ¶
func (a *DefaultAPI) CheckScope(target Scope, required Scope) bool
CheckScope checks whether target scope has all required scopes
func (*DefaultAPI) CheckSecret ¶
func (a *DefaultAPI) CheckSecret(hashed, secret string) (bool, error)
func (*DefaultAPI) CreateEntity ¶
func (a *DefaultAPI) CreateEntity(ctx context.Context, id string, secret []byte, scope Scope, attrs Attrs) error
CreateEntity creates a new entity. The secret should contain a hashed string, not clear text.
func (*DefaultAPI) CreateToken ¶
func (*DefaultAPI) ParseToken ¶
func (a *DefaultAPI) ParseToken(token string) (TokenClaims, error)
func (*DefaultAPI) SecretKey ¶
func (a *DefaultAPI) SecretKey() string
func (*DefaultAPI) UpdateEntity ¶
func (a *DefaultAPI) UpdateEntity(ctx context.Context, id string, secret []byte, scope Scope, attrs Attrs) error
UpdateEntity updates an existing entity. The secret should contain a hashed string, not clear text. Empty secret tells this method that it should not be updated.
type DefaultToken ¶
type DefaultToken struct {
// contains filtered or unexported fields
}
func (*DefaultToken) Claims ¶
func (t *DefaultToken) Claims() Claims
func (*DefaultToken) SignedString ¶
func (t *DefaultToken) SignedString(key interface{}) (string, error)
type ErrInvalidArg ¶
type ErrInvalidArg struct {
Msg string
}
func (ErrInvalidArg) Error ¶
func (e ErrInvalidArg) Error() string
func (ErrInvalidArg) Is ¶
func (e ErrInvalidArg) Is(err error) bool
type TokenClaims ¶
type TokenClaims struct { jwt.RegisteredClaims Scope []string `json:"scope,omitempty"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.