Documentation ¶
Overview ¶
Package oauth2 contains Negroni middleware to provide user login via an OAuth 2.0 backend.
Index ¶
- Variables
- func Facebook(opts *oauth2.Options) http.Handler
- func GetDb(r *http.Request) dal.Database
- func Github(opts *oauth2.Options) http.Handler
- func Google(opts *oauth2.Options) http.Handler
- func LinkedIn(opts *oauth2.Options) http.Handler
- func LoadEnv()
- func NewOAuth2Provider(opts *oauth2.Options, authUrl, tokenUrl string) http.HandlerFunc
- func Params(req *http.Request) map[string]string
- func SetDb(r *http.Request, val dal.Database)
- func SetRenderer(r *http.Request, val Renderer)
- func SetSession(r *http.Request, val *Session)
- func SetSessionStore(r *http.Request, val SessionStore)
- type Environment
- type Middleware
- type MiddlewareFunc
- type Options
- type Renderer
- type Route
- type Router
- type Server
- type Session
- type SessionStore
- type Tokens
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Path to handle OAuth 2.0 logins. PathLogin = "/login" // Path to handle OAuth 2.0 logouts. PathLogout = "/logout" // Path to handle callback from OAuth 2.0 backend // to exchange credentials. PathCallback = "/oauth2callback" // Path to handle error cases. PathError = "/oauth2error" )
View Source
var ( ErrInvalidId = errors.New("session: invalid session id") ErrInvalidModified = errors.New("mongostore: invalid modified value") )
Functions ¶
func NewOAuth2Provider ¶ added in v0.2.0
func NewOAuth2Provider(opts *oauth2.Options, authUrl, tokenUrl string) http.HandlerFunc
Returns a generic OAuth 2.0 backend endpoint.
func SetRenderer ¶ added in v0.2.0
func SetSession ¶ added in v0.2.0
func SetSessionStore ¶ added in v0.2.0
func SetSessionStore(r *http.Request, val SessionStore)
Types ¶
type Environment ¶
type Middleware ¶
type Middleware interface {
ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
}
func LoginRequired ¶ added in v0.2.0
func LoginRequired() Middleware
Handler that redirects user to the login page if user is not logged in.
type MiddlewareFunc ¶ added in v0.2.0
type MiddlewareFunc func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
func (MiddlewareFunc) ServeHTTP ¶ added in v0.2.0
func (h MiddlewareFunc) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type Renderer ¶
type Renderer interface { XML(w http.ResponseWriter, status int, v interface{}) HTML(w http.ResponseWriter, status int, name string, binding interface{}) }
func GetRenderer ¶ added in v0.2.0
func NewRenderer ¶
func NewRenderer() Renderer
type Router ¶
type Server ¶
type Server interface { Run(port string) Use(handler Middleware) UseHandler(http.Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request) }
type Session ¶ added in v0.2.0
type Session struct { ID string Values map[interface{}]interface{} Options *Options IsNew bool // contains filtered or unexported fields }
func GetSession ¶ added in v0.2.0
type SessionStore ¶ added in v0.2.0
type SessionStore interface { GetSession(r *http.Request, name string) (s *Session, err error) SaveSession(r *http.Request, w http.ResponseWriter, session *Session) error }
func GetSessionStore ¶ added in v0.2.0
func GetSessionStore(r *http.Request) SessionStore
func NewSessionStore ¶ added in v0.2.0
func NewSessionStore(c dal.Collection, maxAge int, ensureTTL bool, keyPairs ...[]byte) SessionStore
NewSessionStore returns a new SessionStore (currently uses default dal implementation) Set ensureTTL to true let the database auto-remove expired object by maxAge.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Godeps
|
|
_workspace/src/github.com/codegangsta/negroni
Package negroni is an idiomatic approach to web middleware in Go.
|
Package negroni is an idiomatic approach to web middleware in Go. |
_workspace/src/github.com/golang/oauth2
Package oauth2 provides support for making OAuth2 authorized and authenticated HTTP requests.
|
Package oauth2 provides support for making OAuth2 authorized and authenticated HTTP requests. |
_workspace/src/github.com/golang/oauth2/google
Package google provides support for making OAuth2 authorized and authenticated HTTP requests to Google APIs.
|
Package google provides support for making OAuth2 authorized and authenticated HTTP requests to Google APIs. |
_workspace/src/github.com/golang/oauth2/jws
Package jws provides encoding and decoding utilities for signed JWS messages.
|
Package jws provides encoding and decoding utilities for signed JWS messages. |
_workspace/src/github.com/gorilla/context
Package context stores values shared during a request lifetime.
|
Package context stores values shared during a request lifetime. |
_workspace/src/github.com/gorilla/mux
Package gorilla/mux implements a request router and dispatcher.
|
Package gorilla/mux implements a request router and dispatcher. |
_workspace/src/github.com/gorilla/securecookie
Package gorilla/securecookie encodes and decodes authenticated and optionally encrypted cookie values.
|
Package gorilla/securecookie encodes and decodes authenticated and optionally encrypted cookie values. |
_workspace/src/github.com/gorilla/sessions
Package gorilla/sessions provides cookie and filesystem sessions and infrastructure for custom session backends.
|
Package gorilla/sessions provides cookie and filesystem sessions and infrastructure for custom session backends. |
_workspace/src/github.com/joho/godotenv
A go port of the ruby dotenv library (https://github.com/bkeepers/dotenv) Examples/readme can be found on the github page at https://github.com/joho/godotenv The TL;DR is that you make a .env file that looks something like SOME_ENV_VAR=somevalue and then in your go code you can call godotenv.Load() and all the env vars declared in .env will be avaiable through os.Getenv("SOME_ENV_VAR")
|
A go port of the ruby dotenv library (https://github.com/bkeepers/dotenv) Examples/readme can be found on the github page at https://github.com/joho/godotenv The TL;DR is that you make a .env file that looks something like SOME_ENV_VAR=somevalue and then in your go code you can call godotenv.Load() and all the env vars declared in .env will be avaiable through os.Getenv("SOME_ENV_VAR") |
_workspace/src/labix.org/v2/mgo
Package mgo offers a rich MongoDB driver for Go.
|
Package mgo offers a rich MongoDB driver for Go. |
_workspace/src/labix.org/v2/mgo/bson
Package bson is an implementation of the BSON specification for Go: http://bsonspec.org It was created as part of the mgo MongoDB driver for Go, but is standalone and may be used on its own without the driver.
|
Package bson is an implementation of the BSON specification for Go: http://bsonspec.org It was created as part of the mgo MongoDB driver for Go, but is standalone and may be used on its own without the driver. |
_workspace/src/labix.org/v2/mgo/sasl
Package sasl is an implementation detail of the mgo package.
|
Package sasl is an implementation detail of the mgo package. |
_workspace/src/labix.org/v2/mgo/txn
The txn package implements support for multi-document transactions.
|
The txn package implements support for multi-document transactions. |
Click to show internal directories.
Click to hide internal directories.