utils

package
v0.0.0-...-835c9c4 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAdminToken

func GenerateAdminToken(admin string, session int) (string, error)

GenerateAdminToken generates an unscoped token for an administrator

func GenerateScopedToken

func GenerateScopedToken(admin string, user, session int) (string, error)

GenerateScopedToken generates a token for an administrator scoped to a user

func GenerateUserToken

func GenerateUserToken(user, session int) (string, error)

GenerateUserToken generates a token scoped to a user

func GetAdmins

func GetAdmins() []string

GetAdmins returns a list of available admins

func IsAdmin

func IsAdmin(email string) bool

IsAdmin returns whether the given email is for an admin

func ParseAdminToken

func ParseAdminToken(token string) (string, int, error)

ParseAdminToken decodes the auth token given to it and ensures that it has administrator information in it

func ParseScopedToken

func ParseScopedToken(token string) (string, int, int, error)

ParseScopedToken decodes the auth token given to it and ensures that it is scoped to a user

func SetSecureStore

func SetSecureStore(opts buffalo.Options) buffalo.Options

SetSecureStore sets cookies as HTTPOnly and with the Secure bit on in any environment other than development and test. Most of it is ripped straight from the buffalo source code; https://github.com/gobuffalo/buffalo/blob/9f469851d4d4b00652bf49701840ad41037e6a93/options.go#L153-L162

func UserIP

func UserIP(c buffalo.Context) string

UserIP returns the ip of the requester

Types

type Environment

type Environment string

Environment wraps the environment that's set

func GetEnvironment

func GetEnvironment() Environment

GetEnvironment returns the current environment

func (Environment) IsDeployed

func (e Environment) IsDeployed() bool

IsDeployed checks whether we're in a production deployed environment

func (Environment) Load

func (e Environment) Load()

Load loads a dotenv file for the given environment

Jump to

Keyboard shortcuts

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