handlers

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AccessTokenCookie is the name of the access token cookie.
	AccessTokenCookie = "_a_token_"
	// RefreshTokenCookie is the name of the refresh token cookie.
	RefreshTokenCookie = "_r_token_"
)

Variables

This section is empty.

Functions

func GetParamAsInt

func GetParamAsInt(name string, c echo.Context) (int, error)

GetParamAsInt returns a number for an echo context parameter and checks its existance.

Types

type APIKeysHandler

type APIKeysHandler struct {
	APIKeysHandlerDependencies
}

APIKeysHandler is a handler taking care of api keys related api calls.

func NewAPIKeysHandler

func NewAPIKeysHandler(deps APIKeysHandlerDependencies) *APIKeysHandler

NewAPIKeysHandler creates a new api key pair handler.

func (*APIKeysHandler) Create

func (a *APIKeysHandler) Create() echo.HandlerFunc

Create creates an api key pair for a given user. swagger:operation POST /user/apikey/generate/{name} createApiKey Creates an api key pair for a given user. --- produces: - application/json parameters:

  • name: name in: path required: true description: "the name of the key" type: string

responses:

'200':
  description: 'the generated api key pair'
  schema:
    "$ref": "#/definitions/APIKey"
'400':
  description: 'failed to generate unique key or value'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'when failed to get user context'
  schema:
    "$ref": "#/responses/Message"

func (*APIKeysHandler) Delete

func (a *APIKeysHandler) Delete() echo.HandlerFunc

Delete deletes a set of api keys for a given user with a given id. swagger:operation DELETE /user/apikey/delete/{keyid} deleteApiKey Deletes a set of api keys for a given user with a given id. --- parameters:

  • name: keyid in: path description: 'The ID of the key to delete' required: true type: integer format: int

responses:

'200':
  description: 'OK in case the deletion was successful'
'400':
  description: 'in case of missing user context or invalid ID'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'when the deletion operation failed'
  schema:
    "$ref": "#/responses/Message"

func (*APIKeysHandler) Get

func (a *APIKeysHandler) Get() echo.HandlerFunc

Get returns a given api key. swagger:operation GET /user/apikey/{keyid} getApiKeys Returns a given api key. --- produces: - application/json parameters:

  • name: keyid in: path description: "The ID of the key to return" required: true type: integer format: int

responses:

'200':
  schema:
    "$ref": "#/definitions/APIKey"
'500':
  description: 'failed to get user context'
  schema:
    "$ref": "#/responses/Message"

func (*APIKeysHandler) List

func (a *APIKeysHandler) List() echo.HandlerFunc

List lists all api keys for a given user. swagger:operation POST /user/apikey listApiKeys Lists all api keys for a given user. --- produces: - application/json responses:

'200':
  schema:
    type: array
    items:
      "$ref": "#/definitions/APIKey"
'500':
  description: 'failed to get user context'
  schema:
    "$ref": "#/responses/Message"

type APIKeysHandlerDependencies

type APIKeysHandlerDependencies struct {
	Dependencies
	APIKeysStore  providers.APIKeysStorer
	TokenProvider *TokenHandler
	Clock         providers.Clock
}

APIKeysHandlerDependencies defines the dependencies for the api keys handler provider.

type CommandRunHandler

type CommandRunHandler struct {
	CommandRunHandlerDependencies
}

CommandRunHandler is a handler taking care of commands related api calls.

func NewCommandRunHandler

func NewCommandRunHandler(deps CommandRunHandlerDependencies) *CommandRunHandler

NewCommandRunHandler creates a new command run handler.

func (*CommandRunHandler) GetCommandRun

func (cm *CommandRunHandler) GetCommandRun() echo.HandlerFunc

GetCommandRun returns details about a command run. swagger:operation GET /command/run/{id} getCommandRun Returns details about a command run. --- produces: - application/json parameters:

  • name: id in: path type: integer format: int required: true

responses:

'200':
  schema:
    "$ref": "#/definitions/CommandRun"
