models

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BodyReadError                = "RequestBodyReadError"
	JSONMarshalError             = "JSONMarshalError"
	JSONUnmarshalError           = "JSONUnmarshalError"
	WriteResponseError           = "WriteResponseError"
	InvalidUserIDError           = "InvalidUserId"
	InvalidGroupIDError          = "InvalidGroupID"
	InvalidForenameError         = "InvalidForename"
	InvalidSurnameError          = "InvalidSurname"
	InvalidStatusNotesError      = "InvalidStatusNotes"
	InvalidEmailError            = "InvalidEmail"
	InvalidTokenError            = "InvalidToken"
	InternalError                = "InternalServerError"
	NotFoundError                = "NotFound"
	UserNotFoundError            = "UserNotFound"
	GroupExistsError             = "GroupExists"
	GroupNotFoundError           = "GroupNotFound"
	DeliveryFailureError         = "DeliveryFailure"
	InvalidCodeError             = "InvalidCode"
	ExpiredCodeError             = "ExpiredCode"
	InvalidFieldError            = "InvalidField"
	InvalidPasswordError         = "InvalidPassword"
	LimitExceededError           = "LimitExceeded"
	NotAuthorisedError           = "NotAuthorised"
	PasswordResetRequiredError   = "PasswordResetRequired"
	TooManyFailedAttemptsError   = "TooManyFailedAttempts"
	TooManyRequestsError         = "TooManyRequests"
	UserNotConfirmedError        = "UserNotConfirmed"
	UsernameExistsError          = "UsernameExists"
	MissingConfigError           = "MissingConfig"
	UnknownRequestTypeError      = "UnknownRequestType"
	NotImplementedError          = "NotImplemented"
	InvalidChallengeSessionError = "InvalidChallengeSession"
	InvalidUserPoolError         = "InvalidUserPool"
	BodyCloseError               = "BodyCloseError"
	InvalidGroupName             = "InvalidGroupName"
	InvalidGroupPrecedence       = "InvalidGroupPrecedence"
	InvalidFilterQuery           = "InvalidFilterQuery"
	JWKSParseError               = "JWKSParseError"
)

API error codes

View Source
const (
	MissingAuthorizationTokenDescription   = "no Authorization token was provided"
	MissingRefreshTokenDescription         = "no Refresh token was provided"
	MissingIDTokenDescription              = "no ID token was provided"         //nolint:gosec // not a hardcoded secret
	MalformedIDTokenDescription            = "the ID token could not be parsed" //nolint:gosec // not a hardcoded secret
	MalformedAuthorizationTokenDescription = "the authorization token does not meet the required format"
	ErrorMarshalFailedDescription          = "failed to marshal the error"
	ErrorUnmarshalFailedDescription        = "failed to unmarshal the request body"
	WriteResponseFailedDescription         = "failed to write http response"
	CastingAWSErrorFailedDescription       = "failed to cast error to AWS error"
	UnrecognisedCognitoResponseDescription = "unexpected response from cognito"
	BodyReadFailedDescription              = "endpoint returned an error reading the request body"
	InvalidPasswordDescription             = "the submitted password could not be validated"
	PasswordGenerationErrorDescription     = "failed to generate a valid password"
	MissingGroupIDErrorDescription         = "the group ID was missing"
	MissingUserIDErrorDescription          = "the user id was missing"
	InvalidForenameErrorDescription        = "the submitted user's forename could not be validated"
	InvalidSurnameErrorDescription         = "the submitted user's lastname could not be validated"
	InvalidEmailDescription                = "the submitted email could not be validated"
	DuplicateEmailDescription              = "account using email address found"
	SignInFailedDescription                = "Incorrect username or password."
	SignInAttemptsExceededDescription      = "Password attempts exceeded"
	MissingConfigDescription               = "required configuration setting is missing"
	UnknownPasswordChangeTypeDescription   = "unknown password change type received"
	NotImplementedDescription              = "this feature has not been implemented yet"
	InvalidChallengeSessionDescription     = "no valid auth challenge session was provided"
	InvalidTokenDescription                = "the submitted token could not be validated"
	TooLongStatusNotesDescription          = "the status notes are too long"
	InvalidUserPoolDescription             = "dummy data load being run against non local userpool"
	BodyClosedFailedDescription            = "the request body failed to close"
	MissingGroupName                       = "the group name was not found"
	MissingGroupPrecedence                 = "the group precedence was not found"
	GroupPrecedenceIncorrect               = "the group precedence needs to be a minumum of 10 and maximum of 100"
	IncorrectPatternInGroupName            = "a group name cannot start with 'role-' or 'ROLE-'"
	GroupAlreadyExistsDescription          = "a group with the name already exists"
	InvalidFilterQueryDescription          = "the submitted query could not be validated"
	InternalErrorDescription               = "Internal Server Error"
	JWKSParseErrorDescription              = "error encountered when parsing the json web key set (jwks)"
	JWKSUnsupportedKeyTypeDescription      = "unsupported key type. Must be rsa key"
	JWKSErrorDecodingDescription           = "error decoding json web key"
	JWKSExponentErrorDescription           = "unexpected exponent: unable to decode JWK"
	JWKSEmptyWebKeySetDescription          = "empty json web key set"
)

