Documentation
¶
Index ¶
Constants ¶
const GenericRetrievalErr = "unable to retrieve user"
const TokenHeader string = "X-Lbry-Auth-Token"
TokenHeader is the name of HTTP header which is supplied by client and should contain internal-api auth_token.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthenticatedFunc ¶ added in v0.8.0
type AuthenticatedFunc func(http.ResponseWriter, *AuthenticatedRequest)
type AuthenticatedRequest ¶ added in v0.8.0
func (*AuthenticatedRequest) AuthFailed ¶ added in v0.8.0
func (r *AuthenticatedRequest) AuthFailed() bool
AuthFailed is a helper to see if there was an error authenticating user.
func (*AuthenticatedRequest) IsAuthenticated ¶ added in v0.8.0
func (r *AuthenticatedRequest) IsAuthenticated() bool
IsAuthenticated is a helper to see if a user was authenticated. If it is false, AuthError might be provided (in case user retriever has errored) or be nil if no auth token was present in headers.
type Authenticator ¶ added in v0.8.0
type Authenticator struct {
// contains filtered or unexported fields
}
func NewAuthenticator ¶ added in v0.8.0
func NewAuthenticator(retriever Retriever) *Authenticator
NewAuthenticator provides HTTP handler wrapping methods and should be initialized with an object that allows user retrieval.
func (*Authenticator) GetAccountID ¶ added in v0.8.0
func (a *Authenticator) GetAccountID(r *http.Request) (string, error)
GetAccountID retrieves user token from HTTP headers and subsequently an SDK account ID from Retriever.
func (*Authenticator) Wrap ¶ added in v0.8.0
func (a *Authenticator) Wrap(wrapped AuthenticatedFunc) http.HandlerFunc
Wrap result can be supplied to all functions that accept http.HandleFunc, supplied function will be wrapped and called with AuthenticatedRequest instead of http.Request.
type Query ¶ added in v0.8.2
Query contains queried user details and optional metadata about the request
type RemoteUser ¶
RemoteUser encapsulates internal-apis user data
type Retriever ¶ added in v0.8.0
Retriever is an interface for user retrieval by internal-apis auth token
type TestUserRetriever ¶ added in v0.8.0
TestUserRetriever is a helper allowing to test API endpoints that require authentication without actually creating DB records.
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService stores manipulated user data
func NewUserService ¶
func NewUserService() *UserService
NewUserService returns UserService instance for retrieving or creating user records and accounts.