'400':
  description: 'invalid command id'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'command run not found'
'500':
  description: 'failed to get command run'
  schema:
    "$ref": "#/responses/Message"

type CommandRunHandlerDependencies

type CommandRunHandlerDependencies struct {
	Logger           zerolog.Logger
	CommandRunStorer providers.CommandRunStorer
}

CommandRunHandlerDependencies defines the dependencies for the commands handler provider.

type CommandSettingsHandler

type CommandSettingsHandler struct {
	CommandSettingsHandlerDependencies
}

CommandSettingsHandler is a handler taking care of command settings related api calls.

func NewCommandSettingsHandler

func NewCommandSettingsHandler(deps CommandSettingsHandlerDependencies) *CommandSettingsHandler

NewCommandSettingsHandler creates a new command settings handler.

func (*CommandSettingsHandler) Create

func (ch *CommandSettingsHandler) Create() echo.HandlerFunc

Create creates a command setting. swagger:operation POST /command/settings/update updateCommandSetting Create a new command setting. --- produces: - application/json parameters:

  • name: setting in: body required: true schema: "$ref": "#/definitions/CommandSetting"

responses:

'200':
  description: 'successfully created command setting'
'400':
  description: 'binding error'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to create the command setting'
  schema:
    "$ref": "#/responses/Message"

func (*CommandSettingsHandler) Delete

func (ch *CommandSettingsHandler) Delete() echo.HandlerFunc

Delete deletes a setting. swagger:operation DELETE /command/settings/{id} deleteCommandSetting Deletes a given command setting. --- parameters:

  • name: id in: path description: 'The ID of the command setting to delete' required: true type: integer format: int

responses:

'200':
  description: 'OK in case the deletion was successful'
'400':
  description: 'invalid id'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'command setting not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'when the deletion operation failed'
  schema:
    "$ref": "#/responses/Message"

func (*CommandSettingsHandler) Get

func (ch *CommandSettingsHandler) Get() echo.HandlerFunc

Get returns a specific setting. swagger:operation GET /command/settings/{id} getCommandSetting Get a specific setting. --- produces: - application/json parameters:

  • name: id in: path description: 'The ID of the command setting to retrieve' required: true type: integer format: int

responses:

'200':
  schema:
    "$ref": "#/definitions/CommandSetting"
'400':
  description: 'invalid command id'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'command setting not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to get command setting'
  schema:
    "$ref": "#/responses/Message"

func (*CommandSettingsHandler) List

func (ch *CommandSettingsHandler) List() echo.HandlerFunc

List lists command settings. swagger:operation POST /command/{id}/settings listCommandSettings List settings for a command. --- produces: - application/json parameters:

  • name: id in: path description: 'The ID of the command to list settings for' required: true type: integer format: int

responses:

'200':
  schema:
    type: array
    items:
      "$ref": "#/definitions/CommandSetting"
'400':
  description: 'invalid id'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to list settings'
  schema:
    "$ref": "#/responses/Message"

func (*CommandSettingsHandler) Update

func (ch *CommandSettingsHandler) Update() echo.HandlerFunc

Update updates a setting. swagger:operation POST /command/settings/update updateCommandSetting Updates a given command setting. --- produces: - application/json parameters:

  • name: setting in: body required: true schema: "$ref": "#/definitions/CommandSetting"

responses:

'200':
  description: 'successfully updated command setting'
'400':
  description: 'binding error'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to update the command setting'
  schema:
    "$ref": "#/responses/Message"

type CommandSettingsHandlerDependencies

type CommandSettingsHandlerDependencies struct {
	Logger        zerolog.Logger
	CommandStorer providers.CommandStorer
}

CommandSettingsHandlerDependencies defines the dependencies for the command settings handler provider.

type CommandsHandler

type CommandsHandler struct {
	CommandsHandlerDependencies
}

CommandsHandler is a handler taking care of commands related api calls.

func NewCommandsHandler

func NewCommandsHandler(deps CommandsHandlerDependencies) *CommandsHandler

