Documentation ¶
Overview ¶
Package oauth2 allows users to be created and authenticated via oauth2 services like facebook, google etc. Currently only the web server flow is supported.
The general flow looks like this:
- User goes to Start handler and has his session packed with goodies then redirects to the OAuth service.
- OAuth service returns to OAuthCallback which extracts state and parameters and generally checks that everything is ok. It uses the token received to get an access token from the oauth2 library
- Calls the OAuth2Provider.FindUserDetails which should return the user's details in a generic form.
- Passes the user details into the OAuth2ServerStorer.NewFromOAuth2 in order to create a user object we can work with.
- Saves the user in the database, logs them in, redirects.
In order to do this there are a number of parts:
- The configuration of a provider (handled by authboss.Config.Modules.OAuth2Providers)
- The flow of redirection of client, parameter passing etc (handled by this package)
- The HTTP call to the service once a token has been retrieved to get user details (handled by OAuth2Provider.FindUserDetails)
- The creation of a user from the user details returned from the FindUserDetails (authboss.OAuth2ServerStorer)
Of these parts, the responsibility of the authboss library consumer is on 1, 3, and 4. Configuration of providers that should be used is totally up to the consumer. The FindUserDetails function is typically up to the user, but we have some basic ones included in this package too. The creation of users from the FindUserDetail's map[string]string return is handled as part of the implementation of the OAuth2ServerStorer.
Index ¶
Constants ¶
const ( FormValueOAuth2State = "state" FormValueOAuth2Redir = "redir" )
FormValue constants
const ( OAuth2UID = "uid" OAuth2Email = "email" OAuth2Name = "name" )
Constants for returning in the FindUserDetails call
Variables ¶
This section is empty.