request

package
v0.0.0-...-df391e2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CortezaSessionStore

func CortezaSessionStore(store store.AuthSessions, opt options.AuthOpt) *cortezaSessionStore

func GetAuthUser

func GetAuthUser(ses *sessions.Session) *authUser

GetUser is wrapper to get value from session

func GetOAuth2AuthParams

func GetOAuth2AuthParams(ses *sessions.Session) url.Values

GetOAuth2AuthParams is wrapper to get value from session

func GetOauth2Client

func GetOauth2Client(ses *sessions.Session) *types.AuthClient

GetOauth2Client is wrapper to get value from session

func IsOauth2ClientAuthorized

func IsOauth2ClientAuthorized(ses *sessions.Session) bool

IsOauth2ClientAuthorized is wrapper to get value from session

func IsPermLogin

func IsPermLogin(ses *sessions.Session) (p bool)

IsPermLogin decodes remember-me flag from the session and returns true if set

func NewAuthUser

func NewAuthUser(s *settings.Settings, u *types.User, perm bool) *authUser

func SetOauth2AuthParams

func SetOauth2AuthParams(ses *sessions.Session, val url.Values)

SetOauth2AuthParams is a session value setting wrapper for Oauth2AuthParams

func SetOauth2Client

func SetOauth2Client(ses *sessions.Session, val *types.AuthClient)

SetOauth2Client is a session value setting wrapper for Oauth2Client

func SetOauth2ClientAuthorized

func SetOauth2ClientAuthorized(ses *sessions.Session, val bool)

SetOauth2ClientAuthorized is a session value setting wrapper for Oauth2ClientAuthorized

Types

type Alert

type Alert struct {
	// primary, secondary, danger, warning...
	Type string
	Text string
	Html template.URL
}

type AuthReq

type AuthReq struct {
	// HTTP request sent
	Request *http.Request

	Response http.ResponseWriter

	// Sessions
	Session *sessions.Session

	// Authenticated user
	AuthUser *authUser

	// Current client (when in oauth2 flow)
	Client *types.AuthClient

	Locale localeService

	// Redirect to
	RedirectTo string

	// Template to render
	Template string

	// Data to render with the template
	Data map[string]interface{}

	// handling flash alerts of all types
	//
	// should not be used for form errors; store them into sep. session keys
	PrevAlerts, NewAlerts []Alert

	// HTTP status to send
	Status int
}

auth context simplifies auth request & response handling

func (AuthReq) Context

func (req AuthReq) Context() context.Context

func (*AuthReq) GetKV

func (req *AuthReq) GetKV() map[string]string

retrives key-value from session, stored under request-uri key

func (*AuthReq) PopAlerts

func (req *AuthReq) PopAlerts() []Alert

func (*AuthReq) PopKV

func (req *AuthReq) PopKV() map[string]string

func (*AuthReq) PushAlert

func (req *AuthReq) PushAlert(text string)

func (*AuthReq) PushDangerAlert

func (req *AuthReq) PushDangerAlert(text string)

func (*AuthReq) SetAlerts

func (req *AuthReq) SetAlerts(aa ...Alert)

func (*AuthReq) SetInternalError

func (req *AuthReq) SetInternalError(err error) bool

func (*AuthReq) SetKV

func (req *AuthReq) SetKV(val map[string]string)

sets key-value value to session under request-uri key

type ExtraReqInfo

type ExtraReqInfo struct {
	RemoteAddr string
	UserAgent  string
}

ExtraReqInfo serves as transport struct for additional request information we want to store with the oauth2 token

There is effortless way to extend token info that is created inside go-oauth2 lib so we'll attach this struct to (request's) context with middleware (see MountHttpRoutes) and unpack from context when token is created in CortezaTokenStore.Create()

ExtraReqInfo struct also serves as context value key!

type SessionManager

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

func NewSessionManager

func NewSessionManager(store store.AuthSessions, opt options.AuthOpt, log *zap.Logger) *SessionManager

func (*SessionManager) DeleteByID

func (m *SessionManager) DeleteByID(ctx context.Context, sessionID string) (err error)

DeleteByID removes session by it's ID

func (*SessionManager) DeleteByUserID

func (m *SessionManager) DeleteByUserID(ctx context.Context, userID uint64) (err error)

DeleteByUserID removes session by user ID

func (*SessionManager) Get

func (*SessionManager) Save

func (*SessionManager) Search

func (m *SessionManager) Search(ctx context.Context, userID uint64) (set []*types.AuthSession, err error)

Returns all users sessions

func (SessionManager) Store

func (m SessionManager) Store() sessions.Store

Jump to

Keyboard shortcuts

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