admin

package
v2.8.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrorWrongInput is for corrupted request data.
	ErrorWrongInput = Error("Wrong input data")
	// ErrorRequestInvalidCookie is for invalid cookie.
	ErrorRequestInvalidCookie = Error("Invalid cookie")
	// ErrorInternalError is for internal errors.
	ErrorInternalError = Error("Internal error")
	// ErrorIncorrectLogin is for incorrect login and password.
	ErrorIncorrectLogin = Error("Incorrect login information")
	// ErrorNotAuthorized is for non-authorized access intents.
	ErrorNotAuthorized = Error("Not authorized")
	// ErrorAPIRequestBodyParamsInvalid means that request params are corrupted.
	ErrorAPIRequestBodyParamsInvalid = Error("Input data does not pass validation. Please specify valid params")
	// ErrorAPIInviteNotFound is when invite not found.
	ErrorAPIInviteNotFound = Error("Specified invite not found.")
	// ErrorAPIInviteUnableToInvalidate is when invite cannot be invalidated.
	ErrorAPIInviteUnableToInvalidate = Error("Unable to invalidate invite. Try again or contact support team")
	// ErrorAPIInviteTokenGenerate is when invite not found.
	ErrorAPIInviteTokenGenerate = Error("Unable to generate invite token")
	// ErrorAPISaveInvite is when invite not found.
	ErrorAPISaveInvite = Error("Unable to save invite")

	// ErrorAdminAccountIsNotSet is when not env variables for admin email or/and password are set
	ErrorAdminAccountIsNotSet = Error("Environment variabels for admin account (email and password) is not set")
	// ErrorAdminAccountNoEmailAndPassword when no admin email or/and password are set
	ErrorAdminAccountNoEmailAndPassword = Error("Admin email and/or password are empty and could not be used for security reason")
)

Variables

This section is empty.

Functions

func NewRouter

func NewRouter(settings RouterSettings) (model.Router, error)

NewRouter creates and initializes new admin router.

Types

type Error

type Error string

Error is an http level error type.

func (Error) Error

func (e Error) Error() string

Error is an implementation of std.Error interface.

type ResetEmailData

type ResetEmailData struct {
	User  model.User
	Token string
	URL   string
	Host  string
}

type Router

type Router struct {
	RedirectURL string
	PathPrefix  string
	Host        *url.URL
	// contains filtered or unexported fields
}

Router is a router that handles admin requests.

func (*Router) AddInvite added in v2.2.16

func (ar *Router) AddInvite() http.HandlerFunc

func (*Router) ArchiveInviteByID

func (ar *Router) ArchiveInviteByID() http.HandlerFunc

ArchiveInviteByID sets the 'valid' field of the model.Invite to false.

func (*Router) CreateApp

func (ar *Router) CreateApp() http.HandlerFunc

CreateApp adds new app to the database.

func (*Router) CreateUser

func (ar *Router) CreateUser() http.HandlerFunc

CreateUser registers new user.

func (*Router) DeleteAllApps

func (ar *Router) DeleteAllApps() http.HandlerFunc

DeleteAllApps delete all current apps for some reason? now we are using it for tests

func (*Router) DeleteApp

func (ar *Router) DeleteApp() http.HandlerFunc

DeleteApp deletes app from the database by id.

func (*Router) DeleteUser

func (ar *Router) DeleteUser() http.HandlerFunc

DeleteUser deletes user from the database.

func (*Router) Error

func (ar *Router) Error(w http.ResponseWriter, err error, code int, userInfo string)

Error writes an API error message to the response and logger.

func (*Router) FederatedProvidersList

func (ar *Router) FederatedProvidersList() http.HandlerFunc

GetApp fetches app by ID from the database.

func (*Router) FetchApps

func (ar *Router) FetchApps() http.HandlerFunc

FetchApps fetches apps from the database.

func (*Router) FetchInvites

func (ar *Router) FetchInvites() http.HandlerFunc

FetchInvites returns all invites, active by default. If the withValid param provided and it's true, the method returns all invites including expired and invalid.

func (*Router) FetchSettings

func (ar *Router) FetchSettings() http.HandlerFunc

FetchSettings returns server settings.

func (*Router) FetchUsers

func (ar *Router) FetchUsers() http.HandlerFunc

FetchUsers fetches users from the database.

func (*Router) GenerateNewResetTokenUser

func (ar *Router) GenerateNewResetTokenUser() http.HandlerFunc

func (*Router) GenerateNewSecret

func (ar *Router) GenerateNewSecret() http.HandlerFunc

GenerateNewSecret generate new secret key, save it and return new public key