API error descriptions

View Source
const (
	AdminRoleGroup                  = "role-admin"
	AdminRoleGroupPrecedence        = 2
	AdminRoleGroupHumanReadable     = "Administrators"
	PublisherRoleGroup              = "role-publisher"
	PublisherRoleGroupPrecedence    = 3
	PublisherRoleGroupHumanReadable = "Publishing Officers"
)
View Source
const (
	NewPasswordRequiredType = "NewPasswordRequired"
	ForgottenPasswordType   = "ForgottenPassword"
	MaxStatusNotesLength    = 512
	SecondsInDay            = 86400
)

Variables

View Source
var CognitoErrorMapping = map[string]string{
	cognitoidentityprovider.ErrCodeInternalErrorException:          InternalError,
	cognitoidentityprovider.ErrCodeCodeDeliveryFailureException:    DeliveryFailureError,
	cognitoidentityprovider.ErrCodeCodeMismatchException:           InvalidCodeError,
	cognitoidentityprovider.ErrCodeConcurrentModificationException: InternalError,
	cognitoidentityprovider.ErrCodeExpiredCodeException:            ExpiredCodeError,
	cognitoidentityprovider.ErrCodeGroupExistsException:            GroupExistsError,
	cognitoidentityprovider.ErrCodeInvalidOAuthFlowException:       InternalError,
	cognitoidentityprovider.ErrCodeInvalidParameterException:       InvalidFieldError,
	cognitoidentityprovider.ErrCodeInvalidPasswordException:        InvalidPasswordError,
	cognitoidentityprovider.ErrCodeLimitExceededException:          LimitExceededError,
	cognitoidentityprovider.ErrCodeNotAuthorizedException:          NotAuthorisedError,
	cognitoidentityprovider.ErrCodePasswordResetRequiredException:  PasswordResetRequiredError,
	cognitoidentityprovider.ErrCodeResourceNotFoundException:       NotFoundError,
	cognitoidentityprovider.ErrCodeTooManyFailedAttemptsException:  TooManyFailedAttemptsError,
	cognitoidentityprovider.ErrCodeTooManyRequestsException:        TooManyRequestsError,
	cognitoidentityprovider.ErrCodeUserNotConfirmedException:       UserNotConfirmedError,
	cognitoidentityprovider.ErrCodeUserNotFoundException:           UserNotFoundError,
	cognitoidentityprovider.ErrCodeUsernameExistsException:         UsernameExistsError,
	request.ErrCodeSerialization:                                   InternalError,
	request.ErrCodeRead:                                            InternalError,
	request.ErrCodeResponseTimeout:                                 InternalError,
	request.ErrCodeInvalidPresignExpire:                            InternalError,
	request.CanceledErrorCode:                                      InternalError,
	request.ErrCodeRequestError:                                    InternalError,
}

CognitoErrorMapping mapping Cognito error codes to API error codes

Functions

func BuildSuccessfulSignOutAllUsersJSONResponse

