handlers

package
v0.0.0-...-219ab8e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthHandler

type AuthHandler interface {
	HandleRegister() func(w http.ResponseWriter, r *http.Request)
	HandleLogin() func(w http.ResponseWriter, r *http.Request)
	HandleRefresh() func(w http.ResponseWriter, r *http.Request)
	HandleDelete() func(w http.ResponseWriter, r *http.Request)
}

AuthHandler is an interface for handling authentication requests

type DeleteRequestBody

type DeleteRequestBody struct {
	IDToken string `json:"idToken"`
}

DeleteRequestBody is the request body for the delete endpoint

type ErrorResponseBody

type ErrorResponseBody struct {
	Error struct {
		Code    int                  `json:"code"`
		Message ErrorResponseMessage `json:"message"`
		Errors  []struct {
			Message string `json:"message"`
			Domain  string `json:"domain"`
			Reason  string `json:"reason"`
		} `json:"errors"`
	} `json:"error"`
}

ErrorResponseBody is the response body for an error https://firebase.google.com/docs/reference/rest/auth#section-error-format

type ErrorResponseMessage

type ErrorResponseMessage string
const (
	ErrorEmailExists             ErrorResponseMessage = "EMAIL_EXISTS"
	ErrorOperationNotAllowed     ErrorResponseMessage = "OPERATION_NOT_ALLOWED"
	ErrorTooManyAttempts         ErrorResponseMessage = "TOO_MANY_ATTEMPTS_TRY_LATER"
	ErrorInvalidEmail            ErrorResponseMessage = "INVALID_EMAIL"
	ErrorInvalidLoginCredentials ErrorResponseMessage = "INVALID_LOGIN_CREDENTIALS"
	ErrorTokenExpired            ErrorResponseMessage = "TOKEN_EXPIRED"
	ErrorInvalidIDToken          ErrorResponseMessage = "INVALID_ID_TOKEN"
	ErrorUserNotFound            ErrorResponseMessage = "USER_NOT_FOUND"
	ErrorWeakPassword            ErrorResponseMessage = "WEAK_PASSWORD : Password should be at least 6 characters"
)

type FirebaseAuthHandler

type FirebaseAuthHandler struct {
	// contains filtered or unexported fields
}

FirebaseAuthHandler implements AuthHandler using Firebase Auth REST API

func NewFirebaseAuthHandler

func NewFirebaseAuthHandler(apiKey string) *FirebaseAuthHandler

NewFirebaseAuthHandler creates a new instance of FirebaseAuthHandler

func (*FirebaseAuthHandler) HandleDelete

func (s *FirebaseAuthHandler) HandleDelete() func(w http.ResponseWriter, r *http.Request)

HandleDelete handles requests to the delete endpoint https://firebase.google.com/docs/reference/rest/auth#section-delete-account

func (*FirebaseAuthHandler) HandleLogin

func (s *FirebaseAuthHandler) HandleLogin() func(w http.ResponseWriter, r *http.Request)

HandleLogin handles requests to the login endpoint https://firebase.google.com/docs/reference/rest/auth#section-sign-in-email-password

func (*FirebaseAuthHandler) HandleRefresh

func (s *FirebaseAuthHandler) HandleRefresh() func(w http.ResponseWriter, r *http.Request)

HandleRefresh handles requests to the refresh endpoint https://firebase.google.com/docs/reference/rest/auth#section-refresh-token

func (*FirebaseAuthHandler) HandleRegister

func (s *FirebaseAuthHandler) HandleRegister() func(w http.ResponseWriter, r *http.Request)

HandleRegister handles requests to the register endpoint https://firebase.google.com/docs/reference/rest/auth#section-create-email-password

type LoginRequestBody

type LoginRequestBody struct {
	Email             string `json:"email"`
	Password          string `json:"password"`
	ReturnSecureToken bool   `json:"returnSecureToken"`
}

LoginRequestBody is the request body for the login endpoint

type LoginResponseBody

type LoginResponseBody struct {
	IDToken      string `json:"idToken"`
	Email        string `json:"email"`
	RefreshToken string `json:"refreshToken"`
	ExpiresIn    string `json:"expiresIn"`
	LocalID      string `json:"localId"`
	Registered   bool   `json:"registered"`
}

LoginResponseBody is the response body for the login endpoint

type RefreshRequestBody

type RefreshRequestBody struct {
	GrantType    string `json:"grant_type"`
	RefreshToken string `json:"refresh_token"`
}

RefreshRequestBody is the request body for the refresh endpoint

type RefreshResponseBody

type RefreshResponseBody struct {
	ExpiresIn    string `json:"expires_in"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token"`
	IDToken      string `json:"id_token"`
	UserID       string `json:"user_id"`
	ProjectID    string `json:"project_id"`
}

RefreshResponseBody is the response body for the refresh endpoint

type RegisterRequestBody

type RegisterRequestBody struct {
	Email             string `json:"email"`
	Password          string `json:"password"`
	ReturnSecureToken bool   `json:"returnSecureToken"`
}

RegisterRequestBody is the request body for the register endpoint

type RegisterResponseBody

type RegisterResponseBody struct {
	IDToken      string `json:"idToken"`
	Email        string `json:"email"`
	RefreshToken string `json:"refreshToken"`
	ExpiresIn    string `json:"expiresIn"`
	LocalID      string `json:"localId"`
}

RegisterResponseBody is the response body for the register endpoint

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL