Documentation ¶
Index ¶
- Variables
- func ContextToken(c *gin.Context) (*auth.Token, error)
- func Next(projectID, credentialsFile string) gin.HandlerFunc
- func NextSuccessHandler(projectID, credentialsFile string, handler middleware.SuccessHandler) gin.HandlerFunc
- func NextWithAuthClient(authClient *AuthClient) gin.HandlerFunc
- func NextWithAuthClientSuccessHandler(authClient *AuthClient, handler middleware.SuccessHandler) gin.HandlerFunc
- func NextWithConfig(config FirebaseConfig) gin.HandlerFunc
- type AuthClient
- type FirebaseConfig
- type IDToken
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ContextKey = "user" ErrMissing = xerror.NewHTTPError(http.StatusBadRequest, "missing or malformed firebase") ErrInvalid = xerror.NewHTTPError(http.StatusUnauthorized, "invalid or expired firebase") )
Functions ¶
func NextSuccessHandler ¶
func NextSuccessHandler(projectID, credentialsFile string, handler middleware.SuccessHandler) gin.HandlerFunc
NextSuccessHandler SuccessHandler config
func NextWithAuthClient ¶
func NextWithAuthClient(authClient *AuthClient) gin.HandlerFunc
NextWithAuthClient firebase AuthClient
func NextWithAuthClientSuccessHandler ¶
func NextWithAuthClientSuccessHandler(authClient *AuthClient, handler middleware.SuccessHandler) gin.HandlerFunc
NextWithAuthClientSuccessHandler firebase AuthClient and middleware.SuccessHandler
func NextWithConfig ¶
func NextWithConfig(config FirebaseConfig) gin.HandlerFunc
Types ¶
type AuthClient ¶
func NewAuthClient ¶
func NewAuthClient(projectID, credentialsFile, apiKey string) (*AuthClient, error)
NewAuthClient projectID && apiKey https://console.firebase.google.com/project/xxxxxx/settings/general?hl=zh-cn credentialsFile https://console.firebase.google.com/project/xxxxxx/settings/serviceaccounts/adminsdk?hl=zh-cn
func (AuthClient) TokenToIDToken ¶
func (f AuthClient) TokenToIDToken(token string) (IDToken, error)
TokenToIDToken https://firebase.google.com/docs/reference/rest/auth?hl=zh-cn
type FirebaseConfig ¶
type FirebaseConfig struct { // Skipper defines a function to skip middleware. Skipper middleware.Skipper // middleware or handler. SuccessHandler middleware.SuccessHandler // ErrorHandler defines a function which is executed for an invalid token. // It may be used to define a custom JWT error. ErrorHandler middleware.ErrorHandler // Context key to store user information from the token into context. // Optional. Default value "user". ContextKey string // TokenLookup is a string in the form of "<source>:<name>" or "<source>:<name>,<source>:<name>" that is used // to extract token from the request. // Optional. Default value "header:Authorization". // Possible values: // - "header:<name>" or "header:<name>:<cut-prefix>" // `<cut-prefix>` is argument value to cut/trim prefix of the extracted value. This is useful if header // value has static prefix like `Authorization: <auth-scheme> <authorisation-parameters>` where part that we // want to cut is `<auth-scheme> ` note the space at the end. // In case of JWT tokens `Authorization: Bearer <token>` prefix we cut is `Bearer `. // If prefix is left empty the whole value is returned. // - "query:<name>" // - "param:<name>" // - "cookie:<name>" // - "form:<name>" // Multiple sources example: // - "header:Authorization,cookie:myowncookie" TokenLookup string // AuthScheme to be used in the Authorization header. // Optional. Default value "Bearer". AuthScheme string //NewAuthClient AuthClient *AuthClient }
FirebaseConfig defines the config for BasicAuth middleware.
Click to show internal directories.
Click to hide internal directories.