func BuildSuccessfulSignOutAllUsersJSONResponse(ctx context.Context) ([]byte, error)

BuildSuccessfulSignOutAllUsersJSONResponse creates a JSON response for successful sign-out of all users.

func CleanString

func CleanString(description string) string

CleanString - strip special chars out of incoming string and trim

func IsGroupExistsError

func IsGroupExistsError(err error) bool

IsGroupExistsError checks if the given error is a Cognito GroupExistsException error.

func MapCognitoErrorToLocalError

func MapCognitoErrorToLocalError(ctx context.Context, cognitoErr awserr.Error) string

MapCognitoErrorToLocalError maps an AWS Cognito error to a local error code.

Types

type AccessToken

type AccessToken struct {
	AuthHeader  string // Authorization header containing the token.
	TokenString string // Actual token string extracted from AuthHeader.
}

AccessToken represents a token used for authorization.

func (*AccessToken) GenerateSignOutRequest

func (t *AccessToken) GenerateSignOutRequest() *cognitoidentityprovider.GlobalSignOutInput

GenerateSignOutRequest creates a sign-out request for AWS Cognito using the access token.

func (*AccessToken) Validate

func (t *AccessToken) Validate(ctx context.Context) *Error

Validate checks if the AuthHeader is well-formed and extracts the token string.

type ChangePassword

type ChangePassword struct {
	ChangeType        string `json:"type"`
	Session           string `json:"session"`
	Email             string `json:"email"`
	NewPassword       string `json:"password"`
	VerificationToken string `json:"verification_token"`
}

func (ChangePassword) BuildAuthChallengeResponseRequest

func (p ChangePassword) BuildAuthChallengeResponseRequest(clientSecret, clientID, challengeName string) *cognitoidentityprovider.RespondToAuthChallengeInput

BuildAuthChallengeResponseRequest generates a RespondToAuthChallengeInput for Cognito

func (ChangePassword) BuildAuthChallengeSuccessfulJSONResponse

func (p ChangePassword) BuildAuthChallengeSuccessfulJSONResponse(ctx context.Context, result *cognitoidentityprovider.RespondToAuthChallengeOutput, refreshTokenTTL int) ([]byte, error)

BuildAuthChallengeSuccessfulJSONResponse builds the ChangePassword response json for client responses to NewPasswordRequired changes

func (ChangePassword) BuildConfirmForgotPasswordRequest

func (p ChangePassword) BuildConfirmForgotPasswordRequest(clientSecret, clientID string) *cognitoidentityprovider.ConfirmForgotPasswordInput

func (ChangePassword) ValidateForgottenPasswordRequest

func (p ChangePassword) ValidateForgottenPasswordRequest(ctx context.Context) []error

func (ChangePassword) ValidateNewPasswordRequiredRequest

func (p ChangePassword) ValidateNewPasswordRequiredRequest(ctx context.Context) []error

ValidateNewPasswordRequiredRequest validates the required fields have been submitted and meet the basic structure requirements

type CreateUpdateGroup

type CreateUpdateGroup struct {
	Name       *string `json:"name"`
	Precedence *int64  `json:"precedence"`
	ID         *string `json:"id"`
	GroupsList *cognitoidentityprovider.ListGroupsOutput
}

func (*CreateUpdateGroup) BuildCreateGroupInput

func (g *CreateUpdateGroup) BuildCreateGroupInput(userPoolID *string) *cognitoidentityprovider.CreateGroupInput

func (*CreateUpdateGroup) BuildSuccessfulJSONResponse

func (g *CreateUpdateGroup) BuildSuccessfulJSONResponse(ctx context.Context) ([]byte, error)

func (*CreateUpdateGroup) BuildUpdateGroupInput

func (g *CreateUpdateGroup) BuildUpdateGroupInput(userPoolID string) *cognitoidentityprovider.UpdateGroupInput

BuildUpdateGroupInput builds a correctly populated UpdateGroupInput object using Groups values

func (*CreateUpdateGroup) NewSuccessResponse

func (g *CreateUpdateGroup) NewSuccessResponse(jsonBody []byte, statusCode int, headers map[string]string) *SuccessResponse