NewCommandsHandler creates a new commands handler.

func (*CommandsHandler) AddCommandRelForPlatform

func (ch *CommandsHandler) AddCommandRelForPlatform() echo.HandlerFunc

AddCommandRelForPlatform adds a command relationship to a platform. swagger:operation POST /command/add-command-rel-for-platform/{cmdid}/{repoid} addCommandRelForPlatformCommand Adds a connection to a platform for a command. Defines what platform a command supports. These commands will only be able to run for those platforms. --- parameters:

  • name: cmdid in: path required: true type: integer format: int
  • name: repoid in: path required: true type: integer format: int

responses:

'200':
  description: 'successfully added relationship'
'400':
  description: 'invalid ids or platform not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to add command relationship to platform'
  schema:
    "$ref": "#/responses/Message"

func (*CommandsHandler) AddCommandRelForRepository

func (ch *CommandsHandler) AddCommandRelForRepository() echo.HandlerFunc

AddCommandRelForRepository adds a command relationship to a repository. swagger:operation POST /command/add-command-rel-for-repository/{cmdid}/{repoid} addCommandRelForRepositoryCommand Add a connection to a repository. This will make this command to be executed for events for that repository. --- parameters:

  • name: cmdid in: path required: true type: integer format: int
  • name: repoid in: path required: true type: integer format: int

responses:

'200':
  description: 'successfully added relationship'
'400':
  description: 'invalid ids or repositroy not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to add relationship'
  schema:
    "$ref": "#/responses/Message"

func (*CommandsHandler) Delete

func (ch *CommandsHandler) Delete() echo.HandlerFunc

Delete deletes a command. swagger:operation DELETE /command/{id} deleteCommand Deletes given command. --- parameters:

  • name: id in: path description: 'The ID of the command to delete' required: true type: integer format: int

responses:

'200':
  description: 'OK in case the deletion was successful'
'400':
  description: 'in case of missing user context or invalid ID'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'when the deletion operation failed'
  schema:
    "$ref": "#/responses/Message"

func (*CommandsHandler) Get

func (ch *CommandsHandler) Get() echo.HandlerFunc

Get returns a specific command. swagger:operation GET /command/{id} getCommand Returns a specific command. --- produces: - application/json parameters:

  • name: id in: path type: integer format: int required: true

responses:

'200':
  schema:
    "$ref": "#/definitions/Command"
'400':
  description: 'invalid command id'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to get user context'
  schema:
    "$ref": "#/responses/Message"

func (*CommandsHandler) List

func (ch *CommandsHandler) List() echo.HandlerFunc

List lists commands. swagger:operation POST /commands listCommands List commands --- produces: - application/json parameters:

  • name: listOptions in: body required: false schema: "$ref": "#/definitions/ListOptions"

responses:

'200':
  schema:
    type: array
    items:
      "$ref": "#/definitions/Command"
'500':
  description: 'failed to get user context'
  schema:
    "$ref": "#/responses/Message"

func (*CommandsHandler) RemoveCommandRelForPlatform

func (ch *CommandsHandler) RemoveCommandRelForPlatform() echo.HandlerFunc

RemoveCommandRelForPlatform removes a relationship of a command from a platform. swagger:operation POST /command/remove-command-rel-for-platform/{cmdid}/{repoid} removeCommandRelForPlatformCommand Remove a relationship to a platform. This command will no longer be running for that platform events. --- parameters:

  • name: cmdid in: path required: true type: integer format: int
  • name: repoid in: path required: true type: integer format: int

responses:

'200':
  description: 'successfully removed relationship'
'400':
  description: 'invalid ids or platform not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to add relationship'
  schema:
    "$ref": "#/responses/Message"

func (*CommandsHandler) RemoveCommandRelForRepository

func (ch *CommandsHandler) RemoveCommandRelForRepository() echo.HandlerFunc

