Documentation ¶
Index ¶
- Constants
- Variables
- func AddAuthHeaders(ctx context.Context, r *http.Request, serviceToken string)
- func AddDeprecatedHeader(r *http.Request, token string)
- func AddDownloadServiceTokenHeader(r *http.Request, serviceToken string)
- func AddFlorenceHeader(r *http.Request, userAccessToken string)
- func AddRequestIdHeader(r *http.Request, token string)
- func AddServiceTokenHeader(r *http.Request, serviceToken string)
- func AddUserHeader(r *http.Request, user string)
- func Caller(ctx context.Context) string
- func ErrMissingMember(members []string) error
- func ErrUnsupportedOp(op string, supportedOps []PatchOp) error
- func GetCollectionID(req *http.Request) (string, error)
- func GetLangFromCookieOrDefault(c *http.Cookie) string
- func GetLangFromSubDomain(req *http.Request) string
- func GetLocaleCode(r *http.Request) string
- func GetRequestId(ctx context.Context) string
- func HandlerRequestID(size int) func(http.Handler) http.Handler
- func IsCallerPresent(ctx context.Context) bool
- func IsFlorenceIdentityPresent(ctx context.Context) bool
- func IsUserPresent(ctx context.Context) bool
- func NewRequestID(size int) string
- func SetCaller(ctx context.Context, caller string) context.Context
- func SetFlorenceHeader(ctx context.Context, r *http.Request)
- func SetFlorenceIdentity(ctx context.Context, user string) context.Context
- func SetLocaleCode(req *http.Request) *http.Request
- func SetUser(ctx context.Context, user string) context.Context
- func User(ctx context.Context) string
- func WithRequestId(ctx context.Context, correlationId string) context.Context
- type CheckRequester
- type ContextKey
- type IdentityResponse
- type Params
- type Patch
- type PatchOp
Constants ¶
const ( CollectionIDHeaderKey = "Collection-Id" CollectionIDCookieKey = "collection" )
CollectionID header and cookie keys
const ( UserIdentityKey = ContextKey("User-Identity") CallerIdentityKey = ContextKey("Caller-Identity") RequestIdKey = ContextKey("request-id") FlorenceIdentityKey = ContextKey("florence-id") LocaleContextKey = ContextKey(LocaleHeaderKey) CollectionIDContextKey = ContextKey(CollectionIDHeaderKey) )
Context keys
const ( FlorenceHeaderKey = "X-Florence-Token" AuthHeaderKey = "Authorization" DownloadServiceHeaderKey = "X-Download-Service-Token" UserHeaderKey = "User-Identity" )
Header constants
const ( DeprecatedAuthHeader = "Internal-Token" LegacyUser = "legacyUser" BearerPrefix = "Bearer " )
Other identity-related constants
const ( LangEN = "en" LangCY = "cy" DefaultLang = LangEN LocaleCookieKey = "lang" LocaleHeaderKey = "LocaleCode" )
const (
FlorenceCookieKey = "access_token"
)
Cookie constants
const (
RequestHeaderKey = "X-Request-Id"
)
Header constants
Variables ¶
var ErrInvalidOp = fmt.Errorf("operation is missing or not valid. Please, provide one of the following: %v", validOps)
ErrInvalidOp is an error returned when a patch contains a wrong 'op'
var SupportedLanguages = [2]string{LangEN, LangCY}
Functions ¶
func AddAuthHeaders ¶
AddAuthHeaders sets authentication headers for request
func AddDeprecatedHeader ¶
AddDeprecatedHeader sets the deprecated header on the given request
func AddDownloadServiceTokenHeader ¶
AddDownloadServiceTokenHeader sets the given download service token on the given request
func AddFlorenceHeader ¶
AddFlorenceHeader sets the given user access token (florence token) token on the given request
func AddRequestIdHeader ¶
AddRequestIdHeader add header for given correlation ID
func AddServiceTokenHeader ¶
AddServiceTokenHeader sets the given service token on the given request
func AddUserHeader ¶
AddUserHeader sets the given user ID on the given request
func ErrMissingMember ¶ added in v1.0.10
ErrMissingMember generates an error for a missing member
func ErrUnsupportedOp ¶ added in v1.0.10
ErrUnsupportedOp generates an error for unsupported ops
func GetLangFromCookieOrDefault ¶
GetLangFromCookieOrDefault returns a language based on the lang cookie or if not valid defaults it
func GetLangFromSubDomain ¶
GetLangFromSubDomain returns a language based on subdomain
func GetLocaleCode ¶ added in v1.0.9
GetLocaleCode will grab the locale code from the request
func GetRequestId ¶
GetRequestId gets the correlation id on the context
func HandlerRequestID ¶
HandlerRequestID is a wrapper which adds an X-Request-Id header if one does not yet exist
func IsCallerPresent ¶
IsCallerPresent determines if an identity is present on the given context.
func IsFlorenceIdentityPresent ¶
IsFlorenceIdentityPresent determines if a florence identity is present on the given context
func IsUserPresent ¶
IsUserPresent determines if a user identity is present on the given context
func NewRequestID ¶
NewRequestID generates a random string of requested length
func SetFlorenceHeader ¶
SetFlorenceHeader sets a florence Header if the corresponding Identity key is in context
func SetFlorenceIdentity ¶
SetFlorenceIdentity sets the florence identity for authentication
func SetLocaleCode ¶
SetLocaleCode will fetch the locale code and then sets it
Types ¶
type CheckRequester ¶
CheckRequester is an interface to allow mocking of auth.CheckRequest
type IdentityResponse ¶
type IdentityResponse struct {
Identifier string `json:"identifier"`
}
IdentityResponse represents the response from the identity service
type Params ¶
Params represents a generic map of key value pairs, expected by go-ns/audit Auditor.Record()