Documentation
¶
Overview ¶
Package elogin provides auth middle procedures for remote authentication including oauth2 and other protocols, and specific providers like google, facebook, etc.
Index ¶
- Variables
- type AuthAccessor
- type AuthHTTPWrapper
- func (wr *AuthHTTPWrapper) Callback(w http.ResponseWriter, r *http.Request)
- func (wr *AuthHTTPWrapper) HandleWrapper(prefix string) http.Handler
- func (wr *AuthHTTPWrapper) Login(w http.ResponseWriter, r *http.Request)
- func (wr *AuthHTTPWrapper) Protocol() string
- func (wr *AuthHTTPWrapper) Provider() string
- type ErrorHandler
- type RedirectParamsExtractor
- type SuccessHandler
- type Token
- type URLParam
- type UserData
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrInvalidState = errors.New("invalid state")
)
Functions ¶
This section is empty.
Types ¶
type AuthAccessor ¶
type AuthHTTPWrapper ¶
type AuthHTTPWrapper struct {
Auth AuthAccessor
Error ErrorHandler
Success SuccessHandler
RedirectParams RedirectParamsExtractor
}
AuthHTTPWrapper provides a wrapper for auth authentication
func NewWrapper ¶
func NewWrapper(auth AuthAccessor, err ErrorHandler, success SuccessHandler, redirectParams RedirectParamsExtractor) *AuthHTTPWrapper
NewWrapper creates a new instance of AuthHTTPWrapper
func (*AuthHTTPWrapper) Callback ¶
func (wr *AuthHTTPWrapper) Callback(w http.ResponseWriter, r *http.Request)
Callback handles the callback request
func (*AuthHTTPWrapper) HandleWrapper ¶
func (wr *AuthHTTPWrapper) HandleWrapper(prefix string) http.Handler
HandleWrapper returns the http handler which handles the auth authentication
func (*AuthHTTPWrapper) Login ¶
func (wr *AuthHTTPWrapper) Login(w http.ResponseWriter, r *http.Request)
Login handles the login request
func (*AuthHTTPWrapper) Protocol ¶
func (wr *AuthHTTPWrapper) Protocol() string
Protocol returns the protocol name
func (*AuthHTTPWrapper) Provider ¶
func (wr *AuthHTTPWrapper) Provider() string
Provider returns the provider name
type ErrorHandler ¶
type ErrorHandler interface {
Error(w http.ResponseWriter, r *http.Request, err error)
}
type RedirectParamsExtractor ¶
type SuccessHandler ¶
type Token ¶
type Token struct {
TokenType string `json:"token_type,omitempty"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
Scopes []string `json:"scopes,omitempty"`
}
Token represents the token data
type UserData ¶
type UserData struct {
ID string `json:"id"`
Email string `json:"email"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
Link string `json:"link"`
// Ext is the extra data
Ext map[string]any `json:"ext,omitempty"`
OAuth2conf *oauth2.Config `json:"-"`
}
UserData represents the user data
Source Files
¶
Click to show internal directories.
Click to hide internal directories.