auth

package
v0.0.0-...-a6c2dd6 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: AGPL-3.0 Imports: 43 Imported by: 4

Documentation

Overview

Package auth provides register and login handlers

Index

Constants

View Source
const (
	// CredentialsErrorKey is the key for translating the message showed to the
	// user when he/she enters incorrect credentials
	CredentialsErrorKey = "Login Credentials error"
	// TwoFactorErrorKey is the key for translating the message showed to the
	// user when he/she enters incorrect two factor secret
	TwoFactorErrorKey = "Login Two factor error"
	// TwoFactorExceededErrorKey is the key for translating the message showed to the
	// user when there were too many attempts
	TwoFactorExceededErrorKey = "Login Two factor attempts error"
)
View Source
const DefaultStoreURL = "https://cozy.io/fr/download/"

Variables

This section is empty.

Functions

func AppRedirection

func AppRedirection(inst *instance.Instance, redirect string) (*url.URL, error)

func CheckLinkedAppInstalled

func CheckLinkedAppInstalled(inst *instance.Instance, slug string) error

CheckLinkedAppInstalled checks if a linked webapp has been installed to the instance

func ConfirmSuccess

func ConfirmSuccess(c echo.Context, inst *instance.Instance, state string) error

ConfirmSuccess can be used to send a response after a successful identity confirmation.

func CreateSessionCode

func CreateSessionCode(c echo.Context) error

CreateSessionCode is the handler for creating a session code by the flagship app.

func DiskInfo

func DiskInfo(fs vfs.VFS) (string, string, error)

DiskInfo returns the used and quota disk space for the given VFS.

func GetLinkedApp

func GetLinkedApp(instance *instance.Instance, softwareID string) (*app.WebappManifest, error)

GetLinkedApp fetches the app manifest on the registry

func Home

func Home(c echo.Context) error

Home is the handler for / It redirects to the login page is the user is not yet authentified Else, it redirects to its home application (or onboarding)

func LockOAuthClient

func LockOAuthClient(inst *instance.Instance, clientID string) func()

func LoginRateExceeded

func LoginRateExceeded(i *instance.Instance) error

LoginRateExceeded blocks the instance after too many failed attempts to login

func ReturnSessionCode

func ReturnSessionCode(c echo.Context, statusCode int, inst *instance.Instance) error

func Routes

func Routes(router *echo.Group)

Routes sets the routing for the status service

func SetCookieForNewSession

func SetCookieForNewSession(c echo.Context, duration session.Duration) (string, error)

SetCookieForNewSession creates a new session and sets the cookie on echo context

func TwoFactorGenerationExceeded

func TwoFactorGenerationExceeded(i *instance.Instance) error

TwoFactorGenerationExceeded checks if there was too many attempts to regenerate a 2FA code within an hour

func TwoFactorRateExceeded

func TwoFactorRateExceeded(i *instance.Instance) error

TwoFactorRateExceeded regenerates a new 2FA passcode after too many failed attempts to login

Types

type AccessTokenReponse

type AccessTokenReponse struct {
	Type    string `json:"token_type"`
	Scope   string `json:"scope"`
	Access  string `json:"access_token"`
	Refresh string `json:"refresh_token,omitempty"`
}

AccessTokenReponse is the stuct used for serializing to JSON the response for an access token.

type AuthorizeHTTPHandler

type AuthorizeHTTPHandler struct {
	// contains filtered or unexported fields
}

func NewAuthorizeHandler

func NewAuthorizeHandler(deprecatedAppsCfg config.DeprecatedAppsCfg) *AuthorizeHTTPHandler

NewAuthorizeHandler instantiates a new [AuthHTTPHandler].

func (*AuthorizeHTTPHandler) Register

func (a *AuthorizeHTTPHandler) Register(router *echo.Group)

type DeprecatedAppList

type DeprecatedAppList struct {
	// contains filtered or unexported fields
}

DeprecatedAppList lists and detects the deprecated apps.

func NewDeprecatedAppList

func NewDeprecatedAppList(cfg config.DeprecatedAppsCfg) *DeprecatedAppList

NewDeprecatedAppList instantiates a new DeprecatedAppList.

func (*DeprecatedAppList) IsDeprecated

func (d *DeprecatedAppList) IsDeprecated(client *oauth.Client) bool

IsDeprecated returns true if the given client is marked as deprectated.

func (*DeprecatedAppList) RenderArgs

func (d *DeprecatedAppList) RenderArgs(client *oauth.Client, inst *instance.Instance, uaStr string) map[string]interface{}

type Store

type Store interface {
	AddCode(db prefixer.Prefixer) (string, error)
	GetCode(db prefixer.Prefixer, code string) (bool, error)
}

Store is essentially an object to store and retrieve confirmation codes

func GetStore

func GetStore() Store

GetStore returns the store for temporary move objects.

Jump to

Keyboard shortcuts

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