controllers

package
v0.0.0-...-f2d7034 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAPIKey

func GetAPIKey(c *fiber.Ctx) error

GetAPIKey returns a page to get the initial API key @Summary Get API Key @ID getAPIKey @Description This endpoint checks if the initial password exists in Redis and if it does, renders the API key form. If the initial password does not exist or has been used, it redirects to the home page or prompts the user to restart the server. @Tags Authentication @Accept json @Produce json @Success 200 {object} Response "Renders the API key form if the initial password exists and has not been used" @Failure 500 {Object} Response "The initial password has been used. Please check the database for the API key" @Failure 500 {object} Response "Returns an error message if the initial password does not exist or there was an error getting the initial password" @Router /v1/auth/internal/apikey [get]

func GetAuthSuccess

func GetAuthSuccess(c *fiber.Ctx) error

GetAuthSuccess returns a page to show that the oauth authentication was successful @ID getAuthSuccess @Summary OAuth2 Success Page @Description This endpoint returns a success message after successful authentication. @Tags OAuth2 @Accept json @Produce json @Success 200 {object} Response "Returns a success message indicating successful authentication" @Router /v1/auth/success [get]

func GetGmailEmails

func GetGmailEmails(c *fiber.Ctx) error

GetGmailEmails returns the user's Gmail emails. @Summary Get Gmail Emails @ID getGmailEmails @Description This endpoint retrieves emails from Gmail. If there is an error, it redirects to the Google authentication route or returns a server error. @Tags Email @Accept json @Produce json @Success 200 {array} integrations.Email "Returns the retrieved emails" @Failure 401 {Object} Response "Returns a message if the Gmail session has expired" @Failure 500 {object} Response "Returns an error message if there is a Redis related error that is not due to the token key not being found" @Router /v1/email/google [get]

func GetHome

func GetHome(c *fiber.Ctx) error

GetHome returns the home page. @Summary Get Home @ID getHome @Description This endpoint returns a welcome message. @Tags Home @Accept json @Produce json @Success 200 {object} Response "Returns a welcome message" @Router / [get]

func GetNewTokenFromRefreshToken

func GetNewTokenFromRefreshToken(c *fiber.Ctx) error

GetNewTokenFromRefreshToken handles the redirect from the OAuth2 provider @Summary Get New Token From Refresh Token @ID getNewTokenFromRefreshToken @Description This endpoint retrieves a new access token using the refresh token for the specified provider. @Tags OAuth2 @Accept json @Produce json @Param provider query string true "Name of the OAuth2 provider to get the new access token for" @Success 307 {string} string "Redirects to the OAuth success route on successful token retrieval and update" @Failure 400 {object} Response "Returns an error message if the provided OAuth2 provider is invalid" @Failure 500 {object} Response "Returns an error message if there was an error getting the OAuth2 configuration, retrieving the token, getting the new token from the refresh token, or updating the token" @Router /v1/auth/oauth/refresh [get]

func GetOAtuh

func GetOAtuh(c *fiber.Ctx) error

GetOAtuh returns the auth URL for the given OAuth2 provider @Summary Get OAuth2 Authentication URL @ID getOAuth @Description This endpoint generates the OAuth2 authentication URL for the specified provider. @Tags OAuth2 @Accept json @Produce json @Param provider query string true "Name of the OAuth2 provider to generate the authentication URL for" @Success 200 {object} Response "Returns a message with the URL to visit to authorize the application" @Failure 400 {object} Response "Returns an error message if the provided OAuth2 provider is invalid" @Failure 500 {object} Response "Returns an error message if there was an error loading the OAuth2 configuration or generating the OAuth2 URL" @Router /v1/auth/oauth [get]

func GetOAuthCallBack

func GetOAuthCallBack(c *fiber.Ctx) error

GetOAuthCallBack handles the redirect from the OAuth2 provider @Summary OAuth2 Callback Endpoint @ID getOAuthCallBack @Description This endpoint handles the callback from the OAuth2 provider, exchanges the authorization code for an access token, and saves the token. @Tags OAuth2 @Accept json @Produce json @Param code query string true "Authorization code returned by the OAuth2 provider" @Param state query string true "State token for CSRF protection" @Success 307 {string} string "Redirects to the OAuth success route on successful token exchange and save" @Failure 400 {object} Response "Returns an error message if the authorization code or state token is missing or invalid, or if the OAuth2 provider is invalid" @Failure 500 {object} Response "Returns an error message if there was an error getting the OAuth2 configuration, exchanging the code for a token, or saving the token" @Router /v1/auth/oauth/callback [get]

func GetOutlookEmails

func GetOutlookEmails(c *fiber.Ctx) error

GetOutlookEmails returns the user's outlook emails. @Summary Get Outlook Emails @ID getOutlookEmails @Description This endpoint retrieves emails from Outlook. If there is an error, it redirects to the Outlook authentication route or returns a server error. @Tags Email @Accept json @Produce json @Success 200 {array} integrations.Email "Returns the retrieved emails" @Failure 500 {Object} Response "Unable to retrieve emails due to server error or token retrieval issue" @Failure 401 {Object} Response "Returns a message if the outlook session has expired" @Router /v1/email/outlook [get]

func PostAPIKey

func PostAPIKey(c *fiber.Ctx) error

PostAPIKey generates and returns a new API key @Summary Post API Key @ID postAPIKey @Description This endpoint checks if the initial password exists in Redis, compares it with the password from the form, generates an API key if the passwords match, saves the API key in Redis with a TTL of 7 days, and sets the initial password to an empty string. @Tags Authentication @Accept json @Produce json @Param password formData string true "Password from the form" @Success 200 {object} Response "Returns the generated API key" @Failure 500 {object} Response "The initial password has been used. Please check the database for the API key" @Failure 400 {object} Response "Returns an error message if the password from the form does not match the initial password" @Failure 500 {object} Response "Returns an error message if the initial password does not exist, there was an error getting the initial password, generating the API key, saving the API key, or deleting the initial password" @Router /v1/auth/internal/apikey [post]

Types

type Response

type Response struct {
	Data  string `json:"data,omitempty"`
	Error string `json:"error,omitempty"`
}

Response struct

Jump to

Keyboard shortcuts

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