api

package
v0.0.0-...-2448ec3 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEntry

func AddEntry(context echo.Context) error

func AddLabel

func AddLabel(context echo.Context) error

May not be as similar in the end, still the method is too big imo

func AuthMiddleware

func AuthMiddleware() echo.MiddlewareFunc

func BuildJwtToken

func BuildJwtToken(user database.User, sessionDuration time.Duration, secret []byte) string

Add a user to claims without otp secret and password. Expects a duration in nanoseconds Could implement a key rotation system

func BuildRateLimiterConf

func BuildRateLimiterConf() *limiter.Limiter

func DeclareRoutes

func DeclareRoutes(app *echo.Echo)

func DeleteAbstract

func DeleteAbstract(context echo.Context, m database.Model) error

Abstract implementation for an http call DELETE /resource/:id Expect the resource to be associated to the user with the foreign key user_id

func DeleteEntry

func DeleteEntry(context echo.Context) error

func DeleteLabel

func DeleteLabel(context echo.Context) error

func EditEntry

func EditEntry(context echo.Context) error

func EditLabel

func EditLabel(context echo.Context) error

func GetEntries

func GetEntries(c echo.Context) error

func GetEntry

func GetEntry(context echo.Context) error

Returns a specific entry and the next / prev ones.

We may want that the prev and next fit search criteria, in which case they should be sent here with the same format as in GetEntries

func GetLabels

func GetLabels(context echo.Context) error

func GetMe

func GetMe(c echo.Context) error

func InternalError

func InternalError(context echo.Context, err error) error

Return HTTP 500 and log error to sentry

func Login

func Login(context echo.Context) error

2FA could check: Cookie, IP, device / fingerprint, link to element which validates the cookie

func PopulateLabelsUrls

func PopulateLabelsUrls(labels []database.Label) []database.Label

func RateLimiterMiddleware

func RateLimiterMiddleware(limiter *limiter.Limiter) echo.MiddlewareFunc

Middleware to limit the number of request an IP can make during a time window

func RecoverMiddleware

func RecoverMiddleware() echo.MiddlewareFunc

func Register

func Register(context echo.Context) error

func RequestGoogleAuthenticatorQRCode

func RequestGoogleAuthenticatorQRCode(context echo.Context) error

func RequestTwoFactorsToken

func RequestTwoFactorsToken(context echo.Context) error

func RequireBody

func RequireBody(next echo.HandlerFunc) echo.HandlerFunc

func RunHttpServer

func RunHttpServer()

func SendApiSpec

func SendApiSpec(c echo.Context) error

func TokenToRemainingDuration

func TokenToRemainingDuration() time.Duration

TODO

func ValidateJWTToken

func ValidateJWTToken(token string, secret []byte) (jwt.MapClaims, error)

func ValidateOTPCode

func ValidateOTPCode(context echo.Context) error

Types

type AddEntryRequestBody

type AddEntryRequestBody struct {
	database.PartialEntry
	LabelsID []uint `json:"labels_id"`
}

type LoginBody

type LoginBody struct {
	Email             string        `json:"email"`
	Password          string        `json:"password" validate:"min=9"`
	SessionDurationMs time.Duration `json:"session_duration_ms"`
	TwoFactorsCookie  string        `json:"two_factors_cookie"`
}

We use login body instead of user because user json blocks password

type OTPCodeBody

type OTPCodeBody struct {
	Passcode   string `json:"passcode" validate:"required,len=6,numeric"`
	Token      string `json:"token" validate:"required"`
	KeepActive bool   `json:"keep_active"`
}

type TokenClaims

type TokenClaims struct {
	User database.User `json:"user"`
	jwt.StandardClaims
}

func (TokenClaims) Valid

func (c TokenClaims) Valid() error

type Url

type Url struct {
	ovh.ObjectTempPublicUrl
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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