server

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2016 License: Apache-2.0 Imports: 7 Imported by: 147

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientBasicHandler

func ClientBasicHandler(r *http.Request) (clientID, clientSecret string, err error)

ClientBasicHandler Get client data from basic authorization

func ClientFormHandler

func ClientFormHandler(r *http.Request) (clientID, clientSecret string, err error)

ClientFormHandler Get client data from form

Types

type AuthorizeRequest

type AuthorizeRequest struct {
	ResponseType oauth2.ResponseType
	ClientID     string
	Scope        string
	RedirectURI  string
	State        string
	UserID       string
}

AuthorizeRequest The authorization request

type ClientAuthorizedHandler

type ClientAuthorizedHandler func(clientID string, grantType oauth2.GrantType) (allowed bool, err error)

ClientAuthorizedHandler Check the client allows to use this authorization grant type

type ClientInfoHandler

type ClientInfoHandler func(r *http.Request) (clientID, clientSecret string, err error)

ClientInfoHandler Get client info from request

type ClientScopeHandler

type ClientScopeHandler func(clientID, scope string) (allowed bool, err error)

ClientScopeHandler Check the client allows to use scope

type Config

type Config struct {
	TokenType            string                // TokenType token type(Default is Bearer)
	AllowedResponseTypes []oauth2.ResponseType // Allow the authorization type(Default is all)
	AllowedGrantTypes    []oauth2.GrantType    // Allow the grant type(Default is all)
}

Config Configuration parameters

func NewConfig

func NewConfig() *Config

NewConfig Create to configuration instance

type ErrorHandler

type ErrorHandler func(err error)

ErrorHandler Error handling

type PasswordAuthorizationHandler

type PasswordAuthorizationHandler func(username, password string) (userID string, err error)

PasswordAuthorizationHandler Get user id from username and password

type RefreshingScopeHandler

type RefreshingScopeHandler func(newScope, oldScope string) (allowed bool)

RefreshingScopeHandler Check the scope of the refreshing token

type Server

type Server struct {
	Config                       *Config
	Manager                      oauth2.Manager
	ClientInfoHandler            ClientInfoHandler
	ClientAuthorizedHandler      ClientAuthorizedHandler
	ClientScopeHandler           ClientScopeHandler
	UserAuthorizationHandler     UserAuthorizationHandler
	PasswordAuthorizationHandler PasswordAuthorizationHandler
	RefreshingScopeHandler       RefreshingScopeHandler
	ErrorHandler                 ErrorHandler
}

Server Provide authorization server

func NewServer

func NewServer(cfg *Config, manager oauth2.Manager) *Server

NewServer Create to authorization server instance

func (*Server) CheckGrantType

func (s *Server) CheckGrantType(gt oauth2.GrantType) bool

CheckGrantType Check allows grant type

func (*Server) CheckResponseType

func (s *Server) CheckResponseType(rt oauth2.ResponseType) bool

CheckResponseType Check allows response type

func (*Server) GetAccessToken

func (s *Server) GetAccessToken(gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest) (ti oauth2.TokenInfo, rerr, ierr error)

GetAccessToken Get access token

func (*Server) GetAuthorizeData

func (s *Server) GetAuthorizeData(rt oauth2.ResponseType, ti oauth2.TokenInfo) (data map[string]interface{})

GetAuthorizeData Get authorization response data

func (*Server) GetAuthorizeToken

func (s *Server) GetAuthorizeToken(req *AuthorizeRequest) (ti oauth2.TokenInfo, rerr, ierr error)

GetAuthorizeToken Get authorization token(code)

func (*Server) GetErrorData

func (s *Server) GetErrorData(rerr, ierr error) (data map[string]interface{})

GetErrorData Get error response data

func (*Server) GetRedirectURI

func (s *Server) GetRedirectURI(req *AuthorizeRequest, data map[string]interface{}) (uri string, err error)

GetRedirectURI Get redirect uri

func (*Server) GetTokenData

func (s *Server) GetTokenData(ti oauth2.TokenInfo) (data map[string]interface{})

GetTokenData Get token data

func (*Server) HandleAuthorizeRequest

func (s *Server) HandleAuthorizeRequest(w http.ResponseWriter, r *http.Request) (err error)

HandleAuthorizeRequest The authorization request handling

func (*Server) HandleTokenRequest

func (s *Server) HandleTokenRequest(w http.ResponseWriter, r *http.Request) (err error)

HandleTokenRequest The token request handling

func (*Server) SetAllowedGrantType

func (s *Server) SetAllowedGrantType(types ...oauth2.GrantType)

SetAllowedGrantType Allow the grant types

func (*Server) SetAllowedResponseType

func (s *Server) SetAllowedResponseType(types ...oauth2.ResponseType)

SetAllowedResponseType Allow the authorization types

func (*Server) SetClientAuthorizedHandler

func (s *Server) SetClientAuthorizedHandler(handler ClientAuthorizedHandler)

SetClientAuthorizedHandler Check the client allows to use this authorization grant type

func (*Server) SetClientInfoHandler

func (s *Server) SetClientInfoHandler(handler ClientInfoHandler)

SetClientInfoHandler Get client info from request

func (*Server) SetClientScopeHandler

func (s *Server) SetClientScopeHandler(handler ClientScopeHandler)

SetClientScopeHandler Check the client allows to use scope

func (*Server) SetErrorHandler

func (s *Server) SetErrorHandler(handler ErrorHandler)

SetErrorHandler Error handling

func (*Server) SetPasswordAuthorizationHandler

func (s *Server) SetPasswordAuthorizationHandler(handler PasswordAuthorizationHandler)

SetPasswordAuthorizationHandler Get user id from username and password

func (*Server) SetRefreshingScopeHandler

func (s *Server) SetRefreshingScopeHandler(handler RefreshingScopeHandler)

SetRefreshingScopeHandler Check the scope of the refreshing token

func (*Server) SetUserAuthorizationHandler

func (s *Server) SetUserAuthorizationHandler(handler UserAuthorizationHandler)

SetUserAuthorizationHandler Get user id from request authorization

func (*Server) ValidationAuthorizeRequest

func (s *Server) ValidationAuthorizeRequest(r *http.Request) (req *AuthorizeRequest, rerr, ierr error)

ValidationAuthorizeRequest The authorization request validation

func (*Server) ValidationTokenRequest

func (s *Server) ValidationTokenRequest(r *http.Request) (gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest, rerr, ierr error)

ValidationTokenRequest The token request validation

type UserAuthorizationHandler

type UserAuthorizationHandler func(w http.ResponseWriter, r *http.Request) (userID string, err error)

UserAuthorizationHandler Get user id from request authorization

Jump to

Keyboard shortcuts

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