model

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorInvalidRequest       = "invalid_request"
	ErrorInvalidClient        = "invalid_client"
	ErrorInvalidGrant         = "invalid_grant"
	ErrorUnauthorizedClient   = "unauthorized_client"
	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

View Source
const (
	ErrorInternal                 = "internal_server_error"
	ErrorOIDC                     = "oidc_error"
	ErrorNYI                      = "not_yet_implemented"
	ErrorInsufficientCapabilities = "insufficient_capabilities"
	ErrorUsageRestricted          = "usage_restricted"
)

Additional Mytoken errors

Variables

View Source
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

View Source
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

func OIDCFlowIsInSlice(f OIDCFlow, s []OIDCFlow) bool

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

func BadRequestError(errorDescription string) APIError

BadRequestError creates an APIError for bad request errors

func ErrorWithErrorDescription

func ErrorWithErrorDescription(e string, err error) APIError

ErrorWithErrorDescription creates an APIError from an error string and golang error

func ErrorWithoutDescription

func ErrorWithoutDescription(err string) APIError

ErrorWithoutDescription creates an APIError from an error string

func InternalServerError

func InternalServerError(errorDescription string) APIError

InternalServerError creates an APIError for internal server errors

func InvalidTokenError

func InvalidTokenError(errorDescription string) APIError

InvalidTokenError creates an APIError for invalid token errors

func OIDCError

func OIDCError(oidcError, oidcErrorDescription string) APIError

OIDCError creates an APIError for oidc related errors

func OIDCErrorFromBody

func OIDCErrorFromBody(body []byte) (error APIError, ok bool)

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

func NewGrantType(s string) GrantType

NewGrantType creates a new GrantType from the grant type string

func (GrantType) AddToSliceIfNotFound

func (g GrantType) AddToSliceIfNotFound(s *[]GrantType)

AddToSliceIfNotFound adds the GrantType to a slice s if it is not already there

func (GrantType) MarshalJSON

func (g GrantType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*GrantType) String

func (g *GrantType) String() string

func (*GrantType) UnmarshalJSON

func (g *GrantType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

func (*GrantType) UnmarshalYAML

func (g *GrantType) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface

func (*GrantType) Valid

func (g *GrantType) Valid() bool

Valid checks that GrantType is a defined grant type

type OIDCFlow

type OIDCFlow int

OIDCFlow is a enum like type for oidc flows

const (
	OIDCFlowAuthorizationCode OIDCFlow = iota
	OIDCFlowDevice
)

OIDCFlows

func NewOIDCFlow

func NewOIDCFlow(s string) OIDCFlow

NewOIDCFlow creates a new OIDCFlow from the flow string

func (OIDCFlow) AddToSliceIfNotFound

func (f OIDCFlow) AddToSliceIfNotFound(s *[]OIDCFlow)

AddToSliceIfNotFound adds the OIDCFlow to a slice s if it is not already there

func (OIDCFlow) MarshalJSON

func (f OIDCFlow) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*OIDCFlow) String

func (f *OIDCFlow) String() string

func (*OIDCFlow) UnmarshalJSON

func (f *OIDCFlow) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

func (*OIDCFlow) UnmarshalYAML

func (f *OIDCFlow) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface

func (*OIDCFlow) Valid

func (f *OIDCFlow) Valid() bool

Valid checks that OIDCFlow is a defined flow

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

func (ResponseType) Value

func (r ResponseType) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL