Documentation ¶
Index ¶
- Constants
- func DeleteCSRFCookies(w http.ResponseWriter)
- func DeleteCookie(w http.ResponseWriter, name string)
- func GetExpiryTimeFromMinutes(min int64) time.Time
- func MaskedCSRFMiddleware(useSecureCookie bool) func(next http.Handler) http.Handler
- func SessionCookieMiddleware(globalLogger *zap.Logger, appnames ApplicationServername, ...) func(next http.Handler) http.Handler
- func SessionIDFromContext(ctx context.Context) string
- func SessionIDMiddleware(appnames ApplicationServername, sessionManagers AppSessionManagers) func(next http.Handler) http.Handler
- func SetSessionInContext(ctx context.Context, session *Session) context.Context
- func SetSessionInRequestContext(r *http.Request, session *Session) context.Context
- func WriteMaskedCSRFCookie(w http.ResponseWriter, csrfToken string, useSecureCookie bool)
- type AppSessionManagers
- type Application
- type ApplicationServername
- type OktaSessionInfo
- type ScsSessionManagerWrapper
- func (s ScsSessionManagerWrapper) Commit(ctx context.Context) (string, time.Time, error)
- func (s ScsSessionManagerWrapper) Destroy(ctx context.Context) error
- func (s ScsSessionManagerWrapper) Get(ctx context.Context, key string) interface{}
- func (s ScsSessionManagerWrapper) Load(ctx context.Context, token string) (context.Context, error)
- func (s ScsSessionManagerWrapper) LoadAndSave(next http.Handler) http.Handler
- func (s ScsSessionManagerWrapper) Put(ctx context.Context, key string, val interface{})
- func (s ScsSessionManagerWrapper) RenewToken(ctx context.Context) error
- func (s ScsSessionManagerWrapper) SessionCookie() scs.SessionCookie
- func (s ScsSessionManagerWrapper) Store() scs.Store
- type Session
- func (s *Session) IsAdminApp() bool
- func (s *Session) IsAdminUser() bool
- func (s *Session) IsMilApp() bool
- func (s *Session) IsOfficeApp() bool
- func (s *Session) IsOfficeUser() bool
- func (s *Session) IsProgramAdmin() bool
- func (s *Session) IsServiceMember() bool
- func (s *Session) IsSystemAdmin() bool
- type SessionManager
Constants ¶
const GorillaCSRFToken = "_gorilla_csrf"
GorillaCSRFToken is the name of the base CSRF token RA Summary: gosec - G101 - Password Management: Hardcoded Password RA: This line was flagged because it detected use of the word "token" RA: This line is used to identify the name of the token. GorillaCSRFToken is the name of the base CSRF token. RA: This variable does not store an application token. RA Developer Status: Mitigated RA Validator Status: Mitigated RA Validator: jneuner@mitre.org RA Modified Severity: CAT III #nosec G101
const MaskedGorillaCSRFToken = "masked_gorilla_csrf"
MaskedGorillaCSRFToken is the masked CSRF token used to send back in the 'X-CSRF-Token' request header
const SessionExpiryInMinutes = 15
SessionExpiryInMinutes is the number of minutes before a fallow session is harvested
Variables ¶
This section is empty.
Functions ¶
func DeleteCSRFCookies ¶
func DeleteCSRFCookies(w http.ResponseWriter)
DeleteCSRFCookies deletes the base and masked CSRF cookies
func DeleteCookie ¶
func DeleteCookie(w http.ResponseWriter, name string)
DeleteCookie sends a delete request for the named cookie
func GetExpiryTimeFromMinutes ¶
GetExpiryTimeFromMinutes returns 'min' minutes from now
func MaskedCSRFMiddleware ¶
MaskedCSRFMiddleware handles setting the CSRF Token cookie
func SessionCookieMiddleware ¶
func SessionCookieMiddleware(globalLogger *zap.Logger, appnames ApplicationServername, sessionManagers AppSessionManagers) func(next http.Handler) http.Handler
SessionCookieMiddleware handle serializing and de-serializing the session between the user_session cookie and the request context
func SessionIDFromContext ¶
func SessionIDMiddleware ¶
func SessionIDMiddleware(appnames ApplicationServername, sessionManagers AppSessionManagers) func(next http.Handler) http.Handler
func SetSessionInContext ¶
SetSessionInContext modifies the context to add the session data.
func SetSessionInRequestContext ¶
SetSessionInRequestContext modifies the request's Context() to add the session data
func WriteMaskedCSRFCookie ¶
func WriteMaskedCSRFCookie(w http.ResponseWriter, csrfToken string, useSecureCookie bool)
WriteMaskedCSRFCookie update the masked_gorilla_csrf cookie value
Types ¶
type AppSessionManagers ¶
type AppSessionManagers struct { Mil SessionManager Office SessionManager Admin SessionManager }
func SetupSessionManagers ¶
func SetupSessionManagers(redisPool *redis.Pool, useSecureCookie bool, idleTimeout time.Duration, lifetime time.Duration) AppSessionManagers
SetupSessionManagers configures the session manager for each app: mil, admin, and office. It's necessary to have separate session managers to allow users to be signed in on multiple apps at the same time.
func (AppSessionManagers) SessionManagerForApplication ¶
func (a AppSessionManagers) SessionManagerForApplication(app Application) SessionManager
sessionManagerForSession returns the appropriate session manager for the session
type Application ¶
type Application string
Application describes the application name
const ( // OfficeApp indicates office.move.mil OfficeApp Application = "office" // MilApp indicates my.move.mil (DNS still points to my.move.mil and not mil.move.mil) MilApp Application = "mil" // AdminApp indicates admin.move.mil AdminApp Application = "admin" )
func ApplicationName ¶
func ApplicationName(hostname string, appnames ApplicationServername) (Application, error)
ApplicationName returns the application name given the hostname
func (Application) IsAdminApp ¶
func (a Application) IsAdminApp() bool
IsAdminApp returns true if the application is the admin app
func (Application) IsMilApp ¶
func (a Application) IsMilApp() bool
IsMilApp returns true if the application is the mil app
func (Application) IsOfficeApp ¶
func (a Application) IsOfficeApp() bool
IsOfficeApp returns true if the application is the office app
type ApplicationServername ¶
type ApplicationServername struct { MilServername string OfficeServername string AdminServername string OrdersServername string PrimeServername string PPTASServerName string }
ApplicationServername is a collection of all the servernames for the application
type OktaSessionInfo ¶
type ScsSessionManagerWrapper ¶
type ScsSessionManagerWrapper struct {
ScsSessionManager *scs.SessionManager
}
func (ScsSessionManagerWrapper) Destroy ¶
func (s ScsSessionManagerWrapper) Destroy(ctx context.Context) error
func (ScsSessionManagerWrapper) Get ¶
func (s ScsSessionManagerWrapper) Get(ctx context.Context, key string) interface{}
func (ScsSessionManagerWrapper) LoadAndSave ¶
func (s ScsSessionManagerWrapper) LoadAndSave(next http.Handler) http.Handler
func (ScsSessionManagerWrapper) Put ¶
func (s ScsSessionManagerWrapper) Put(ctx context.Context, key string, val interface{})
func (ScsSessionManagerWrapper) RenewToken ¶
func (s ScsSessionManagerWrapper) RenewToken(ctx context.Context) error
func (ScsSessionManagerWrapper) SessionCookie ¶
func (s ScsSessionManagerWrapper) SessionCookie() scs.SessionCookie
func (ScsSessionManagerWrapper) Store ¶
func (s ScsSessionManagerWrapper) Store() scs.Store
type Session ¶
type Session struct { ApplicationName Application Hostname string IDToken string UserID uuid.UUID Email string FirstName string Middle string LastName string ServiceMemberID uuid.UUID OfficeUserID uuid.UUID AdminUserID uuid.UUID AdminUserRole string Roles roles.Roles Permissions []string AccessToken string ClientID string OktaSessionInfo OktaSessionInfo }
Session stores information about the currently logged in session
func SessionFromContext ¶
SessionFromContext gets the reference to the Session stored in the request.Context()
func SessionFromRequestContext ¶
SessionFromRequestContext gets the reference to the Session stored in the request.Context()
func (*Session) IsAdminApp ¶
IsAdminApp returns true iff the request is for the admin.move.mil host
func (*Session) IsAdminUser ¶
IsAdminUser checks whether the authenticated user is an AdminUser
func (*Session) IsOfficeApp ¶
IsOfficeApp returns true iff the request is for the office.move.mil host
func (*Session) IsOfficeUser ¶
IsOfficeUser checks whether the authenticated user is an OfficeUser
func (*Session) IsProgramAdmin ¶
IsProgramAdmin checks whether the authenticated admin user is a program admin
func (*Session) IsServiceMember ¶
IsServiceMember checks whether the authenticated user is a ServiceMember
func (*Session) IsSystemAdmin ¶
IsSystemAdmin checks whether the authenticated admin user is a system admin
type SessionManager ¶
type SessionManager interface { Get(context.Context, string) interface{} Put(context.Context, string, interface{}) Destroy(context.Context) error RenewToken(context.Context) error Commit(context.Context) (string, time.Time, error) Load(context.Context, string) (context.Context, error) LoadAndSave(http.Handler) http.Handler Store() scs.Store SessionCookie() scs.SessionCookie }