Documentation
¶
Index ¶
Constants ¶
View Source
const Version = "0.2.0"
Version is the version of go-nginx-oauth2-adapter.
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"`
// 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"`
}
CookieConfig is a configration for the cookie of HTTP.
func (*CookieConfig) Options ¶
func (c *CookieConfig) Options() *sessions.Options
Options returns the sesseion config.
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 Server ¶
type Server struct {
Config Config
DefaultPrivider 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.