NewSuccessResponse - returns a custom response where group description is returned as group name

func (*CreateUpdateGroup) ValidateCreateUpdateGroupRequest

func (g *CreateUpdateGroup) ValidateCreateUpdateGroupRequest(ctx context.Context, isCreate bool) []error

ValidateCreateUpdateGroupRequest validate the create group request

type CreateUserInput

type CreateUserInput struct {
	UserInput *cognitoidentityprovider.AdminCreateUserInput
}

type CreateUserOutput

type CreateUserOutput struct {
	UserOutput *cognitoidentityprovider.AdminCreateUserOutput
}

type Error

type Error struct {
	Cause       error  `json:"-"`           // The underlying error, if available.
	Code        string `json:"code"`        // Error code representing the type of error.
	Description string `json:"description"` // Detailed description of the error.
}

Error represents a custom error type with additional context and description.

func NewCognitoError

func NewCognitoError(ctx context.Context, err error, errContext string) *Error

NewCognitoError creates a new Error for errors returned from AWS Cognito, mapping it to a local error code.

func NewError

func NewError(ctx context.Context, cause error, code, description string) *Error

NewError creates and logs a new Error with the provided context, cause, code, and description.

func NewValidationError

func NewValidationError(ctx context.Context, code, description string) *Error

NewValidationError creates a new Error specifically for validation errors with a code and description.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message string for the custom Error type.

type ErrorResponse

type ErrorResponse struct {
	Errors  []error           `json:"errors"`
	Status  int               `json:"-"`
	Headers map[string]string `json:"-"`
}

func NewErrorResponse

func NewErrorResponse(statusCode int, headers map[string]string, errors ...error) *ErrorResponse

type GlobalSignOut

type GlobalSignOut struct {
	ResultsChannel  chan string
	BackoffSchedule []time.Duration
	RetryAllowed    bool
}

func (GlobalSignOut) BuildSignOutUserRequest

func (g GlobalSignOut) BuildSignOutUserRequest(users *[]UserParams, userPoolID *string) []*cognitoidentityprovider.AdminUserGlobalSignOutInput

BuildSignOutUserRequest - standalone request builder - builds a signout request array

this is required for concurrent global signout requests

type Group

type Group struct {
	ID         string    `json:"id"`
	Name       string    `json:"name"`
	Precedence int64     `json:"precedence"`
	Created    time.Time `json:"created"`
}

Group is a type for the identity API representation of a group's details

func NewAdminRoleGroup

func NewAdminRoleGroup() Group

NewAdminRoleGroup is a constructor for a new instance of the admin role group

func NewPublisherRoleGroup

func NewPublisherRoleGroup() Group

NewPublisherRoleGroup is a constructor for a new instance of the publisher role group

func (*Group) BuildAddUserToGroupRequest

func (g *Group) BuildAddUserToGroupRequest(userPoolID, userID string) *cognitoidentityprovider.AdminAddUserToGroupInput

BuildAddUserToGroupRequest builds a correctly populated AdminAddUserToGroupInput object

func (*Group) BuildCreateGroupRequest

func (g *Group) BuildCreateGroupRequest(userPoolID string) *cognitoidentityprovider.CreateGroupInput

BuildCreateGroupRequest builds a correctly populated CreateGroupInput object using the Groups values

func (*Group) BuildDeleteGroupRequest

func (g *Group) BuildDeleteGroupRequest(userPoolID string) *cognitoidentityprovider.DeleteGroupInput

BuildDeleteGroupRequest builds a correctly populated DeleteGroupInput object using the Groups values

func (*Group) BuildGetGroupRequest

func (g *Group) BuildGetGroupRequest(userPoolID string) *cognitoidentityprovider.GetGroupInput

BuildGetGroupRequest builds a correctly populated GetGroupInput object using the Groups values

func (*Group) BuildListUsersInGroupRequest

func (g *Group) BuildListUsersInGroupRequest(userPoolID string) *cognitoidentityprovider.ListUsersInGroupInput

BuildListUsersInGroupRequest builds a correctly populated ListUsersInGroupInput object

