Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallbackRequest ¶
type CallbackRequest struct {
Code string `json:"code"`
CodeVerifier string `json:"code_verifier"`
}
CallbackRequest is the JSON body for the callback request.
type Config ¶
type Config struct {
GoogleClientID string
GoogleClientSecret string
RedirectURL string
PrivateKeyPEM string
AllowedGoogleIDs []string
}
Config holds the parameters needed to create a Handler.
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse is the standard error JSON we return.
type GoogleUserInfo ¶
GoogleUserInfo holds the fields we extract from the verified Google ID token.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the Google OAuth2 login flow and issues JWTs.
func NewHandler ¶
NewHandler creates an auth Handler from the given config.
func (*Handler) RegisterRoutes ¶
RegisterRoutes mounts /auth/login and /auth/callback on the given mux.
type IDTokenValidator ¶
type IDTokenValidator interface {
Validate(ctx context.Context, idToken string, audience string) (*idtoken.Payload, error)
}
IDTokenValidator validates a Google ID token and returns the payload.
type TokenExchanger ¶
type TokenExchanger interface {
Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
}
TokenExchanger exchanges an authorization code for an OAuth2 token.
type TokenResponse ¶
type TokenResponse struct {
Token string `json:"token"`
}
TokenResponse is the JSON returned to the client after successful login.