auth

package
v0.0.0-...-b3fb872 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSignedOut

func IsSignedOut(ctx context.Context, token string) bool

func SetUpJWT

func SetUpJWT(secret string, provider func(r *http.Request) (string, []string, error), expiration int) error

func Sign

func Sign(r *http.Request, subject string) (string, error)

func SignOut

func SignOut(ctx context.Context, token string) bool

func SigninEmail

func SigninEmail(r *http.Request, email string, password string) (string, *errors.VironError)

SigninEmail Emailアドレスでサインイン

func VerifyToken

func VerifyToken(token string) (jwxJwt.Token, error)

Types

type Auth

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

func New

func New(multipleAuthUser *bool, google *config.GoogleOAuth2, oidcConfig *config.OIDC, providerFactory OIDCProviderFactory) *Auth

New Auth初期化

func (*Auth) GenGoogleOAuth2AuthorizationUrl

func (a *Auth) GenGoogleOAuth2AuthorizationUrl(clientID string, redirectUrl string, codeVerifier string, state string) string

GenGoogleOAuth2AuthorizationUrlIDC Authorization URL生成

func (*Auth) GenGoogleOAuth2CodeVerifier

func (a *Auth) GenGoogleOAuth2CodeVerifier(clientID string) string

GenGoogleOAuth2CodeVerifier Code Verifier生成

func (*Auth) GenOIDCAuthorizationUrl

func (a *Auth) GenOIDCAuthorizationUrl(clientID string, redirectUrl string, codeVerifier string, state string) string

GenOIDCAuthorizationUrl Authorization URL生成

func (*Auth) GenOIDCCodeVerifier

func (a *Auth) GenOIDCCodeVerifier(clientID string) string

GenOIDCCodeVerifier Code Verifier生成

func (*Auth) SigninGoogleOAuth2

func (a *Auth) SigninGoogleOAuth2(r *http.Request, clientID string, redirectUrl string, code string, state string, codeVerifier string) (string, *errors.VironError)

SigninGoogleOAuth2

func (*Auth) SigninOIDC

func (a *Auth) SigninOIDC(r *http.Request, clientID string, redirectUrl string, code string, state string, codeVerifier string) (string, *errors.VironError)

SigninOIDC

func (*Auth) VerifyAccessToken

func (a *Auth) VerifyAccessToken(r *http.Request, clientID string, userID string, user domains.AdminUser) bool

VerifyAccessToken SSOトークン検証

type AuthOIDC

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

type Claim

type Claim struct {
	Exp int
	Iat int
	Nbf int
	Sub string
	Iss string
	Aud []string
}

func Verify

func Verify(r *http.Request, token string) (*Claim, error)

type OAuthProvider

type OAuthProvider interface {
	AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
	Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
	TokenSource(ctx context.Context, token *oauth2.Token) oauth2.TokenSource
}

OAuthProvider インターフェース

type OAuthProviderImpl

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

OAuth2Provider の具体的な実装

func (*OAuthProviderImpl) AuthCodeURL

func (m *OAuthProviderImpl) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string

AuthCodeURL OAuth2ProviderのAuthCodeURL

func (*OAuthProviderImpl) Exchange

func (m *OAuthProviderImpl) Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)

Exchange OAuth2ProviderのExchange

func (*OAuthProviderImpl) TokenSource

func (m *OAuthProviderImpl) TokenSource(ctx context.Context, token *oauth2.Token) oauth2.TokenSource

TokenSource OAuth2ProviderのTokenSource

type OIDCProvider

type OIDCProvider interface {
	Verifier(config *oidc.Config) *oidc.IDTokenVerifier
	Endpoint() oauth2.Endpoint
}

OIDCProvider インターフェース

type OIDCProviderFactory

type OIDCProviderFactory interface {
	NewProvider(ctx context.Context, issuer string) *oidc.Provider
}

OIDCProviderFactory は OIDC のプロバイダーを作成するためのインターフェース

type OIDCProviderFactoryImpl

type OIDCProviderFactoryImpl struct{}

OIDCProviderFactoryImpl は本番環境用の実装

func (*OIDCProviderFactoryImpl) NewProvider

func (f *OIDCProviderFactoryImpl) NewProvider(ctx context.Context, issuer string) *oidc.Provider

NewProvider は実際の oidc.NewProvider を呼び出す

type OIDCProviderImpl

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

OIDCProvider の具体的な実装

func (*OIDCProviderImpl) Endpoint

func (m *OIDCProviderImpl) Endpoint() oauth2.Endpoint

Endpoint OIDCProviderのエンドポイント取得

func (*OIDCProviderImpl) Verifier

func (m *OIDCProviderImpl) Verifier(config *oidc.Config) *oidc.IDTokenVerifier

Verifier OIDCProviderのIDトークン検証機取得

Jump to

Keyboard shortcuts

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