func (*Group) BuildListUsersInGroupRequestWithNextToken

func (g *Group) BuildListUsersInGroupRequestWithNextToken(userPoolID, nextToken string) *cognitoidentityprovider.ListUsersInGroupInput

BuildListUsersInGroupRequestWithNextToken builds a correctly populated ListUsersInGroupInput object with Next Token

func (*Group) BuildRemoveUserFromGroupRequest

func (g *Group) BuildRemoveUserFromGroupRequest(userPoolID, userID string) *cognitoidentityprovider.AdminRemoveUserFromGroupInput

BuildRemoveUserFromGroupRequest builds a correctly populated AdminRemoveUserFromGroupInput object

func (*Group) BuildSuccessfulJSONResponse

func (g *Group) BuildSuccessfulJSONResponse(ctx context.Context) ([]byte, error)

BuildSuccessfulJSONResponse builds the Group response json for client responses

func (*Group) MapCognitoDetails

func (g *Group) MapCognitoDetails(groupDetails *cognitoidentityprovider.GroupType)

MapCognitoDetails maps the group details returned from GetGroup requests

func (*Group) ValidateAddRemoveUser

func (g *Group) ValidateAddRemoveUser(ctx context.Context, userID string) []error

ValidateAddRemoveUser validates the required fields for adding a user to a group, returns validation errors for anything that fails

type IDClaims

type IDClaims struct {
	Sub           string `json:"sub"`
	Aud           string `json:"aud"`
	EmailVerified bool   `json:"email_verified"`
	TokenUse      string `json:"token_use"`
	AuthTime      int    `json:"auth_time"`
	Iss           string `json:"iss"`
	CognitoUser   string `json:"cognito:username"`
	Exp           int    `json:"exp"`
	GivenName     string `json:"given_name"`
	Iat           int    `json:"iat"`
	Email         string `json:"email"`
	jwt.StandardClaims
}

IDClaims represents the claims contained in an ID token.

type IDToken

type IDToken struct {
	TokenString string   // JWT string representation.
	Claims      IDClaims // Parsed claims from the JWT.
}

IDToken represents a JWT containing ID claims.

func (*IDToken) ParseWithoutValidating

func (t *IDToken) ParseWithoutValidating(ctx context.Context, tokenString string) *Error

ParseWithoutValidating parses the claims in an ID token JWT in to a IdClaims struct without validating the token

func (*IDToken) Validate

func (t *IDToken) Validate(ctx context.Context) *Error

Validate validates the existence of a JWT string and that it is correctly formatting, storing the tokens claims in an IdClaims struct

type ListGroupUsersType

type ListGroupUsersType struct {
	GroupName string `type:"string" json:"group"`
	UserEmail string `type:"string" json:"user"`
}

ListGroupUsersType list of groups and the membership for user report group-report

type ListUserGroupType

type ListUserGroupType struct {
	CreationDate     *time.Time `type:"timestamp" json:"creation_date"`
	Name             *string    `type:"string" json:"name"`
	ID               *string    `min:"1" type:"string" json:"id"`
	LastModifiedDate *time.Time `type:"timestamp" json:"last_modified_date"`
	Precedence       *int64     `type:"integer" json:"precedence"`
	RoleArn          *string    `min:"20" type:"string" json:"role_arn"`
	UserPoolID       *string    `min:"1" type:"string" json:"user_pool_id"`
}

ListUserGroupType output structure from cognitoidentityprovider.AdminListGroupsForUserOutput but changing the json output

func (*ListUserGroupType) BuildListGroupsRequest

func (g *ListUserGroupType) BuildListGroupsRequest(userPoolID, nextToken string) *cognitoidentityprovider.ListGroupsInput

BuildListGroupsRequest build the require input for cognito query to obtain the groups for given user

type ListUserGroups

type ListUserGroups struct {
	Groups    []*ListUserGroupType `json:"groups"`
	NextToken *string              `json:"next_token"`
	Count     int                  `json:"count"`
}

ListUserGroups list of groups for user output structure from cognitoidentityprovider.AdminListGroupsForUserOutput with count of total groups returned