func (*Router) GetApp

func (ar *Router) GetApp() http.HandlerFunc

GetApp fetches app by ID from the database.

func (*Router) GetInviteByID

func (ar *Router) GetInviteByID() http.HandlerFunc

GetInviteByID returns specific invite by its id.

func (*Router) GetJWTKeys

func (ar *Router) GetJWTKeys() http.HandlerFunc

GetJWTKeys returns public and private JWT keys currently used by Identifo

func (*Router) GetServerErrors added in v2.3.3

func (ar *Router) GetServerErrors() http.HandlerFunc

return all server errors

func (*Router) GetUser

func (ar *Router) GetUser() http.HandlerFunc

GetUser fetches user by ID from the database.

func (*Router) IsLoggedIn

func (ar *Router) IsLoggedIn() http.HandlerFunc

IsLoggedIn checks if admin is logged in.

func (*Router) Login

func (ar *Router) Login() http.HandlerFunc

Login logins admin with admin name and password.

func (*Router) Logout

func (ar *Router) Logout() http.HandlerFunc

Logout logs admin out.

func (*Router) RemoveTrailingSlash

func (ar *Router) RemoveTrailingSlash() negroni.HandlerFunc

func (*Router) ServeHTTP

func (ar *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements identifo.Router interface.

func (*Router) ServeJSON

func (ar *Router) ServeJSON(w http.ResponseWriter, code int, v interface{})

ServeJSON sends status code, headers and data back to the user.

func (*Router) Session

func (ar *Router) Session() negroni.HandlerFunc

Session is a middleware to check if admin is logged in with valid cookie. If all checks succeeded, prolongs existing session. If not, forces to login.

func (*Router) TestConnection

func (ar *Router) TestConnection() http.HandlerFunc

TestConnection validates different connection types, if server could connect to that.

func (*Router) TestDatabaseConnection

func (ar *Router) TestDatabaseConnection() http.HandlerFunc

TestDatabaseConnection tests database connection.

func (*Router) UpdateApp

func (ar *Router) UpdateApp() http.HandlerFunc

UpdateApp updates app in the database.

func (*Router) UpdateSettings

func (ar *Router) UpdateSettings() http.HandlerFunc

UpdateSettings handles the request to update server settings.

func (*Router) UpdateUser

func (ar *Router) UpdateUser() http.HandlerFunc

UpdateUser updates user in the database.

func (*Router) UploadJWTKeys

func (ar *Router) UploadJWTKeys() http.HandlerFunc

UploadJWTKeys is for uploading public and private keys used for signing JWTs.

type RouterSettings

type RouterSettings struct {
	Server       model.Server
	Logger       *log.Logger
	Host         *url.URL
	Prefix       string
	Cors         *cors.Cors
	Restart      chan<- bool
	OriginUpdate func() error
}

type ServerInitErrors added in v2.3.3

type ServerInitErrors struct {
	Errors []error `json:"errors"`
}

type ServerSettingsAPI

type ServerSettingsAPI struct {
	General        *model.GeneralServerSettings  `json:"general,omitempty"`
	AdminAccount   *model.AdminAccountSettings   `json:"admin_account,omitempty"`
	Storage        *StorageSettingsAPI           `json:"storage,omitempty"`
	SessionStorage *model.SessionStorageSettings `json:"session_storage,omitempty"`
	Services       *model.ServicesSettings       `json:"external_services,omitempty"`
	Login          *model.LoginSettings          `json:"login,omitempty"`
	KeyStorage     *model.FileStorageSettings    `json:"keyStorage,omitempty"`
	Config         *model.FileStorageSettings    `json:"config,omitempty"`
	Logger         *model.LoggerSettings         `json:"logger,omitempty"`
	AdminPanel     *model.AdminPanelSettings     `json:"admin_panel"`
	LoginWebApp    *model.FileStorageSettings    `json:"login_web_app"`
	EmailTemplates *model.FileStorageSettings    `json:"email_templates"`
}

type StorageSettingsAPI

type StorageSettingsAPI struct {
	AppStorage              *model.DatabaseSettings `json:"app_storage,omitempty"`
	UserStorage             *model.DatabaseSettings `json:"user_storage,omitempty"`
	TokenStorage            *model.DatabaseSettings `json:"token_storage,omitempty"`
	TokenBlacklist          *model.DatabaseSettings `json:"token_blacklist,omitempty"`
	VerificationCodeStorage *model.DatabaseSettings `json:"verification_code_storage,omitempty"`
	InviteStorage           *model.DatabaseSettings `json:"invite_storage,omitempty"`
}

Jump to

Keyboard shortcuts

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