Documentation ¶
Index ¶
- func GetAccessToken(ctx context.Context) string
- func GetGroups(ctx context.Context) []string
- func GetRequestID(ctx context.Context) string
- func GetSubject(ctx context.Context) string
- func HasGroup(ctx context.Context, group string) bool
- func IsAPIError(err error) bool
- func IsBadGatewayError(err error) bool
- func IsBadRequestError(err error) bool
- func IsConflictError(err error) bool
- func IsForbiddenError(err error) bool
- func IsInternalServerError(err error) bool
- func IsNotFoundError(err error) bool
- func IsUnauthorizedError(err error) bool
- type APIError
- func NewAPIError(ctx context.Context, status int, message ErrorMessageCode, details url.Values) APIError
- func NewBadGateway(ctx context.Context, message ErrorMessageCode, details url.Values) APIError
- func NewBadRequest(ctx context.Context, message ErrorMessageCode, details url.Values) APIError
- func NewConflict(ctx context.Context, message ErrorMessageCode, details url.Values) APIError
- func NewForbidden(ctx context.Context, message ErrorMessageCode, details url.Values) APIError
- func NewInternalServerError(ctx context.Context, message ErrorMessageCode, details url.Values) APIError
- func NewNotFound(ctx context.Context, message ErrorMessageCode, details url.Values) APIError
- func NewUnauthorized(ctx context.Context, message ErrorMessageCode, details url.Values) APIError
- type AllClaims
- type CtxKeyAPIKey
- type CtxKeyAccessToken
- type CtxKeyClaims
- type CtxKeyIDToken
- type CtxKeyRequestID
- type CustomClaims
- type ErrorMessageCode
- type StatusError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAccessToken ¶
GetAccessToken obtains the raw access token from the context.
This is without the "Bearer " prefix.
func GetGroups ¶
GetGroups extracts the groups from the jwt token that came with the request or from the groups retrieved from userinfo, if using authorization token.
In either case the list is filtered by relevant groups (if reg-auth-service is configured).
func GetRequestID ¶
GetRequestID extracts the request ID from the context.
It originally comes from a header with the request, or is rolled while processing the request.
func GetSubject ¶
GetSubject extracts the subject field from the jwt token or the userinfo response, if using an authorization token.
func IsAPIError ¶
func IsBadGatewayError ¶
func IsBadRequestError ¶
func IsConflictError ¶
func IsForbiddenError ¶
func IsInternalServerError ¶
func IsNotFoundError ¶
func IsUnauthorizedError ¶
Types ¶
type APIError ¶
APIError allows lower layers of the service to provide detailed information about an error.
While this breaks layer separation somewhat, it avoids having to map errors all over the place.
func NewAPIError ¶
func NewAPIError(ctx context.Context, status int, message ErrorMessageCode, details url.Values) APIError
NewAPIError creates a generic API error from directly provided information.
func NewBadGateway ¶
func NewBadRequest ¶
func NewConflict ¶
func NewForbidden ¶
func NewInternalServerError ¶
func NewNotFound ¶
func NewUnauthorized ¶
type AllClaims ¶
type AllClaims struct { jwt.RegisteredClaims CustomClaims }
type CtxKeyAPIKey ¶
type CtxKeyAPIKey struct{}
type CtxKeyAccessToken ¶
type CtxKeyAccessToken struct{}
type CtxKeyClaims ¶
type CtxKeyClaims struct{}
type CtxKeyIDToken ¶
type CtxKeyIDToken struct{}
type CtxKeyRequestID ¶
type CtxKeyRequestID struct{}
type CustomClaims ¶
type ErrorMessageCode ¶
type ErrorMessageCode string
ErrorMessageCode is a key to use for error messages in frontends or other automated systems interacting with our API. It avoids having to parse human-readable language for error classification beyond the http status.
const ( AuthForbidden ErrorMessageCode = "auth.forbidden" // permissions missing RequestParseFailed ErrorMessageCode = "request.parse.failed" ValueTooHigh ErrorMessageCode = "value.too.high" ValueTooLow ErrorMessageCode = "value.too.low" InternalErrorMessage ErrorMessageCode = "error.internal" UnknownErrorMessage ErrorMessageCode = "error.unknown" )
type StatusError ¶
type StatusError struct {
// contains filtered or unexported fields
}
func (*StatusError) Error ¶
func (se *StatusError) Error() string
func (*StatusError) Response ¶
func (se *StatusError) Response() apimodel.Error
func (*StatusError) Status ¶
func (se *StatusError) Status() int