supertokens

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Config

func Config(config ConfigMap)

Config used to set locations of SuperTokens instances

func GetAllSessionHandlesForUser

func GetAllSessionHandlesForUser(userID string) ([]string, error)

GetAllSessionHandlesForUser function used to get all sessions for a user

func GetCORSAllowedHeaders added in v1.3.0

func GetCORSAllowedHeaders() []string

GetCORSAllowedHeaders function is used to get header keys that are used by SuperTokens

func GetJWTPayload

func GetJWTPayload(sessionHandle string) (map[string]interface{}, error)

GetJWTPayload function used to get jwt payload for the given handle

func GetSessionData

func GetSessionData(sessionHandle string) (map[string]interface{}, error)

GetSessionData function used to get session data for the given handle

func HandleErrorAndRespond

func HandleErrorAndRespond(err error, w http.ResponseWriter)

HandleErrorAndRespond if error handlers are provided, then uses those, else does default error handling depending on the type of error

func Middleware

func Middleware(theirHandler http.HandlerFunc, extraParams ...interface{}) http.HandlerFunc

Middleware for verifying and refreshing session. ExtraParams are: bool, func(error, http.ResponseWriter)

func OnGeneralError

func OnGeneralError(handler func(error, http.ResponseWriter))

OnGeneralError function to override default behaviour of handling general errors

func OnTokenTheftDetected

func OnTokenTheftDetected(handler func(string, string, http.ResponseWriter))

OnTokenTheftDetected function to override default behaviour of handling token thefts

func OnTryRefreshToken

func OnTryRefreshToken(handler func(error, http.ResponseWriter))

OnTryRefreshToken function to override default behaviour of handling try refresh token errors

func OnUnauthorized

func OnUnauthorized(handler func(error, http.ResponseWriter))

OnUnauthorized function to override default behaviour of handling Unauthorized error

func RevokeAllSessionsForUser

func RevokeAllSessionsForUser(userID string) ([]string, error)

RevokeAllSessionsForUser function used to revoke all sessions for a user

func RevokeMultipleSessions

func RevokeMultipleSessions(sessionHandles []string) ([]string, error)

RevokeMultipleSessions function used to revoke a list of sessions

func RevokeSession

func RevokeSession(sessionHandle string) (bool, error)

RevokeSession function used to revoke a specific session

func SetRelevantHeadersForOptionsAPI

func SetRelevantHeadersForOptionsAPI(response http.ResponseWriter)

SetRelevantHeadersForOptionsAPI function is used to set headers specific to SuperTokens for OPTIONS API

func UpdateJWTPayload

func UpdateJWTPayload(sessionHandle string, newJWTPayload map[string]interface{}) error

UpdateJWTPayload function used to update jwt payload for the given handle

func UpdateSessionData

func UpdateSessionData(sessionHandle string, newSessionData map[string]interface{}) error

UpdateSessionData function used to update session data for the given handle

Types

type ConfigMap added in v1.1.0

type ConfigMap struct {
	Hosts           string
	AccessTokenPath string
	RefreshAPIPath  string
	CookieDomain    string
	CookieSecure    *bool
	CookieSameSite  string
	APIKey          string
}

ConfigMap add key value params for session behaviour

type Session

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

Session object returned for managing a session

func CreateNewSession

func CreateNewSession(response http.ResponseWriter,
	userID string, payload ...map[string]interface{}) (Session, error)

CreateNewSession function used to create a new SuperTokens session

func GetSession

func GetSession(response http.ResponseWriter, request *http.Request,
	doAntiCsrfCheck bool) (Session, error)

GetSession function used to verify a session

func GetSessionFromRequest

func GetSessionFromRequest(r *http.Request) *Session

GetSessionFromRequest returns the verified session object if present, otherwise returns nil

func RefreshSession

func RefreshSession(response http.ResponseWriter, request *http.Request) (Session, error)

RefreshSession function used to refresh a session

func (*Session) GetAccessToken

func (session *Session) GetAccessToken() string

GetAccessToken function gets the access token for this session

func (*Session) GetHandle

func (session *Session) GetHandle() string

GetHandle function gets the session handle for this session

func (*Session) GetJWTPayload

func (session *Session) GetJWTPayload() map[string]interface{}

GetJWTPayload function gets the jwt payload for this session

func (*Session) GetSessionData

func (session *Session) GetSessionData() (map[string]interface{}, error)

GetSessionData function used to get session data for this session

func (*Session) GetUserID

func (session *Session) GetUserID() string

GetUserID function gets the user for this session

func (*Session) RevokeSession

func (session *Session) RevokeSession() error

RevokeSession function used to revoke a session for this session

func (*Session) UpdateJWTPayload

func (session *Session) UpdateJWTPayload(newJWTPayload map[string]interface{}) error

UpdateJWTPayload function used to update jwt payload for this session

func (*Session) UpdateSessionData

func (session *Session) UpdateSessionData(newSessionData map[string]interface{}) error

UpdateSessionData function used to update session data for this session

type TokenInfo added in v1.4.1

type TokenInfo struct {
	Uid string                 `json:"uid"`
	Ate uint64                 `json:"ate"`
	Up  map[string]interface{} `json:"up"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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