RemoveCommandRelForRepository removes a relationship of a command from a repository. swagger:operation POST /command/remove-command-rel-for-repository/{cmdid}/{repoid} removeCommandRelForRepositoryCommand Remove a relationship to a repository. This command will no longer be running for that repository events. --- parameters:

  • name: cmdid in: path required: true type: integer format: int
  • name: repoid in: path required: true type: integer format: int

responses:

'200':
  description: 'successfully removed relationship'
'400':
  description: 'invalid ids or repositroy not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to add relationship'
  schema:
    "$ref": "#/responses/Message"

func (*CommandsHandler) Update

func (ch *CommandsHandler) Update() echo.HandlerFunc

Update updates a command. swagger:operation POST /command/update updateCommand Updates a given command. --- produces: - application/json consumes: - application/json parameters:

  • name: command in: body required: true schema: "$ref": "#/definitions/Command"

responses:

'200':
  description: 'successfully updated command'
  schema:
    "$ref": "#/definitions/Command"
'400':
  description: 'binding error'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to update the command'
  schema:
    "$ref": "#/responses/Message"

func (*CommandsHandler) Upload

func (ch *CommandsHandler) Upload() echo.HandlerFunc

Upload a command. To set up anything for the command, like schedules etc, the command has to be edited. We don't support uploading the same thing twice. If the command binary needs to be updated, delete the command and upload the new binary. swagger:operation POST /command uploadCommand Upload a command. To set up anything for the command, like schedules etc, the command has to be edited. We don't support uploading the same thing twice. If the command binary needs to be updated, delete the command and upload the new binary. --- produces: - application/json responses:

'201':
  description: 'in case of successful file upload'
  schema:
    "$ref": "#/definitions/Command"
'400':
  description: 'invalid file format or command already exists'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to upload file, create plugin, create command or copy operations'
  schema:
    "$ref": "#/responses/Message"

type CommandsHandlerDependencies

type CommandsHandlerDependencies struct {
	Logger        zerolog.Logger
	CommandStorer providers.CommandStorer
	Plugins       providers.Plugins
}

CommandsHandlerDependencies defines the dependencies for the commands handler provider.

type Config

type Config struct {
	Proto              string
	Hostname           string
	GlobalTokenKey     string
	GoogleClientID     string
	GoogleClientSecret string
}

Config has the configuration options for the repository handler.

type Dependencies

type Dependencies struct {
	Logger      zerolog.Logger
	UserStore   providers.UserStorer
	APIKeyAuth  providers.APIKeysAuthenticator
	TokenIssuer providers.TokenIssuer
}

Dependencies defines the dependencies for the repository handler provider.

type EventHandler

type EventHandler struct {
	EventHandlerDependencies
}

EventHandler is a handler taking care of vcs token related api calls.

func NewEventHandler

func NewEventHandler(deps EventHandlerDependencies) *EventHandler

NewEventHandler creates a new event handler.

func (*EventHandler) Get

func (r *EventHandler) Get() echo.HandlerFunc

Get a specific event. swagger:operation GET /event/{id} getEvent Get a specific event. --- produces: - application/json parameters:

  • name: id in: path description: 'The ID of the event to retrieve' required: true type: integer format: int

responses:

'200':
  schema:
    "$ref": "#/definitions/Event"
'400':
  description: 'invalid event id'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'event not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to get event'
  schema:
    "$ref": "#/responses/Message"

func (*EventHandler) List

func (r *EventHandler) List() echo.HandlerFunc

List handles the list rest event. swagger:operation POST /events/{repoid} listEvents List events for a repository. --- produces: - application/json parameters:

  • name: repoid in: path description: 'The ID of the repository to list events for.' required: true type: integer format: int

responses:

'200':
  schema:
    type: array
    items:
      "$ref": "#/definitions/Event"
'400':
  description: 'invalid repository id'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to list events'
  schema:
    "$ref": "#/responses/Message"

type EventHandlerDependencies

type EventHandlerDependencies struct {
	Logger       zerolog.Logger
	EventsStorer providers.EventsStorer
}

EventHandlerDependencies defines the dependencies for the vcs token handler provider.

type HookDependencies

type HookDependencies struct {
	// Load all the hook providers here and decide to which to delegate to.
	Logger            zerolog.Logger
	RepositoryStore   providers.RepositoryStorer
	PlatformProviders map[int]providers.Platform
	Executer          providers.Executor
	EventsStorer      providers.EventsStorer
	Timer             providers.Clock
}

HookDependencies defines the dependencies of this server.

type KrokHookHandler

type KrokHookHandler struct {
	HookDependencies
}

KrokHookHandler is the main hook handler.

func NewHookHandler

func NewHookHandler(deps HookDependencies) *KrokHookHandler

NewHookHandler creates a new Krok server to listen for all hook related events.

func (*KrokHookHandler) HandleHooks

func (k *KrokHookHandler) HandleHooks() echo.HandlerFunc

HandleHooks creates a hook handler. swagger:operation POST /hooks/{rid}/{vid}/callback hookHandler Handle the hooks created by the platform. --- produces: - application/json parameters:

  • name: rid in: path description: The ID of the repository. required: true type: integer format: int
  • name: vid in: path description: The ID of the provider. required: true type: integer format: int

responses:

'200':
  description: 'success in case the hook event was processed without problems'
'400':
  description: 'for invalid parameters'
'404':
  description: 'if the repository or the provider does not exist'

type RepoConfig

type RepoConfig struct {
	Protocol string
	HookBase string
}

RepoConfig represents configuration entities that the repository requires.

type RepoHandler

type RepoHandler struct {
	RepoConfig
	RepoHandlerDependencies
}

RepoHandler is a handler taking care of repository related api calls.

func NewRepositoryHandler

func NewRepositoryHandler(cfg RepoConfig, deps RepoHandlerDependencies) (*RepoHandler, error)

NewRepositoryHandler creates a new repository handler.

func (*RepoHandler) Create

func (r *RepoHandler) Create() echo.HandlerFunc

Create handles the Create rest event. swagger:operation POST /repository createRepository Creates a new repository --- produces: - application/json consumes: - application/json parameters:

  • name: repository in: body required: true schema: "$ref": "#/definitions/Repository"

responses:

'200':
  description: 'the created repository'
  schema:
    "$ref": "#/definitions/Repository"
'400':
  description: 'failed to generate unique key or value'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'when failed to get user context'
  schema:
    "$ref": "#/responses/Message"

func (*RepoHandler) Delete

func (r *RepoHandler) Delete() echo.HandlerFunc

Delete handles the Delete rest event. TODO: Delete the hook here as well? swagger:operation DELETE /repository/{id} deleteRepository Deletes the given repository. --- parameters:

  • name: id in: path description: 'The ID of the repository to delete' required: true type: integer format: int

responses:

'200':
  description: 'OK in case the deletion was successful'
'400':
  description: 'in case of missing user context or invalid ID'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'in case of repository not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'when the deletion operation failed'
  schema:
    "$ref": "#/responses/Message"

func (*RepoHandler) Get

func (r *RepoHandler) Get() echo.HandlerFunc

Get retrieves a repository and displays the unique URL for which this repo is responsible for. swagger:operation GET /repository/{id} getRepository Gets the repository with the corresponding ID. --- produces: - application/json parameters:

  • name: id in: path type: integer format: int required: true

responses:

'200':
  schema:
    "$ref": "#/definitions/Repository"
'400':
  description: 'invalid repository id'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'repository not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to get repository'
  schema:
    "$ref": "#/responses/Message"

func (*RepoHandler) List

func (r *RepoHandler) List() echo.HandlerFunc

List handles the List rest event. swagger:operation POST /repositories listRepositories List repositories --- produces: - application/json consumes: - application/json parameters:

  • name: listOptions in: body required: false schema: "$ref": "#/definitions/ListOptions"

responses:

'200':
  schema:
    type: array
    items:
      "$ref": "#/definitions/Repository"
'500':
  description: 'failed to list repositories'
  schema:
    "$ref": "#/responses/Message"

func (*RepoHandler) Update

func (r *RepoHandler) Update() echo.HandlerFunc

Update handles the update rest event. swagger:operation POST /repository/update updateRepository Updates an existing repository. --- produces: - application/json consumes: - application/json parameters:

  • name: repository in: body required: true schema: "$ref": "#/definitions/Repository"

responses:

'200':
  description: 'the updated repository'
  schema:
    "$ref": "#/definitions/Repository"
'400':
  description: 'failed to bind repository'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'repository not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to update repository'
  schema:
    "$ref": "#/responses/Message"

type RepoHandlerDependencies

type RepoHandlerDependencies struct {
	Auth              providers.RepositoryAuth
	RepositoryStorer  providers.RepositoryStorer
	Logger            zerolog.Logger
	PlatformProviders map[int]providers.Platform
}

RepoHandlerDependencies defines the dependencies for the repository handler provider.

type SupportedPlatformList

type SupportedPlatformList struct{}

SupportedPlatformList is the supporting struct which implements platform listing.

func NewSupportedPlatformListHandler

func NewSupportedPlatformListHandler() *SupportedPlatformList

NewSupportedPlatformListHandler creates a new supported platform list handler.

func (*SupportedPlatformList) ListSupportedPlatforms

func (s *SupportedPlatformList) ListSupportedPlatforms() echo.HandlerFunc

ListSupportedPlatforms lists all platforms which Krok supports. swagger:operation GET /supported-platforms listSupportedPlatforms Lists all supported platforms. --- produces: - application/json responses:

'200':
  description: 'the list of supported platform ids'
  schema:
    type: array
    items:
      "$ref": "#/definitions/Platform"

type TokenHandler

type TokenHandler struct {
	Dependencies
}

TokenHandler is a token provider for the handlers.

func NewTokenHandler

func NewTokenHandler(deps Dependencies) (*TokenHandler, error)

NewTokenHandler creates a new token handler which deals with generating and handling tokens.

func (*TokenHandler) TokenHandler

func (p *TokenHandler) TokenHandler() echo.HandlerFunc

TokenHandler creates a JWT token for a given api key pair. swagger:operation POST /get-token getToken Creates a JWT token for a given api key pair. --- deprecated: true produces: - application/json responses:

'200':
  description: 'the generated JWT token'
  schema:
    "$ref": "#/responses/TokenResponse"
'500':
  description: 'when there was a problem with matching the email, or the api key or generating the token'

type UserAuthHandler

type UserAuthHandler struct {
	UserAuthHandlerDeps
}

UserAuthHandler handles user authentication.

func NewUserAuthHandler

func NewUserAuthHandler(deps UserAuthHandlerDeps) *UserAuthHandler

NewUserAuthHandler creates a new UserAuthHandler.

func (*UserAuthHandler) OAuthCallback

func (h *UserAuthHandler) OAuthCallback() echo.HandlerFunc

OAuthCallback handles the user login callback. swagger:operation GET /auth/callback userCallback

This is the url to which Google calls back after a successful login. Creates a cookie which will hold the authenticated user. --- parameters:

  • name: state in: query description: the state variable defined by Google required: true type: string
  • name: code in: query description: the authorization code provided by Google required: true type: string

responses:

'308':
  description: 'the permanent redirect url'
'404':
  description: 'error invalid state|code'
'401':
  description: 'error verifying state | error during token exchange'

func (*UserAuthHandler) OAuthLogin

func (h *UserAuthHandler) OAuthLogin() echo.HandlerFunc

OAuthLogin handles a user login. swagger:operation GET /auth/login userLogin

User login. --- parameters:

  • name: redirect_url in: query description: the redirect URL coming from Google to redirect login to required: true type: string

responses:

'307':
  description: 'the redirect url to the login'
'404':
  description: 'error invalid redirect_url'
'401':
  description: 'error generating state'

func (*UserAuthHandler) Refresh

func (h *UserAuthHandler) Refresh() echo.HandlerFunc

Refresh handles user token refreshing. swagger:operation POST /auth/refresh refreshToken

Refresh the authentication token.

--- responses:

'200':
   description: 'Status OK'
'401':
   description: 'refresh token cookie not found|error refreshing token'

type UserAuthHandlerDeps

type UserAuthHandlerDeps struct {
	Logger      zerolog.Logger
	OAuth       providers.OAuthAuthenticator
	TokenIssuer providers.TokenIssuer
}

UserAuthHandlerDeps contains the UserAuthHandler dependencies.

type UserHandler

type UserHandler struct {
	UserHandlerDependencies
}

UserHandler .

func NewUserHandler

func NewUserHandler(deps UserHandlerDependencies) *UserHandler

NewUserHandler .

func (*UserHandler) CreateUser

func (u *UserHandler) CreateUser() echo.HandlerFunc

CreateUser creates a new user. swagger:operation POST /user createUser Creates a new user --- produces: - application/json consumes: - application/json parameters:

  • name: user in: body required: true schema: "$ref": "#/definitions/User"

responses:

'200':
  description: 'the created user'
  schema:
    "$ref": "#/definitions/User"
'400':
  description: 'invalid json payload'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to create user or generating a new api key'
  schema:
    "$ref": "#/responses/Message"

func (*UserHandler) DeleteUser

func (u *UserHandler) DeleteUser() echo.HandlerFunc

DeleteUser deletes a user. swagger:operation DELETE /user/{id} deleteUser Deletes the given user. --- parameters:

  • name: id in: path description: 'The ID of the user to delete' required: true type: integer format: int

responses:

'200':
  description: 'OK in case the deletion was successful'
'400':
  description: 'in case of missing user context or invalid ID'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'in case of user not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'when the deletion operation failed'
  schema:
    "$ref": "#/responses/Message"

func (*UserHandler) GetUser

func (u *UserHandler) GetUser() echo.HandlerFunc

GetUser returns a user. swagger:operation GET /user/{id} getUser Gets the user with the corresponding ID. --- produces: - application/json parameters:

  • name: id in: path type: integer format: int required: true

responses:

'200':
  schema:
    "$ref": "#/definitions/User"
'400':
  description: 'invalid user id'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'user not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to get user'
  schema:
    "$ref": "#/responses/Message"

func (*UserHandler) ListUsers

func (u *UserHandler) ListUsers() echo.HandlerFunc

ListUsers lists all users. swagger:operation POST /users listUsers List users --- produces: - application/json responses:

'200':
  schema:
    type: array
    items:
      "$ref": "#/definitions/User"
'500':
  description: 'failed to list user'
  schema:
    "$ref": "#/responses/Message"

func (*UserHandler) UpdateUser

func (u *UserHandler) UpdateUser() echo.HandlerFunc

UpdateUser update a specific user. swagger:operation POST /user/update updateUser Updates an existing user. --- produces: - application/json consumes: - application/json parameters:

  • name: user in: body required: true schema: "$ref": "#/definitions/User"

responses:

'200':
  description: 'user successfully updated'
  schema:
    "$ref": "#/definitions/User"
'400':
  description: 'invalid json payload'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'user not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to update user'
  schema:
    "$ref": "#/responses/Message"

type UserHandlerDependencies

type UserHandlerDependencies struct {
	Logger     zerolog.Logger
	UserStore  providers.UserStorer
	APIKeyAuth providers.APIKeysAuthenticator
}

UserHandlerDependencies .

type VCSTokenHandler

type VCSTokenHandler struct {
	VCSTokenHandlerDependencies
}

VCSTokenHandler is a handler taking care of vcs token related api calls.

func NewVCSTokenHandler

func NewVCSTokenHandler(deps VCSTokenHandlerDependencies) *VCSTokenHandler

NewVCSTokenHandler creates a new vcs token handler.

func (*VCSTokenHandler) Create

func (r *VCSTokenHandler) Create() echo.HandlerFunc

