Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTokenMissing = echo.NewHTTPError(http.StatusBadRequest, "Missing or malformed Firebase AuthID TOKEN") ErrTokenInvalid = echo.NewHTTPError(http.StatusUnauthorized, "Invalid or expired Firebase AuthID TOKEN") )
Errors
View Source
var ( // nolint // DefaultFirebaseAuthConfig is the default auth middleware config. DefaultFirebaseAuthConfig = Config{ Skipper: middleware.DefaultSkipper, ContextIDKey: "id-key", ContextUserKey: "user", ContextUserIDKey: "userID", TokenLookup: "header:" + echo.HeaderAuthorization, AuthScheme: "Bearer", } )
Functions ¶
func FirebaseAuth ¶
func FirebaseAuth() echo.MiddlewareFunc
FirebaseAuth returns a JSON Web Token (JWT) auth middleware.
For valid token, it sets the user in context and calls next handler. For invalid token, it returns "401 - Unauthorized" error. For missing token, it returns "400 - Bad Request" error.
func GetContextValue ¶
func GetContextValueMap ¶
func WithConfig ¶
func WithConfig(config Config) echo.MiddlewareFunc
WithConfig returns a FirebaseAuth middleware with config. See: `FirebaseAuth()`.
Types ¶
type Config ¶
type Config struct { // Skipper defines a function to skip middleware. Skipper middleware.Skipper // ID key to store user information from the token into context. // Optional. Default value "id-key". ContextIDKey string // Context key to store user information from the user into context. // Optional. Default value "user". ContextUserKey string ContextUserIDKey string // TokenLookup is a string in the form of "<source>:<name>" that is used // to extract token from the request. // Optional. Default value "header:Authorization". // Possible values: // - "header:<name>" // - "query:<name>" // - "cookie:<name>" TokenLookup string // AuthScheme to be used in the Authorization header. // Optional. Default value "Bearer". AuthScheme string CredentialJSON []byte }
Config defines the config for Firebase Auth JWT middleware.
Click to show internal directories.
Click to hide internal directories.