Documentation ¶
Index ¶
- Variables
- type AddUserScopesArgs
- type Auth
- func (auth *Auth) AddUserScopes(ctx context.Context, args AddUserScopesArgs) error
- func (auth *Auth) Authorization(r *http.Request) (*Token, error)
- func (auth *Auth) CreateKey(ctx context.Context, args CreateKeyArgs) (*TokenResult, error)
- func (auth *Auth) GetToken(ctx context.Context, tokenString string) (*Token, error)
- func (auth *Auth) GetUser(ctx context.Context, args GetUserArgs) (*GetUserResult, error)
- func (auth *Auth) GetUserScopes(ctx context.Context, args GetUserScopesArgs) (*GetUserScopesResult, error)
- func (auth *Auth) Invalidate(ctx context.Context, args InvalidateArgs) error
- func (auth *Auth) Login(ctx context.Context, args LoginArgs) (*TokenResult, error)
- func (auth *Auth) PublicKey(ctx context.Context) (interface{}, error)
- func (auth *Auth) Signup(ctx context.Context, args SignupArgs) (*TokenResult, error)
- func (auth *Auth) UpdateUser(ctx context.Context, args UpdateUserArgs) error
- func (auth *Auth) Validate(ctx context.Context, args ValidateArgs) (*TokenResult, error)
- type CallError
- type CreateKeyArgs
- type GetUserArgs
- type GetUserResult
- type GetUserScopesArgs
- type GetUserScopesResult
- type InvalidTokenError
- type InvalidateArgs
- type LoginArgs
- type LoginBody
- type Scopes
- type SignupArgs
- type SignupBody
- type Token
- type TokenClaims
- type TokenResult
- type UpdateUserArgs
- type UpdateUserBody
- type ValidateArgs
Constants ¶
This section is empty.
Variables ¶
var ErrNoToken = errors.New("no token")
Functions ¶
This section is empty.
Types ¶
type AddUserScopesArgs ¶
type Auth ¶
type Auth struct { URL string AuthToken string // either a service token string, user token string, or empty. Log interface { Println(v ...interface{}) Printf(format string, v ...interface{}) } // contains filtered or unexported fields }
func (*Auth) AddUserScopes ¶
func (auth *Auth) AddUserScopes(ctx context.Context, args AddUserScopesArgs) error
func (*Auth) Authorization ¶
Authorization gets the token from the Authorization header, passes it to GetToken. Returns ErrNoToken if the expected token is not present.
func (*Auth) CreateKey ¶
func (auth *Auth) CreateKey(ctx context.Context, args CreateKeyArgs) (*TokenResult, error)
func (*Auth) GetToken ¶
GetToken reads tokenString, returns a validated *Token, or error. The error can be of type *InvalidTokenError, *CallError, *url.Error, or other.
func (*Auth) GetUser ¶
func (auth *Auth) GetUser(ctx context.Context, args GetUserArgs) (*GetUserResult, error)
func (*Auth) GetUserScopes ¶
func (auth *Auth) GetUserScopes(ctx context.Context, args GetUserScopesArgs) (*GetUserScopesResult, error)
func (*Auth) Invalidate ¶
func (auth *Auth) Invalidate(ctx context.Context, args InvalidateArgs) error
func (*Auth) Signup ¶
func (auth *Auth) Signup(ctx context.Context, args SignupArgs) (*TokenResult, error)
func (*Auth) UpdateUser ¶
func (auth *Auth) UpdateUser(ctx context.Context, args UpdateUserArgs) error
func (*Auth) Validate ¶
func (auth *Auth) Validate(ctx context.Context, args ValidateArgs) (*TokenResult, error)
type CallError ¶
type CallError struct { Msg string HTTPStatus string HTTPStatusCode int ScopeRequired string IsUserError bool }
CallError is a generic API call error from a failed HTTP request.
func NewCallError ¶
NewCallError creates a *CallError from the HTTP Response, or nil if the status is 200. The body should not be read yet, this call reads the body if the result is not nil. The caller needs to close the body sometime after this call.
type CreateKeyArgs ¶
type GetUserArgs ¶
type GetUserArgs struct {
User string
}
type GetUserResult ¶
type GetUserScopesArgs ¶
type GetUserScopesArgs struct {
User string
}
type GetUserScopesResult ¶
type InvalidTokenError ¶
type InvalidTokenError struct {
*jwt.ValidationError
}
func (*InvalidTokenError) Expired ¶
func (err *InvalidTokenError) Expired() bool
func (*InvalidTokenError) Unwrap ¶
func (err *InvalidTokenError) Unwrap() error
type InvalidateArgs ¶
type InvalidateArgs struct {
// contains filtered or unexported fields
}
type Scopes ¶
type Scopes []string
func GetTokenScopes ¶
GetTokenScopes gets the Scopes from the Token. Only guaranteed to work on tokens returned by Auth.
func (Scopes) MarshalText ¶
func (*Scopes) UnmarshalText ¶
type SignupArgs ¶
type SignupArgs struct { NoPassword bool AnyEmail bool SignupBody }
type SignupBody ¶
type TokenClaims ¶
type TokenClaims = jwt.MapClaims
type TokenResult ¶
type UpdateUserArgs ¶
type UpdateUserArgs struct {
UpdateUserBody
}
type UpdateUserBody ¶
type UpdateUserBody struct {
Updates map[string]interface{} `json:"updates"`
}
type ValidateArgs ¶
type ValidateArgs struct {
// contains filtered or unexported fields
}