func (*ListUserGroups) BuildListGroupsSuccessfulJSONResponse

func (p *ListUserGroups) BuildListGroupsSuccessfulJSONResponse(ctx context.Context, result *cognitoidentityprovider.ListGroupsOutput) ([]byte, error)

BuildListGroupsSuccessfulJSONResponse formats the output to comply with current standards and to json , adds the count of groups returned and

func (*ListUserGroups) BuildListUserGroupsSuccessfulJSONResponse

func (p *ListUserGroups) BuildListUserGroupsSuccessfulJSONResponse(ctx context.Context, result *cognitoidentityprovider.AdminListGroupsForUserOutput) ([]byte, error)

BuildListUserGroupsSuccessfulJSONResponse formats the output to comply with current standards and to json , adds the count of groups returned and

type ListUsersInput

type ListUsersInput struct {
	ListUsersInput *cognitoidentityprovider.ListUsersInput
}

type ListUsersOutput

type ListUsersOutput struct {
	ListUsersOutput *cognitoidentityprovider.ListUsersOutput
}

type PasswordReset

type PasswordReset struct {
	Email string `json:"email"`
}

func (PasswordReset) BuildCognitoRequest

func (p PasswordReset) BuildCognitoRequest(clientSecret, clientID string) *cognitoidentityprovider.ForgotPasswordInput

func (*PasswordReset) Validate

func (p *PasswordReset) Validate(ctx context.Context) error

type RefreshToken

type RefreshToken struct {
	TokenString string
}

RefreshToken represents a token used for session refresh.

func (*RefreshToken) BuildSuccessfulJSONResponse

func (t *RefreshToken) BuildSuccessfulJSONResponse(ctx context.Context, result *cognitoidentityprovider.InitiateAuthOutput) ([]byte, error)

BuildSuccessfulJSONResponse creates a JSON response containing the expiration time from the Cognito auth result.

func (*RefreshToken) GenerateRefreshRequest

func (t *RefreshToken) GenerateRefreshRequest(clientSecret, username, clientID string) *cognitoidentityprovider.InitiateAuthInput

GenerateRefreshRequest produces a Cognito InitiateAuthInput struct for refreshing a users current session

func (*RefreshToken) Validate

func (t *RefreshToken) Validate(ctx context.Context) *Error

Validate validates the existence of a JWT string

type SuccessResponse

type SuccessResponse struct {
	Body    []byte            `json:"-"`
	Status  int               `json:"-"`
	Headers map[string]string `json:"-"`
}

func NewSuccessResponse

func NewSuccessResponse(jsonBody []byte, statusCode int, headers map[string]string) *SuccessResponse

type UserParams

type UserParams struct {
	Forename    string   `json:"forename"`
	Lastname    string   `json:"lastname"`
	Email       string   `json:"email"`
	Password    string   `json:"-"`
	Groups      []string `json:"groups"`
	Status      string   `json:"status"`
	Active      bool     `json:"active"`
	ID          string   `json:"id"`
	StatusNotes string   `json:"status_notes"`
}

UserParams Model for the User

func (UserParams) BuildAdminGetUserRequest

func (p UserParams) BuildAdminGetUserRequest(userPoolID string) *cognitoidentityprovider.AdminGetUserInput

BuildAdminGetUserRequest generates a AdminGetUserInput for Cognito

func (UserParams) BuildCreateUserRequest

func (p UserParams) BuildCreateUserRequest(userID, userPoolID string) *cognitoidentityprovider.AdminCreateUserInput

BuildCreateUserRequest generates a AdminCreateUserInput for Cognito

func (UserParams) BuildDisableUserRequest

func (p UserParams) BuildDisableUserRequest(userPoolID string) *cognitoidentityprovider.AdminDisableUserInput

BuildDisableUserRequest generates a AdminDisableUserInput for Cognito

func (UserParams) BuildEnableUserRequest

func (p UserParams) BuildEnableUserRequest(userPoolID string) *cognitoidentityprovider.AdminEnableUserInput

BuildEnableUserRequest generates a AdminEnableUserInput for Cognito

func (UserParams) BuildListUserGroupsRequest

