Documentation
¶
Index ¶
- func GenerateState() string
- type CognitoAdapter
- func (a *CognitoAdapter) AdminDeleteUser(ctx context.Context, username string) error
- func (a *CognitoAdapter) ClaimsFromCode(ctx context.Context, code string) (jwt.MapClaims, error)
- func (a *CognitoAdapter) ConfirmAccount(ctx context.Context, email string, code string) (bool, error)
- func (a *CognitoAdapter) DeleteUser(ctx context.Context, accessToken string) error
- func (a *CognitoAdapter) ForgotPassword(ctx context.Context, userName string) (*string, error)
- func (a *CognitoAdapter) GetUserByToken(ctx context.Context, token string) (*CognitoUser, error)
- func (a *CognitoAdapter) GetUsersByEmail(ctx context.Context, email string) ([]*CognitoUser, error)
- func (a *CognitoAdapter) ListUnconfirmedUsers(ctx context.Context) ([]*CognitoUser, error)
- func (a *CognitoAdapter) OauthCodeUrl(state string) string
- func (a *CognitoAdapter) ResendConfirmationCode(ctx context.Context, username string) error
- func (a *CognitoAdapter) ResetPassword(ctx context.Context, code string, userName string, password string) error
- func (a *CognitoAdapter) SignIn(ctx context.Context, email string, password string) (*types.AuthenticationResultType, error)
- func (a *CognitoAdapter) SignUp(ctx context.Context, firstName string, lastName string, email string, ...) (bool, error)
- func (a *CognitoAdapter) UpdateAttributes(ctx context.Context, username string, attributes []types.AttributeType) error
- func (a *CognitoAdapter) UpdatePassword(ctx context.Context, email string, password string) error
- type CognitoUser
- type OauthHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateState ¶ added in v0.3.2
func GenerateState() string
Types ¶
type CognitoAdapter ¶ added in v0.3.0
type CognitoAdapter struct {
// contains filtered or unexported fields
}
func New ¶ added in v0.3.0
func New(cognitoConfig configs.Cognito, region string) (*CognitoAdapter, error)
New creates a new Cognito adapter with the provided configuration. This function handles all the complex setup internally, including creating the Cognito client and OAuth handler based on whether you're using a local or production environment.
func (*CognitoAdapter) AdminDeleteUser ¶ added in v0.4.0
func (a *CognitoAdapter) AdminDeleteUser(ctx context.Context, username string) error
AdminDeleteUser deletes a user from the Cognito User Pool by username using admin credentials. Use this for server-side cleanup where no user access token is available (e.g., removing unconfirmed users). Only removes the user from the pool — unconfirmed users are not persisted in the application DB.
func (*CognitoAdapter) ClaimsFromCode ¶ added in v0.3.0
func (*CognitoAdapter) ConfirmAccount ¶ added in v0.3.0
func (*CognitoAdapter) DeleteUser ¶ added in v0.3.0
func (a *CognitoAdapter) DeleteUser(ctx context.Context, accessToken string) error
DeleteUser deletes the user from the Cognito User Pool using their access token. Use this only for user-initiated flows where the user is logged in (e.g., "Delete my account"). The pool is inferred from the token. Only removes the user from the pool, not any application data. Not suitable for batch cleanup — use AdminDeleteUser instead, which only requires a username.
func (*CognitoAdapter) ForgotPassword ¶ added in v0.3.0
func (*CognitoAdapter) GetUserByToken ¶ added in v0.3.0
func (a *CognitoAdapter) GetUserByToken(ctx context.Context, token string) (*CognitoUser, error)
func (*CognitoAdapter) GetUsersByEmail ¶ added in v0.3.0
func (a *CognitoAdapter) GetUsersByEmail(ctx context.Context, email string) ([]*CognitoUser, error)
func (*CognitoAdapter) ListUnconfirmedUsers ¶ added in v0.4.0
func (a *CognitoAdapter) ListUnconfirmedUsers(ctx context.Context) ([]*CognitoUser, error)
func (*CognitoAdapter) OauthCodeUrl ¶ added in v0.3.0
func (a *CognitoAdapter) OauthCodeUrl(state string) string
func (*CognitoAdapter) ResendConfirmationCode ¶ added in v0.3.0
func (a *CognitoAdapter) ResendConfirmationCode(ctx context.Context, username string) error
func (*CognitoAdapter) ResetPassword ¶ added in v0.3.0
func (*CognitoAdapter) SignIn ¶ added in v0.3.0
func (a *CognitoAdapter) SignIn(ctx context.Context, email string, password string) (*types.AuthenticationResultType, error)
func (*CognitoAdapter) UpdateAttributes ¶ added in v0.3.0
func (a *CognitoAdapter) UpdateAttributes(ctx context.Context, username string, attributes []types.AttributeType) error
func (*CognitoAdapter) UpdatePassword ¶ added in v0.3.0
type CognitoUser ¶ added in v0.3.0
type OauthHandler ¶
type OauthHandler struct {
// contains filtered or unexported fields
}
func NewCognitoOauthHandler ¶ added in v0.2.6
func NewCognitoOauthHandler(cognitoConfig configs.Cognito, scopes []string) (*OauthHandler, error)
NewCognitoOauthHandler is a wrapper on NewOauthHandler that uses the CognitoConfig for most of the variables.
func NewOauthHandler ¶
func NewOauthHandler(clientId string, clientSecret string, redirectUrl string, issuerUrl string, scopes []string) (*OauthHandler, error)
NewOauthHandler creates a handler that is meant to operate between oidc and oauth to handle the necessary redirects and issuer interactions. This has been tested against Cognito specifically.
func (*OauthHandler) AuthCodeUrl ¶
func (h *OauthHandler) AuthCodeUrl(state string, opts ...oauth2.AuthCodeOption) string
func (*OauthHandler) ExchangeCode ¶
func (*OauthHandler) Verifier ¶
func (h *OauthHandler) Verifier() *oidc.IDTokenVerifier