Versions in this module Expand all Collapse all v5 v5.0.0 Sep 11, 2021 Changes in this version + const ErrorStringCannotGetPermission + const ErrorStringCannotIntrospectToken + const ErrorStringFailedToExchangeAuthorizationCode + const ErrorStringInvalidState + const ErrorStringUnableToSetCookie + const ErrorStringUnauthorized + const PermissionExpireTime + const SessionExpireTime + var ErrorInvalidAuthorizationSyntax = errors.New("invalid authorization syntax") + var ErrorInvalidClientID = errors.New("invalid client ID (audience of token)") + var ErrorInvalidSession = errors.New("invalid session") + var ErrorInvalidUserID = errors.New("invalid user ID (subject of token)") + var ErrorUnsupportedAuthorizationScheme = errors.New("unsupported authorization scheme") + func AttachRequestWithSessionData(r *http.Request, sessionData *AuthSessionData) *http.Request + func CompareErrorMessage(err error, msg string) bool + func WrapError(msg string, err error) error + type AuthSessionCookieData struct + Permissions StringSet + PermissionsExpiresAt time.Time + Token *oauth2.Token + func (cookieData *AuthSessionCookieData) GetPermissions() []string + func (cookieData *AuthSessionCookieData) HasPermission(permission string) bool + type AuthSessionData struct + ClientID string + UserID string + func GetRequestSessionData(r *http.Request) (*AuthSessionData, bool) + func (data *AuthSessionData) GetClientID() string + func (data *AuthSessionData) GetUserID() string + type CookieConfig struct + AuthenticationKey string + EncryptionKey string + type GetPermissionsFunc func(ctx context.Context, userID string, clientID string, token *oauth2.Token) (permissions []string, err error) + type IntrospectTokenFunc func(ctx context.Context, accessToken string) (userID string, clientID string, expiresAt int64, extra map[string]interface{}, ...) + type OAuthConfig struct + AppIDList []string + AuthURL string + ClientID string + ClientSecret string + Scopes []string + TokenURL string + type OAuthSession struct + func NewOAuthSession(name string, cookieConf *CookieConfig, oauthConf *OAuthConfig, ...) *OAuthSession + func (s *OAuthSession) Authorize(w http.ResponseWriter, r *http.Request) (*AuthSessionData, error) + func (s *OAuthSession) CallbackView(w http.ResponseWriter, r *http.Request) + func (s *OAuthSession) ClearSession(w http.ResponseWriter, r *http.Request) error + func (s *OAuthSession) EndOAuth(w http.ResponseWriter, r *http.Request) (string, *oauth2.Token, error) + func (s *OAuthSession) LogOut(redirect string) http.HandlerFunc + func (s *OAuthSession) SecuredF(isAPI bool) func(http.HandlerFunc) http.HandlerFunc + func (s *OAuthSession) SecuredH(isAPI bool) func(http.Handler) http.Handler + func (s *OAuthSession) StartOAuth(w http.ResponseWriter, r *http.Request) error + type StateHandler interface + Generate func(cookieStore *sessions.CookieStore, w http.ResponseWriter, r *http.Request) (state string, err error) + Verify func(cookieStore *sessions.CookieStore, w http.ResponseWriter, r *http.Request, ...) (continueURI string, err error) + type StringSet map[string]struct + func NewStringSet(a []string) StringSet + func (s StringSet) Add(x string) + func (s StringSet) Contain(x string) bool + func (s StringSet) List() []string + func (s StringSet) Remove(x string) + type TokenVerifier struct + GetPermissionsFunc GetPermissionsFunc + IntrospectTokenFunc IntrospectTokenFunc Other modules containing this package github.com/rayark/osecure github.com/rayark/osecure/v3 github.com/rayark/osecure/v4 github.com/rayark/osecure/v6