oauth

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoogleOAuthProvider

type GoogleOAuthProvider struct {
	Config *oauth2.Config
}

func NewGoogleOAuthProvider

func NewGoogleOAuthProvider(clientID string, clientSecret string, redirectURL string, scopes []string) *GoogleOAuthProvider

func (*GoogleOAuthProvider) ExchangeCodeForToken

func (p *GoogleOAuthProvider) ExchangeCodeForToken(code string, state string) (*oauth2.Token, error)

func (*GoogleOAuthProvider) GetAuthorizationURL

func (p *GoogleOAuthProvider) GetAuthorizationURL(state string) string

func (*GoogleOAuthProvider) GetUserInfo

func (p *GoogleOAuthProvider) GetUserInfo(token *oauth2.Token) (interface{}, error)

type GoogleUserInfo

type GoogleUserInfo struct {
	Sub       string `json:"sub"`
	Email     string `json:"email"`
	Name      string `json:"name"`
	Picture   string `json:"picture"`
	Locale    string `json:"locale"`
	ExpiresIn int64  `json:"expires_in"`
}

type KeycloakProvider

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

func NewKeycloakProvider

func NewKeycloakProvider(clientID, clientSecret, redirectURI, authURL, tokenURL, userinfoURL string) *KeycloakProvider

func (*KeycloakProvider) ExchangeCodeForToken

func (kp *KeycloakProvider) ExchangeCodeForToken(code string, state string) (*oauth2.Token, error)

func (*KeycloakProvider) GetAuthorizationURL

func (kp *KeycloakProvider) GetAuthorizationURL(state string) string

func (*KeycloakProvider) GetUserInfo

func (kp *KeycloakProvider) GetUserInfo(token *oauth2.Token) (interface{}, error)

type OAuthProvider

type OAuthProvider interface {
	// GetAuthorizationURL returns the URL to redirect the user to for authentication
	GetAuthorizationURL(state string) string

	// ExchangeCodeForToken exchanges the authorization code received from the OAuth provider for an access token
	ExchangeCodeForToken(code string, state string) (*oauth2.Token, error)

	// GetUserInfo returns the user information associated with the access token
	GetUserInfo(token *oauth2.Token) (interface{}, error)
}

Jump to

Keyboard shortcuts

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