Documentation
¶
Index ¶
- Constants
- Variables
- func OIDCFlowIsInSlice(f OIDCFlow, s []OIDCFlow) bool
- type APIError
- func BadRequestError(errorDescription string) APIError
- func ErrorWithErrorDescription(e string, err error) APIError
- func ErrorWithoutDescription(err string) APIError
- func InternalServerError(errorDescription string) APIError
- func InvalidTokenError(errorDescription string) APIError
- func OIDCError(oidcError, oidcErrorDescription string) APIError
- func OIDCErrorFromBody(body []byte) (error APIError, ok bool)
- type GrantType
- type OIDCFlow
- type ResponseType
- func (r ResponseType) AddToSliceIfNotFound(s *[]ResponseType)
- func (r ResponseType) MarshalJSON() ([]byte, error)
- func (r *ResponseType) Scan(src interface{}) error
- func (r *ResponseType) String() string
- func (r *ResponseType) UnmarshalJSON(data []byte) error
- func (r *ResponseType) UnmarshalYAML(value *yaml.Node) error
- func (r *ResponseType) Valid() bool
- func (r ResponseType) Value() (driver.Value, error)
Constants ¶
const ( ErrorInvalidRequest = "invalid_request" ErrorInvalidClient = "invalid_client" ErrorInvalidGrant = "invalid_grant" ErrorUnsupportedGrantType = "unsupported_grant_type" ErrorInvalidScope = "invalid_scope" ErrorInvalidToken = "invalid_token" ErrorInsufficientScope = "insufficient_scope" ErrorExpiredToken = "expired_token" ErrorAccessDenied = "access_denied" ErrorAuthorizationPending = "authorization_pending" )
Predefined OAuth2/OIDC errors
const ( ErrorInternal = "internal_server_error" ErrorOIDC = "oidc_error" ErrorNYI = "not_yet_implemented" ErrorInsufficientCapabilities = "insufficient_capabilities" ErrorUsageRestricted = "usage_restricted" )
Additional Mytoken errors
Variables ¶
var ( APIErrorUnknownIssuer = APIError{ErrorInvalidRequest, "The provided issuer is not supported"} APIErrorStateMismatch = APIError{ErrorInvalidRequest, "State mismatched"} APIErrorUnsupportedOIDCFlow = APIError{ErrorInvalidGrant, "Unsupported oidc_flow"} APIErrorUnsupportedGrantType = APIError{ErrorInvalidGrant, "Unsupported grant_type"} APIErrorBadTransferCode = APIError{ErrorInvalidToken, "Bad polling or transfer code"} APIErrorTransferCodeExpired = APIError{ErrorExpiredToken, "polling or transfer code is expired"} APIErrorAuthorizationPending = ErrorWithoutDescription(ErrorAuthorizationPending) APIErrorNoRefreshToken = APIError{ErrorOIDC, "Did not receive a refresh token"} APIErrorInsufficientCapabilities = APIError{ErrorInsufficientCapabilities, "The provided token does not have the required capability for this operation"} APIErrorUsageRestricted = APIError{ErrorUsageRestricted, "The restrictions of this token does not allow this usage"} APIErrorNYI = ErrorWithoutDescription(ErrorNYI) )
Predefined errors
var AllGrantTypes = [...]string{"super_token", "oidc_flow", "polling_code", "access_token", "private_key_jwt", "transfer_code"}
AllGrantTypes holds all defined GrantType strings
Functions ¶
func OIDCFlowIsInSlice ¶
OIDCFlowIsInSlice checks if a OIDCFlow is present in a slice of OIDCFlows
Types ¶
type APIError ¶
type APIError struct {
Error string `json:"error"`
ErrorDescription string `json:"error_description,omitempty"`
}
APIError is an error object that is returned on the api when an error occurs
func BadRequestError ¶
BadRequestError creates an APIError for bad request errors
func ErrorWithErrorDescription ¶
ErrorWithErrorDescription creates an APIError from an error string and golang error
func ErrorWithoutDescription ¶
ErrorWithoutDescription creates an APIError from an error string
func InternalServerError ¶
InternalServerError creates an APIError for internal server errors
func InvalidTokenError ¶
InvalidTokenError creates an APIError for invalid token errors
func OIDCErrorFromBody ¶
OIDCErrorFromBody creates an APIError for oidc related errors from the response of an oidc provider
type GrantType ¶
type GrantType int
GrantType is an enum like type for grant types
const ( GrantTypeSuperToken GrantType = iota GrantTypeOIDCFlow GrantTypePollingCode GrantTypeAccessToken GrantTypePrivateKeyJWT GrantTypeTransferCode )
GrantTypes
func NewGrantType ¶
NewGrantType creates a new GrantType from the grant type string
func (GrantType) AddToSliceIfNotFound ¶
AddToSliceIfNotFound adds the GrantType to a slice s if it is not already there
func (GrantType) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface
func (*GrantType) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface
func (*GrantType) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface
type OIDCFlow ¶
type OIDCFlow int
OIDCFlow is a enum like type for oidc flows
func NewOIDCFlow ¶
NewOIDCFlow creates a new OIDCFlow from the flow string
func (OIDCFlow) AddToSliceIfNotFound ¶
AddToSliceIfNotFound adds the OIDCFlow to a slice s if it is not already there
func (OIDCFlow) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface
func (*OIDCFlow) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface
func (*OIDCFlow) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface
type ResponseType ¶
type ResponseType int
ResponseType is a enum like type for response types
const ( ResponseTypeToken ResponseType = iota ResponseTypeShortToken ResponseTypeTransferCode )
ResponseTypes
func NewResponseType ¶
func NewResponseType(s string) ResponseType
NewResponseType creates a new ResponseType from the given response type string
func (ResponseType) AddToSliceIfNotFound ¶
func (r ResponseType) AddToSliceIfNotFound(s *[]ResponseType)
AddToSliceIfNotFound adds the ResponseType to a slice s if it is not already there
func (ResponseType) MarshalJSON ¶
func (r ResponseType) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface
func (*ResponseType) Scan ¶
func (r *ResponseType) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
func (*ResponseType) String ¶
func (r *ResponseType) String() string
func (*ResponseType) UnmarshalJSON ¶
func (r *ResponseType) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface
func (*ResponseType) UnmarshalYAML ¶
func (r *ResponseType) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implements the yaml.Unmarshaler interface
func (*ResponseType) Valid ¶
func (r *ResponseType) Valid() bool
Valid checks that ResponseType is a defined flow