Documentation ¶
Index ¶
- Variables
- type AWSCognito
- type CognitoClient
- func (c *CognitoClient) ChangePassword(accessToken, prevPass, newPass string) (*cogIdp.ChangePasswordOutput, error)
- func (c *CognitoClient) ConfirmForgotPassword(newPass, code, username string) (*cogIdp.ConfirmForgotPasswordOutput, error)
- func (c *CognitoClient) ConfirmSignUp(code, username string) (*cogIdp.ConfirmSignUpOutput, error)
- func (c *CognitoClient) ForgotPassword(username string) (*cogIdp.ForgotPasswordOutput, error)
- func (c *CognitoClient) GetUser(username string) (*cogIdp.AdminGetUserOutput, error)
- func (c *CognitoClient) Init() error
- func (c *CognitoClient) SecretHash(username string) string
- func (c *CognitoClient) SignIn(username, password string) (*cogIdp.InitiateAuthOutput, error)
- func (c *CognitoClient) SignUp(username, password, confirmPass, email string) (*cogIdp.SignUpOutput, error)
- func (c *CognitoClient) ValidateToken(tokenStr string) (models.AuthenticatedUser, error)
- type JWK
- type JWKKey
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AWSCognito ¶
type AWSCognito interface { Init() error SecretHash(string) string SignUp(string, string, string, string) (*cogIdp.SignUpOutput, error) SignIn(string, string) (*cogIdp.InitiateAuthOutput, error) GetUser(string) (*cogIdp.AdminGetUserOutput, error) ConfirmSignUp(string) (*cogIdp.ConfirmSignUpOutput, error) ValidateToken(string, map[string]JWKKey) error ForgotPassword(string) (*cogIdp.ForgotPasswordOutput, error) ConfirmForgotPassword(string, string, string) (*cogIdp.ConfirmForgotPasswordOutput, error) ChangePassword(string, string, string) (*cogIdp.ChangePasswordOutput, error) }
AWSCognito methods interface
type CognitoClient ¶
type CognitoClient struct{}
* see Using ID Tokens and Access Tokens in your Web APIs: https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-with-identity-providers.html
decode and verify the sitnature of Cognito JSON web key token: https://aws.amazon.com/premiumsupport/knowledge-center/decode-verify-cognito-json-token/
verify token example: https://github.com/mura123yasu/go-cognito/blob/master/verifyToken.go
Email and phone verification: https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-email-phone-verification.html
CognitoClient is an empty structure
func (*CognitoClient) ChangePassword ¶
func (c *CognitoClient) ChangePassword(accessToken, prevPass, newPass string) (*cogIdp.ChangePasswordOutput, error)
ChangePassword resets password for the user (a link to their email)
func (*CognitoClient) ConfirmForgotPassword ¶
func (c *CognitoClient) ConfirmForgotPassword(newPass, code, username string) (*cogIdp.ConfirmForgotPasswordOutput, error)
ConfirmForgotPassword
func (*CognitoClient) ConfirmSignUp ¶
func (c *CognitoClient) ConfirmSignUp(code, username string) (*cogIdp.ConfirmSignUpOutput, error)
ConfirmSignUp confirms user registration link sent to their email
func (*CognitoClient) ForgotPassword ¶
func (c *CognitoClient) ForgotPassword(username string) (*cogIdp.ForgotPasswordOutput, error)
ForgotPassword requires custom_message in Cognito with a Lambda function to custom link with username and confirm code
func (*CognitoClient) GetUser ¶
func (c *CognitoClient) GetUser(username string) (*cogIdp.AdminGetUserOutput, error)
* output: {"level":"info","msg":"output from getting user: %v\n{\n Enabled: true,\n UserAttributes: [{\n Name: \"sub\",\n Value: \"b6e60099-4efa-4b37-a799-d82e314a71e9\"\n },{\n Name: \"email_verified\",\n Value: \"false\"\n },{\n Name: \"email\",\n Value: \"gwang81@gmail.com\"\n }],\n UserCreateDate: 2018-02-20 05:46:17 +0000 UTC,\n UserLastModifiedDate: 2018-02-20 05:46:17 +0000 UTC,\n UserStatus: \"UNCONFIRMED\",\n Username: \"gwang81\"\n}","time":"2018-02-19T22:10:48-08:00"}
func (*CognitoClient) Init ¶
func (c *CognitoClient) Init() error
Init initializes all the variables as well as the jwk
func (*CognitoClient) SecretHash ¶
func (c *CognitoClient) SecretHash(username string) string
SecretHash is for generating secret hash specific to username
func (*CognitoClient) SignIn ¶
func (c *CognitoClient) SignIn(username, password string) (*cogIdp.InitiateAuthOutput, error)
func (*CognitoClient) SignUp ¶
func (c *CognitoClient) SignUp(username, password, confirmPass, email string) (*cogIdp.SignUpOutput, error)
SignUp registers a user given the username info
func (*CognitoClient) ValidateToken ¶
func (c *CognitoClient) ValidateToken(tokenStr string) (models.AuthenticatedUser, error)
ValidateToken validates the token provided by client