Documentation ¶
Overview ¶
source: golang.org/x/oauth2
Index ¶
- Constants
- func ContextClient(ctx context.Context) *http.Client
- func NewService(ctx context.Context, logger log.Logger, cfg Config, ...) (*service, error)
- func RefreshToken(ctx context.Context, conf *oauth2.Config, refreshToken string) (*oauth2.Token, error)
- func ResetAuthCache()
- func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string, v url.Values, ...) (*oauth2.Token, error)
- func UnauthorizedError(rctx *routing.Context, message string) routing.HTTPError
- type AuthStyle
- type Config
- type ContextKey
- type DefaultAccountSettings
- type RetrieveError
- type Service
- type Token
- type TokenRepository
- type UserService
Constants ¶
const (
URI_RefreshToken = "/api/login/oauth/refresh_token"
)
Variables ¶
This section is empty.
Functions ¶
func NewService ¶
func NewService(ctx context.Context, logger log.Logger, cfg Config, tokenRepository TokenRepository, sessionRepository session.Repository, userService user.IService, langFinder text_lang.LangFinder) (*service, error)
NewService creates a new authentication service.
func RefreshToken ¶
func RefreshToken(ctx context.Context, conf *oauth2.Config, refreshToken string) (*oauth2.Token, error)
WARNING: Token is not safe for concurrent access, as it updates the tokenRefresher's refreshToken field. Within this package, it is used by reuseTokenSource which synchronizes calls to this method with its own mutex.
func ResetAuthCache ¶
func ResetAuthCache()
ResetAuthCache resets the global authentication style cache used for AuthStyleUnknown token requests.
func RetrieveToken ¶
Types ¶
type AuthStyle ¶
type AuthStyle int
AuthStyle is a copy of the golang.org/x/oauth2 package's AuthStyle type.
type Config ¶
type Config struct { SignInRedirectURL string JWTSigningKey string JWTExpirationInHours uint SessionlifeTimeInHours uint DefaultAccountSettings DefaultAccountSettings }
type ContextKey ¶
type ContextKey struct{}
ContextKey is just an empty struct. It exists so HTTPClient can be an immutable public variable with a unique type. It's immutable because nobody else can create a ContextKey, being unexported.
var HTTPClient ContextKey
HTTPClient is the context key to use with golang.org/x/net/context's WithValue function to associate an *http.Client value with a context.
type DefaultAccountSettings ¶
type DefaultAccountSettings struct {
Lang string
}
type RetrieveError ¶
func (*RetrieveError) Error ¶
func (r *RetrieveError) Error() string
type Service ¶
type Service interface { //GetSignUpUrl() string //GetSignInUrl() string //GetForgetUrl() string //GetSession(ctx context.Context) *session.Session //SessionInit(ctx context.Context, token string, sessionID string, accountSettings *account.AccountSettings) (context.Context, error) //UpdateSession(ctx context.Context, sess *session.Session) (context.Context, *session.Session, error) //AccountSettingsUpdate(ctx context.Context, accountSettings *account.AccountSettings) (context.Context, error) //AccountUpdate(ctx context.Context, sess *session.Session) (context.Context, error) //SignIn(ctx context.Context, code, state string, accountSettings *account.AccountSettings) (context.Context, error) //StringTokenValidation(ctx context.Context, stringToken string) error //RoutingGetAccountSettingsWithDefaults(rctx *routing.Context) (*account.AccountSettings, error) //CheckAuthMiddleware(rctx *routing.Context) error //CreateUnauthSession(ctx context.Context, accountSettings *account.AccountSettings) (*session.Session, error) GetSession(ctx context.Context) (*session.Session, error) MiddlewareCheckAuth() routing.Handler MiddlewareSessionInit() routing.Handler SignInTg(ctx context.Context, account *tg_account.TgAccount, langID uint) (accessToken string, err error) }
Service encapsulates the authentication logic.
type TokenRepository ¶
type UserService ¶
type UserService interface { }