Documentation
¶
Overview ¶
Package github implements OAuth2 support for github.com
Index ¶
- Constants
- type AuthRequest
- type AuthResponse
- type Realm
- func (r *Realm) AuthSession(id string, userID id.UserID, realmID string) types.AuthSession
- func (r *Realm) ID() string
- func (r *Realm) Init() error
- func (r *Realm) OnReceiveRedirect(w http.ResponseWriter, req *http.Request)
- func (r *Realm) Register() error
- func (r *Realm) RequestAuthSession(userID id.UserID, req json.RawMessage) interface{}
- func (r *Realm) Type() string
- type Session
Constants ¶
const RealmType = "github"
RealmType of the Github Realm
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthRequest ¶
type AuthRequest struct {
// Optional. The URL to redirect to after authentication.
RedirectURL string
}
AuthRequest is a request for authenticating with github.com
type AuthResponse ¶
type AuthResponse struct {
// The URL to visit to perform OAuth on github.com
URL string
}
AuthResponse is a response to an AuthRequest.
type Realm ¶
type Realm struct {
// The client secret for this Github application.
ClientSecret string
// The client ID for this Github application.
ClientID string
// Optional. The URL to redirect the client to after authentication.
StarterLink string
// contains filtered or unexported fields
}
Realm can handle OAuth processes with github.com
Example request:
{
"ClientSecret": "YOUR_CLIENT_SECRET",
"ClientID": "YOUR_CLIENT_ID"
}
func (*Realm) AuthSession ¶
AuthSession returns a Github Session for this user
func (*Realm) OnReceiveRedirect ¶
func (r *Realm) OnReceiveRedirect(w http.ResponseWriter, req *http.Request)
OnReceiveRedirect processes OAuth redirect requests from Github
func (*Realm) RequestAuthSession ¶
func (r *Realm) RequestAuthSession(userID id.UserID, req json.RawMessage) interface{}
RequestAuthSession generates an OAuth2 URL for this user to auth with github via. The request body is of type "github.AuthRequest". The response is of type "github.AuthResponse".
Request example:
{
"RedirectURL": "https://optional-url.com/to/redirect/to/after/auth"
}
Response example:
{
"URL": "https://github.com/login/oauth/authorize?client_id=abcdef&client_secret=acascacac...."
}
type Session ¶
type Session struct {
// AccessToken is the github access token for the user
AccessToken string
// Scopes are the set of *ALLOWED* scopes (which may not be the same as the requested scopes)
Scopes string
// Optional. The client-supplied URL to redirect them to after the auth process is complete.
ClientsRedirectURL string
// contains filtered or unexported fields
}
Session represents an authenticated github session
func (*Session) Authenticated ¶
Authenticated returns true if the user has completed the auth process
func (*Session) Info ¶
func (s *Session) Info() interface{}
Info returns a list of possible repositories that this session can integrate with.