common

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthCookieName added in v0.8.0

func AuthCookieName(unsecure bool) string

func CSRFCookieName added in v0.8.0

func CSRFCookieName(unsecure bool) string

func CurrentUserID

func CurrentUserID(ctx context.Context) string

func ExtractToken added in v0.8.0

func ExtractToken(hdr http.Header, name, prefix string) string

func GenerateAuthCookies added in v0.8.0

func GenerateAuthCookies(userID string, sc *scommon.CookieSigningData, unsecureCookies bool) (*http.Cookie, *http.Cookie, error)

func IsUserAdmin

func IsUserAdmin(ctx context.Context) bool

func IsUserLogged

func IsUserLogged(ctx context.Context) bool

func IsUserLoggedOrAdmin

func IsUserLoggedOrAdmin(ctx context.Context) bool

func SecondaryAuthCookieName added in v0.8.0

func SecondaryAuthCookieName() string

Types

type AuthCookie added in v0.8.0

type AuthCookie struct {
	Sub            string    `json:"sub"`
	SecondaryToken string    `json:"secondaryToken"`
	Expires        time.Time `json:"expires"`
}

type ContextKey

type ContextKey int
const (
	ContextKeyUserID ContextKey = iota
	ContextKeyUsername
	ContextKeyUserAdmin

	ContextKeyTokenAuth
)

type SecondaryAuthCookie added in v0.8.0

type SecondaryAuthCookie struct {
	SecondaryToken string `json:"secondaryToken"`
}

Jump to

Keyboard shortcuts

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