Create handles the Create rest event. swagger:operation POST /vcs-token createVcsToken Create a new token for a platform like Github, Gitlab, Gitea... --- consumes: - application/json parameters:

  • name: secret in: body required: true schema: "$ref": "#/definitions/VCSToken"

responses:

'200':
  description: 'OK setting successfully create'
'400':
  description: 'invalid json payload'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to create secret'
  schema:
    "$ref": "#/responses/Message"

type VCSTokenHandlerDependencies

type VCSTokenHandlerDependencies struct {
	Logger        zerolog.Logger
	TokenProvider providers.PlatformTokenProvider
}

VCSTokenHandlerDependencies defines the dependencies for the vcs token handler provider.

type VaultHandler

type VaultHandler struct {
	VaultHandlerDependencies
}

VaultHandler is a handler taking care of vault related api calls.

func NewVaultHandler

func NewVaultHandler(deps VaultHandlerDependencies) *VaultHandler

NewVaultHandler creates a new vault settings handler.

func (*VaultHandler) CreateSecret

func (v *VaultHandler) CreateSecret() echo.HandlerFunc

CreateSecret will create a new secret. swagger:operation POST /vault/secret createSecret Create a new secure secret. --- consumes: - application/json parameters:

  • name: secret in: body required: true schema: "$ref": "#/definitions/VaultSetting"

responses:

'200':
  description: 'OK setting successfully create'
'400':
  description: 'invalid json payload'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to create secret'
  schema:
    "$ref": "#/responses/Message"

func (*VaultHandler) DeleteSecret

func (v *VaultHandler) DeleteSecret() echo.HandlerFunc

DeleteSecret deletes secrets. swagger:operation DELETE /vault/secret/{name} deleteSecret Deletes the given secret. --- parameters:

  • name: name in: path description: 'The key of the secret' required: true type: string

responses:

'200':
  description: 'OK in case the deletion was successful'
'400':
  description: 'in case of missing name'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'in case the secret was not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'when the deletion operation failed'
  schema:
    "$ref": "#/responses/Message"

func (*VaultHandler) GetSecret

func (v *VaultHandler) GetSecret() echo.HandlerFunc

GetSecret will return all information including the secret. swagger:operation GET /vault/secret/{name} getSecret Get a specific secret. --- produces: - application/json parameters:

  • name: name in: path type: string required: true

responses:

'200':
  schema:
    "$ref": "#/definitions/VaultSetting"
'400':
  description: 'invalid name'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'secret not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to load secrets'
  schema:
    "$ref": "#/responses/Message"

func (*VaultHandler) ListSecrets

func (v *VaultHandler) ListSecrets() echo.HandlerFunc

ListSecrets will return all settings, but not the values. swagger:operation POST /vault/secrets listSecrets List all settings without the values. --- produces: - application/json responses:

'200':
  schema:
    type: array
    items:
      "$ref": "#/definitions/VaultSetting"
'500':
  description: 'failed to load secrets'
  schema:
    "$ref": "#/responses/Message"

func (*VaultHandler) UpdateSecret

func (v *VaultHandler) UpdateSecret() echo.HandlerFunc

UpdateSecret will update a given secret. swagger:operation POST /vault/secret/update updateSecret Updates an existing secret. --- consumes: - application/json parameters:

  • name: secret in: body required: true schema: "$ref": "#/definitions/VaultSetting"

responses:

'200':
  description: 'OK setting successfully updated'
'400':
  description: 'invalid json payload'
  schema:
    "$ref": "#/responses/Message"
'404':
  description: 'setting not found'
  schema:
    "$ref": "#/responses/Message"
'500':
  description: 'failed to update secret'
  schema:
    "$ref": "#/responses/Message"

type VaultHandlerDependencies

type VaultHandlerDependencies struct {
	Logger zerolog.Logger
	Vault  providers.Vault
}

VaultHandlerDependencies defines the dependencies for the vault settings handler provider.

Jump to

Keyboard shortcuts

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