Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AvatarSaver ¶
AvatarSaver defines minimal interface to save avatar
type CredChecker ¶ added in v0.2.0
CredChecker defines interface to check credentials
type CredCheckerFunc ¶ added in v0.2.0
CredCheckerFunc type is an adapter to allow the use of ordinary functions as CredsChecker.
type DevAuthServer ¶
type DevAuthServer struct { lgr.L Provider Oauth2Handler Automatic bool // contains filtered or unexported fields }
DevAuthServer is a fake oauth server for development it provides stand-alone server running on its own port and pretending to be the real oauth2. It also provides Dev Provider the same way as normal providers do, i.e. like github, google and others. can run in interactive and non-interactive mode. In interactive mode login attempts will show login form to select desired user name, this is the mode used for development. Non-interactive mode for tests only.
func (*DevAuthServer) Run ¶
func (d *DevAuthServer) Run(ctx context.Context)
Run oauth2 dev server on port devAuthPort
type DirectHandler ¶ added in v0.2.0
type DirectHandler struct { lgr.L CredChecker CredChecker ProviderName string TokenService TokenService Issuer string }
DirectHandler implements non-oauth2 provider authorizing user in traditional way with storage with users and hashes
func (DirectHandler) AuthHandler ¶ added in v0.2.0
func (p DirectHandler) AuthHandler(w http.ResponseWriter, r *http.Request)
AuthHandler doesn't do anything for direct login as it has no callbacks
func (DirectHandler) LoginHandler ¶ added in v0.2.0
func (p DirectHandler) LoginHandler(w http.ResponseWriter, r *http.Request)
LoginHandler checks "user" and "passwd" against data store and makes jwt if all passed GET /something?user=name&password=xyz&sess=[0|1]
func (DirectHandler) LogoutHandler ¶ added in v0.2.0
func (p DirectHandler) LogoutHandler(w http.ResponseWriter, r *http.Request)
LogoutHandler - GET /logout
func (DirectHandler) Name ¶ added in v0.2.0
func (p DirectHandler) Name() string
Name of the handler
type Oauth2Handler ¶ added in v0.1.1
type Oauth2Handler struct { Params // contains filtered or unexported fields }
Oauth2Handler implements /login, /callback and /logout handlers from aouth2 flow
func NewFacebook ¶
func NewFacebook(p Params) Oauth2Handler
NewFacebook makes facebook oauth2 provider
func (Oauth2Handler) AuthHandler ¶ added in v0.1.1
func (p Oauth2Handler) AuthHandler(w http.ResponseWriter, r *http.Request)
AuthHandler fills user info and redirects to "from" url. This is callback url redirected locally by browser GET /callback
func (Oauth2Handler) LoginHandler ¶ added in v0.1.1
func (p Oauth2Handler) LoginHandler(w http.ResponseWriter, r *http.Request)
LoginHandler - GET /login?from=redirect-back-url&site=siteID&session=1
func (Oauth2Handler) LogoutHandler ¶ added in v0.1.1
func (p Oauth2Handler) LogoutHandler(w http.ResponseWriter, r *http.Request)
LogoutHandler - GET /logout
func (Oauth2Handler) Name ¶ added in v0.1.1
func (p Oauth2Handler) Name() string
Name returns provider name
type Params ¶
type Params struct { lgr.L URL string JwtService TokenService Cid string Csecret string Issuer string AvatarSaver AvatarSaver }
Params to make initialized and ready to use provider
type Provider ¶ added in v0.1.1
type Provider interface { Name() string LoginHandler(w http.ResponseWriter, r *http.Request) AuthHandler(w http.ResponseWriter, r *http.Request) LogoutHandler(w http.ResponseWriter, r *http.Request) }
Provider defines interface for auth handler
type Service ¶
type Service struct {
Provider
}
Service represents oauth2 provider. Adds Handler method multiplexing login, auth and logout requests
func NewService ¶ added in v0.1.1
NewService makes service for given provider
type TokenService ¶
type TokenService interface { Parse(tokenString string) (claims token.Claims, err error) Set(w http.ResponseWriter, claims token.Claims) (token.Claims, error) Get(r *http.Request) (claims token.Claims, token string, err error) Reset(w http.ResponseWriter) }
TokenService defines interface accessing tokens