func (p UserParams) BuildListUserGroupsRequest(userPoolID, nextToken string) *cognitoidentityprovider.AdminListGroupsForUserInput

BuildListUserGroupsRequest build the required input for cognito query to obtain the groups for given user

func (UserParams) BuildSuccessfulJSONResponse

func (p UserParams) BuildSuccessfulJSONResponse(ctx context.Context) ([]byte, error)

BuildSuccessfulJSONResponse builds the UserParams response json for client responses

func (UserParams) BuildUpdateUserRequest

func (p UserParams) BuildUpdateUserRequest(userPoolID string) *cognitoidentityprovider.AdminUpdateUserAttributesInput

BuildUpdateUserRequest generates a AdminUpdateUserAttributesInput for Cognito

func (UserParams) CheckForDuplicateEmail

func (p UserParams) CheckForDuplicateEmail(ctx context.Context, listUserResp *cognitoidentityprovider.ListUsersOutput) error

CheckForDuplicateEmail checks the Cognito response for users already using the email address, returning a validation error if found

func (*UserParams) GeneratePassword

func (p *UserParams) GeneratePassword(ctx context.Context) error

GeneratePassword creates a password for the user and assigns it to the struct

func (UserParams) MapCognitoDetails

func (p UserParams) MapCognitoDetails(userDetails *cognitoidentityprovider.UserType) UserParams

MapCognitoDetails maps the details from the Cognito ListUser User model to the UserParams model

func (*UserParams) MapCognitoGetResponse

func (p *UserParams) MapCognitoGetResponse(userDetails *cognitoidentityprovider.AdminGetUserOutput)

MapCognitoGetResponse maps the details from the Cognito GetUser User model to the UserParams model

func (UserParams) ValidateRegistration

func (p UserParams) ValidateRegistration(ctx context.Context, allowedDomains []string) []error

ValidateRegistration validates the required fields for user creation, returning validation errors for any failures

func (UserParams) ValidateUpdate

func (p UserParams) ValidateUpdate(ctx context.Context) []error

ValidateUpdate validates the required fields for user update, returning validation errors for any failures

type UserSignIn

type UserSignIn struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

func (*UserSignIn) BuildCognitoRequest

func (p *UserSignIn) BuildCognitoRequest(clientID, clientSecret, clientAuthFlow string) *cognitoidentityprovider.InitiateAuthInput

BuildCognitoRequest generates a InitiateAuthInput for Cognito

func (*UserSignIn) BuildSuccessfulJSONResponse

func (p *UserSignIn) BuildSuccessfulJSONResponse(ctx context.Context, result *cognitoidentityprovider.InitiateAuthOutput, refreshTokenTTL int) ([]byte, error)

BuildSuccessfulJSONResponse builds the UserSignIn response json for client responses

func (*UserSignIn) ValidateCredentials

func (p *UserSignIn) ValidateCredentials(ctx context.Context) *[]error

ValidateCredentials validates the required fields have been submitted and meet the basic structure requirements

type UsersList

type UsersList struct {
	Count           int          `json:"count"`
	Users           []UserParams `json:"users"`
	PaginationToken string
}

func (UsersList) BuildListUserRequest

func (p UsersList) BuildListUserRequest(filterString, requiredAttribute string, limit int64, paginationToken, userPoolID *string) *cognitoidentityprovider.ListUsersInput

BuildListUserRequest generates a ListUsersInput object for Cognito

func (*UsersList) BuildSuccessfulJSONResponse

func (p *UsersList) BuildSuccessfulJSONResponse(ctx context.Context) ([]byte, error)

BuildSuccessfulJSONResponse builds the UsersList response json for client responses

func (*UsersList) MapCognitoUsers

func (p *UsersList) MapCognitoUsers(cognitoResults *[]*cognitoidentityprovider.UserType)

MapCognitoUsers maps the users from the cognito response into the UsersList Users attribute and sets the Count attribute

func (*UsersList) SetUsers

func (p *UsersList) SetUsers(usersList *[]UserParams)

SetUsers sets the UsersList Users attribute and sets the Count attribute

Jump to

Keyboard shortcuts

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