Documentation
¶
Index ¶
- func CodeToken(ctx context.Context, r *http.Request, w http.ResponseWriter, ...) error
- func LoadValue(r *http.Request, w http.ResponseWriter, cookieName, postfix, sessionKey string, ...) ([]byte, error)
- func RefreshToken(ctx context.Context, r *http.Request, w http.ResponseWriter, ...) (*store.Token, error)
- func RegexCheck(r *http.Request, information *RedirectMatch) (bool, error)
- func RemoveAuthQueryParams(r *http.Request)
- func RemoveRedirect(r *http.Request, w http.ResponseWriter, cookieName string, redirect *Setting, ...) error
- func RemoveValue(r *http.Request, w http.ResponseWriter, cookieName, postfix string, ...) error
- func SaveInfo(r *http.Request, w http.ResponseWriter, accessToken string, ...) error
- func SaveValue(r *http.Request, w http.ResponseWriter, cookieName, postfix, sessionKey string, ...) error
- func SetRedirect(r *http.Request, redirect *Setting, rValue RedirectValue) error
- func URI(r *http.Request, callback, baseURL, schema string, disableRawQueryEmpty bool) (string, error)
- type Info
- type Information
- type InformationCookie
- type Logout
- type RedirectMatch
- type RedirectValue
- type RegexMatch
- type RegexPath
- type Setting
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CodeToken ¶
func CodeToken(ctx context.Context, r *http.Request, w http.ResponseWriter, code, cookieName string, redirect *Setting, sessionStore *sessions.FilesystemStore) error
CodeToken get token and set the cookie/session.
func LoadValue ¶
func LoadValue(r *http.Request, w http.ResponseWriter, cookieName, postfix, sessionKey string, redirect *Setting, sessionStore store.SessionStore) ([]byte, error)
LoadValue load the cookie/session.
func RefreshToken ¶
func RefreshToken(ctx context.Context, r *http.Request, w http.ResponseWriter, refreshToken, cookieName string, oldCookieValue string, redirect *Setting, sessionStore *sessions.FilesystemStore) (*store.Token, error)
RefreshToken refreshes the access token and set the cookie.
func RegexCheck ¶ added in v0.7.1
func RegexCheck(r *http.Request, information *RedirectMatch) (bool, error)
func RemoveAuthQueryParams ¶
func RemoveRedirect ¶
func RemoveRedirect(r *http.Request, w http.ResponseWriter, cookieName string, redirect *Setting, sessionStore store.SessionStore) error
func RemoveValue ¶
func RemoveValue(r *http.Request, w http.ResponseWriter, cookieName, postfix string, redirect *Setting, sessionStore store.SessionStore) error
RemoveValue remove the cookie/session.
func SaveInfo ¶ added in v0.7.1
func SaveInfo(r *http.Request, w http.ResponseWriter, accessToken string, information *Information) error
func SaveValue ¶
func SaveValue(r *http.Request, w http.ResponseWriter, cookieName, postfix, sessionKey string, redirect *Setting, sessionStore store.SessionStore, value []byte) error
SaveValue save the cookie/session.
func SetRedirect ¶
func SetRedirect(r *http.Request, redirect *Setting, rValue RedirectValue) error
SetRedirect set to request path and query params.
Types ¶
type Info ¶ added in v0.7.1
type Info struct { Roles []string `json:"roles,omitempty"` Scopes []string `json:"scopes,omitempty"` Map map[string]interface{} `json:"map,omitempty"` Custom map[string]interface{} `json:"custom,omitempty"` }
Info is use to store some information about token.
type Information ¶ added in v0.7.1
type Information struct { // InformationCookie is use to store some information about token. // - CookieName required want to use this cookie. // - Store as json. Cookie InformationCookie `cfg:"cookie"` }
type InformationCookie ¶ added in v0.7.1
type InformationCookie struct { // Name is the name of the cookie, required want to use this cookie. Name string `cfg:"name"` MaxAge int `cfg:"max_age"` Path string `cfg:"path"` Domain string `cfg:"domain"` Secure bool `cfg:"secure"` SameSite http.SameSite `cfg:"same_site"` // HttpOnly for true for not accessible by JavaScript. Default is false. HttpOnly bool `cfg:"http_only"` // Map list to store in the cookie like "preferred_username", "given_name", "family_name", "sid", "azp", "aud" Map []string `cfg:"values"` // Custom map to store in the cookie. Custom map[string]interface{} `cfg:"custom"` // Roles to store in the cookie as []string. Roles bool `cfg:"roles"` // Scopes to store in the cookie as []string. Scopes bool `cfg:"scopes"` }
func (*InformationCookie) MapConfigCookie ¶ added in v0.7.1
func (r *InformationCookie) MapConfigCookie() store.Config
type RedirectMatch ¶ added in v0.7.1
type RedirectValue ¶
type RedirectValue struct { Path string `json:"path,omitempty"` Query string `json:"query,omitempty"` State string `json:"state,omitempty"` }
func LoadRedirect ¶
func LoadRedirect(r *http.Request, w http.ResponseWriter, cookieName string, redirect *Setting, sessionStore store.SessionStore) (RedirectValue, error)
func SaveRedirect ¶
func SaveRedirect(r *http.Request, w http.ResponseWriter, cookieName string, redirect *Setting, sessionStore store.SessionStore) (RedirectValue, error)
func (*RedirectValue) Marshal ¶
func (t *RedirectValue) Marshal() ([]byte, error)
func (*RedirectValue) Unmarshal ¶
func (t *RedirectValue) Unmarshal(data []byte) error
type RegexMatch ¶ added in v0.7.1
type RegexMatch struct { Regex string `cfg:"regex"` // contains filtered or unexported fields }
type Setting ¶
type Setting struct { AuthURL string `cfg:"-"` TokenURL string `cfg:"-"` LogoutURL string `cfg:"-"` ClientID string `cfg:"-"` ClientSecret string `cfg:"-"` Scopes []string `cfg:"-"` // CookieName is the name of the cookie. Default is "auth_" + ClientID. CookieName string `cfg:"cookie_name"` // MaxAge the number of seconds until the cookie expires. MaxAge int `cfg:"max_age"` // Path that must exist in the requested URL for the browser to send the Cookie header. Path string `cfg:"path"` // Domain for defines the host to which the cookie will be sent. Domain string `cfg:"domain"` // Secure to cookie only sent over HTTPS. Secure bool `cfg:"secure"` // SameSite for Lax 2, Strict 3, None 4. SameSite http.SameSite `cfg:"same_site"` // HttpOnly for true for not accessible by JavaScript. HttpOnly bool `cfg:"http_only"` // DisableRawQueryEmpty for not making empty of the RawQuery before send code token grant. DisableRawQueryEmpty bool `cfg:"disable_raw_query_empty"` // Callback is the callback URI. Callback string `cfg:"callback"` // CallbackSet for setting back original path. CallbackSet bool `cfg:"callback_set"` // CallbackModify for modify the callback URI, for multiple regex using the first match. CallbackModify []RegexPath `cfg:"callback_modify"` // BaseURL is the base URL to use for the redirect. // Default is the request Host with checking the X-Forwarded-Host header. BaseURL string `cfg:"base_url"` // Schema is the default schema to use for the redirect if no schema is provided. // Default is the https schema. Schema string `cfg:"schema"` RedirectMatch RedirectMatch `cfg:"redirect_match"` // UseSession is use session instead of cookie. UseSession bool `cfg:"use_session"` // SessionKey secret key for session, if shared with other applications, use a static string, default is random. SessionKey string `cfg:"session_key"` // SessionPath is the path to store the session, os.TempDir() is the default. SessionPath string `cfg:"session_path"` // SessionStoreName is the name store for session. // Use Store.GetSessionFilesystem to get the store. SessionStoreName string `cfg:"session_store_name"` // TokenHeader to add token to header. TokenHeader bool `cfg:"token_header"` // RefreshToken is use to refresh the token. RefreshToken bool `cfg:"refresh_token"` CheckAgent bool `cfg:"check_agent"` // CheckAgentContains for check agent extra settings, default is related with implementation, usually is "Mozilla". CheckAgentContains string `cfg:"check_agent_contains"` // Information is use to store some information about token. Information Information `cfg:"information"` // Logout usable with "openid" scope. Logout Logout `cfg:"logout"` Client *http.Client `cfg:"-"` }
func (*Setting) MapConfigCookie ¶
Click to show internal directories.
Click to hide internal directories.