Documentation
¶
Index ¶
- Variables
- func DeleteApplication(serv *server.Server, clientId string) error
- func GetApplication(serv *server.Server, clientId string, withCredentials bool) (*applicationModel.Application, error)
- func ListApplication(serv *server.Server, limit int, withCredentials bool) ([]*applicationModel.Application, error)
- func NewApplication(serv *server.Server, name string, isPublic bool, ...) (string, error)
- func UpdateApplication(serv *server.Server, clientId string, patch *applicationModel.Application) error
Constants ¶
This section is empty.
Variables ¶
var ErrAppDoesNotExist = credstackError.NewError(404, "APP_DOES_NOT_EXIST", "application: Application does not exist under the specified client ID")
ErrAppDoesNotExist - Provides a named error for when you try and fetch an application that does not exist
var ErrAppMissingIdentifier = credstackError.NewError(400, "APP_MISSING_ID", "application: Application is missing a Client ID")
ErrAppMissingIdentifier - Provides a named error for when you try and fetch an application with no client id
var ErrClientIDCollision = credstackError.NewError(500, "APP_CLIENT_ID_COLLISION", "application: A collision was detected while creating a new application")
ErrClientIDCollision - Provides a named error for when a new application is created with the same client ID
var ErrInvalidClientCredentials = credstackError.NewError(401, "ERR_INVALID_CLIENT_CREDENTIALS", "token: Unable to issue token. Invalid client credentials were supplied")
ErrInvalidClientCredentials - An error that gets returned when the client credentials sent in a token request do not match what was received from the database (during client credentials flow)
var ErrVisibilityIssue = credstackError.NewError(400, "ERR_VISIBILITY_ERROR", "token: Failed to issue token for application. Public clients cannot use client credentials flow")
ErrVisibilityIssue - An error that gets returned when the caller tries to issue a token for a public application
Functions ¶
func DeleteApplication ¶
DeleteApplication - Completely removes an application from CredStack. A valid client ID must be passed in this parameter, or it will return ErrAppMissingIdentifier. If the deleted count returned is equal to zero, then the function considers the user to not exist. A successful call to this function will return nil
func GetApplication ¶
func GetApplication(serv *server.Server, clientId string, withCredentials bool) (*applicationModel.Application, error)
GetApplication - Fetches an application from the database and returns is protobuf model. If you are fetching an app without its credentials, then set withCredentials to false. Projection is used on this to prevent the credentials from even leaving the database. If the app does not exist under the client_id, then ErrAppDoesNotExist is returned. If you try and fetch an application with an empty client_id, then ErrAppMissingIdentifier is returned.
func ListApplication ¶
func ListApplication(serv *server.Server, limit int, withCredentials bool) ([]*applicationModel.Application, error)
ListApplication - Lists all applications present in the database. Optionally, a limit can be specified here to limit the amount of data returned at once. The maximum that can be returned in a single call is 10, and if a limit exceeds this, it will be reset to 10
func NewApplication ¶
func NewApplication(serv *server.Server, name string, isPublic bool, grantTypes ...applicationModel.GrantTypes) (string, error)
NewApplication - Creates a new application with the provided grant types in the parameter. If an empty slice is provided here, then the Authorization Code grant type is appended to the slice as we always want a way to authenticate users. This is the preferred authentication method as well, as we don't need to directly touch secrets (aside from the auth code) to be able to authenticate the user.
A single database call is consumed here to be able to insert the data into Mongo. If the same client ID is generated as an existing application, then the error: ErrClientIDCollision is returned. Additionally, we wrap any errors that are encountered here and returned.
func UpdateApplication ¶
func UpdateApplication(serv *server.Server, clientId string, patch *applicationModel.Application) error
UpdateApplication - Provides functionality for updating a select number of fields of the app model. A valid client id must be provided as an argument for this function call. Fields to update can be passed in the patch parameter. The following fields can be updated: RedirectURI, TokenLifetime, GrantType.
Types ¶
This section is empty.