Documentation
¶
Index ¶
- Constants
- Variables
- type API
- func (api *API) AddUserToGroup(_ context.Context, group models.Group, userID string) (*models.UsersList, error)
- func (api *API) AddUserToGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) ChangePasswordHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) CognitoPoolJWKSHandler(ctx context.Context, _ http.ResponseWriter, _ *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) CreateGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) CreateUserHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) DeleteGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) GetFilterStringAndValidate(path, queryStr string) (string, error)
- func (api *API) GetGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) GetListGroups() (*cognitoidentityprovider.ListGroupsOutput, error)
- func (api *API) GetTeamsReportLines(listOfGroups *cognitoidentityprovider.ListGroupsOutput) (*[]models.ListGroupUsersType, error)
- func (api *API) GetUserHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) ListGroupsHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) ListGroupsUsersCSV(groupsUsersList *[]models.ListGroupUsersType) *bytes.Buffer
- func (api *API) ListGroupsUsersHandler(_ context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) ListUserGroupsHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) ListUsersHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) ListUsersInGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) ListUsersWorker(ctx context.Context, userFilterString *string, backoffSchedule []time.Duration) (*[]models.UserParams, *models.ErrorResponse)
- func (api *API) PasswordResetHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) RefreshHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) RemoveUserFromGroup(_ context.Context, group models.Group, userID string) (*models.UsersList, error)
- func (api *API) RemoveUserFromGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) SetGroupUsers(ctx context.Context, group models.Group, users models.UsersList) (*models.UsersList, *models.ErrorResponse)
- func (api *API) SetGroupUsersHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) SignOutAllUsersHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) SignOutHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) SignOutUsersWorker(ctx context.Context, g *models.GlobalSignOut, usersList *[]models.UserParams)
- func (api *API) TokensHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) UpdateGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
- func (api *API) UpdateUserHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
Constants ¶
const ( GroupsCreatePermission = "groups:create" GroupsReadPermission = "groups:read" GroupsEditPermission = "groups:update" GroupsDeletePermission = "groups:delete" )
const ( UsersCreatePermission = "users:create" UsersReadPermission = "users:read" UsersUpdatePermission = "users:update" )
Variables ¶
var ( IDTokenHeaderName = "ID" AccessTokenHeaderName = "Authorization" RefreshTokenHeaderName = "Refresh" WWWAuthenticateName = "WWW-Authenticate" ONSRealm = "Florence publishing platform" Charset = "UTF-8" NewPasswordChallenge = "NEW_PASSWORD_REQUIRED" DefaultBackOffSchedule = []time.Duration{ 1 * time.Second, 3 * time.Second, 10 * time.Second, } )
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { Router *mux.Router CognitoClient cognito.Client UserPoolID string ClientID string ClientSecret string ClientAuthFlow string AWSRegion string AllowedDomains []string APIRequestFilter map[string]map[string]string JWKSManager jwks.Manager }
API provides a struct to wrap the api around
func Setup ¶
func Setup(ctx context.Context, r *mux.Router, cognitoClient cognito.Client, userPoolID, clientID, clientSecret, awsRegion, clientAuthFlow string, allowedDomains []string, auth authorisation.Middleware, jwksManager jwks.Manager) (*API, error)
Setup function sets up the api and returns an api
func (*API) AddUserToGroup ¶
func (api *API) AddUserToGroup(_ context.Context, group models.Group, userID string) (*models.UsersList, error)
AddUserToGroup adds a user to the specified group
func (*API) AddUserToGroupHandler ¶
func (api *API) AddUserToGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
AddUserToGroupHandler adds a user to the specified group
func (*API) ChangePasswordHandler ¶
func (api *API) ChangePasswordHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
ChangePasswordHandler processes changes to the users password
func (*API) CognitoPoolJWKSHandler ¶
func (api *API) CognitoPoolJWKSHandler(ctx context.Context, _ http.ResponseWriter, _ *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
CognitoPoolJWKSHandler handles the retrieval of pool specific web key set
func (*API) CreateGroupHandler ¶
func (api *API) CreateGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
CreateGroupHandler creates a new group
func (*API) CreateUserHandler ¶
func (api *API) CreateUserHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
CreateUserHandler creates a new user and returns a http handler interface
func (*API) DeleteGroupHandler ¶
func (api *API) DeleteGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
DeleteGroupHandler deletes the group for the given group id
func (*API) GetFilterStringAndValidate ¶
func (*API) GetGroupHandler ¶
func (api *API) GetGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
GetGroupHandler gets group details for given groups
func (*API) GetListGroups ¶
func (api *API) GetListGroups() (*cognitoidentityprovider.ListGroupsOutput, error)
List Groups pagination allows first call and then any other call if nextToken is not ""
func (*API) GetTeamsReportLines ¶
func (api *API) GetTeamsReportLines(listOfGroups *cognitoidentityprovider.ListGroupsOutput) (*[]models.ListGroupUsersType, error)
GetTeamsReportLines from the listOfGroups for each group gets the list of members and produces output group description user email for each group member
func (*API) GetUserHandler ¶
func (api *API) GetUserHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
GetUserHandler lists the users in the user pool
func (*API) ListGroupsHandler ¶
func (api *API) ListGroupsHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
ListGroupsHandler lists the users in the user pool
func (*API) ListGroupsUsersCSV ¶
func (api *API) ListGroupsUsersCSV(groupsUsersList *[]models.ListGroupUsersType) *bytes.Buffer
ListGroupsUsersCSV converts the groupsUsersList output to csv
func (*API) ListGroupsUsersHandler ¶
func (api *API) ListGroupsUsersHandler(_ context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
ListGroupsUsersHandler produces a user requested report of all groups with members including groups that act as roles output by default is json but if request header accept == text/csv then the output is csv format each line consists of the group description and user email
func (*API) ListUserGroupsHandler ¶
func (api *API) ListUserGroupsHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
ListUserGroupsHandler lists the users in the user pool
func (*API) ListUsersHandler ¶
func (api *API) ListUsersHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
ListUsersHandler lists the users in the user pool
func (*API) ListUsersInGroupHandler ¶
func (api *API) ListUsersInGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
ListUsersInGroupHandler list the users in the specified group
func (*API) ListUsersWorker ¶
func (api *API) ListUsersWorker(ctx context.Context, userFilterString *string, backoffSchedule []time.Duration) (*[]models.UserParams, *models.ErrorResponse)
ListUsersWorker - generates a list of users based on `userFilterString` filter string
func (*API) PasswordResetHandler ¶
func (api *API) PasswordResetHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
PasswordResetHandler requests a password reset email be sent to the user and returns a http handler interface
func (*API) RefreshHandler ¶
func (api *API) RefreshHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
RefreshHandler refreshes a users access token and returns new access and ID tokens, expiration time and the refresh token
func (*API) RemoveUserFromGroup ¶
func (api *API) RemoveUserFromGroup(_ context.Context, group models.Group, userID string) (*models.UsersList, error)
RemoveUserFromGroup adds a user to the specified group
func (*API) RemoveUserFromGroupHandler ¶
func (api *API) RemoveUserFromGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
RemoveUserFromGroupHandler adds a user to the specified group
func (*API) SetGroupUsers ¶
func (*API) SetGroupUsersHandler ¶
func (api *API) SetGroupUsersHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
/SetGroupUsersHandler adds a user to the specified group
func (*API) SignOutAllUsersHandler ¶
func (api *API) SignOutAllUsersHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
SignOutAllUsersHandler bulk refresh token invalidation for panic sign out handling
func (*API) SignOutHandler ¶
func (api *API) SignOutHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
SignOutHandler invalidates a users access token signing them out and returns a http handler interface
func (*API) SignOutUsersWorker ¶
func (api *API) SignOutUsersWorker(ctx context.Context, g *models.GlobalSignOut, usersList *[]models.UserParams)
SignOutUsersWorker - signs out users globally by invalidating user's refresh token
func (*API) TokensHandler ¶
func (api *API) TokensHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
TokensHandler uses submitted email address and password to sign a user in against Cognito and returns a http handler interface
func (*API) UpdateGroupHandler ¶
func (api *API) UpdateGroupHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
UpdateGroupHandler update group details for a given group by id (GroupName)
func (*API) UpdateUserHandler ¶
func (api *API) UpdateUserHandler(ctx context.Context, _ http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)
UpdateUserHandler updates a users details in Cognito and returns a http handler interface