Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrForbidden = errors.New("shogo82148/go-nginx-oauth2-adapter/provider: access forbidden")
ErrForbidden is the error which the access is forbidden.
View Source
var ErrProviderConfigNotFound = errors.New("shogo82148/go-nginx-oauth2-adapter: provider configure not found")
ErrProviderConfigNotFound is the error which provider configure is not found.
Functions ¶
func LoggingHandler ¶
LoggingHandler logs HTTP requests.
func RegisterProvider ¶
RegisterProvider registers the OAuth provider.
Types ¶
type Config ¶
type Config struct { Address string `yaml:"address" json:"address"` Secrets []*string `yaml:"secrets" json:"secrets"` SessionName string `yaml:"session_name" json:"session_name"` Providers map[string]map[string]interface{} `yaml:"providers" json:"providers"` AppRefreshInterval string `yaml:"app_refresh_interval" json:"app_refresh_interval"` // set with -configtest option. ConfigTest bool `yaml:"-" json:"-"` // Fields are a subset of http.Cookie fields. Cookie *CookieConfig `yaml:"cookie" json:"cookie"` }
Config is a configration for go-nginx-oauth2-adapter.
type CookieConfig ¶
type CookieConfig struct { Path string `yaml:"path" json:"path"` Domain string `yaml:"domain" json:"domain"` // MaxAge=0 means no 'Max-Age' attribute specified. // MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'. // MaxAge>0 means Max-Age attribute present and given in seconds. MaxAge int `yaml:"max_age" json:"max_age"` Secure bool `yaml:"secure" json:"secure"` HTTPOnly bool `yaml:"http_only" json:"http_only"` SameSite string `yaml:"same_site" json:"same_site"` }
CookieConfig is a configration for the cookie of HTTP.
type Provider ¶
type Provider interface {
ParseConfig(configFile map[string]interface{}) (ProviderConfig, error)
}
Provider is an OAuth provider.
type ProviderConfig ¶
type ProviderConfig interface { Config() oauth2.Config Info(c *oauth2.Config, t *oauth2.Token) (string, map[string]interface{}, error) }
ProviderConfig is a config for an OAuth provider.
type ProviderInfoContext ¶ added in v0.3.0
type ProviderInfoContext interface {
InfoContext(ctx context.Context, c *oauth2.Config, t *oauth2.Token) (string, map[string]interface{}, error)
}
ProviderInfoContext is for support context.Context.
type Server ¶
type Server struct { Config Config DefaultProvider string ProviderConfigs map[string]ProviderConfig SessionStore sessions.Store AppRefreshInterval time.Duration }
Server is the go-nginx-oauth2-adapter server.
func (*Server) HandlerCallback ¶
func (s *Server) HandlerCallback(w http.ResponseWriter, r *http.Request)
HandlerCallback validates the user infomation, set to cookie
func (*Server) HandlerInitiate ¶
func (s *Server) HandlerInitiate(w http.ResponseWriter, r *http.Request)
HandlerInitiate redirects to authorization page.
func (*Server) HandlerTest ¶
func (s *Server) HandlerTest(w http.ResponseWriter, r *http.Request)
HandlerTest validates the session.
Click to show internal directories.
Click to hide internal directories.