const RealmType = "github"
RealmType of the Github Realm
type AuthRequest struct { // Optional. The URL to redirect to after authentication. RedirectURL string }
AuthRequest is a request for authenticating with github.com
type AuthResponse struct { // The URL to visit to perform OAuth on github.com URL string }
AuthResponse is a response to an AuthRequest.
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 (r *Realm) AuthSession(id, userID, realmID string) types.AuthSession
AuthSession returns a Github Session for this user
func (r *Realm) ID() string
ID returns the realm ID
func (r *Realm) Init() error
Init does nothing.
func (r *Realm) OnReceiveRedirect(w http.ResponseWriter, req *http.Request)
OnReceiveRedirect processes OAuth redirect requests from Github
func (r *Realm) Register() error
Register does nothing.
func (r *Realm) RequestAuthSession(userID string, 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...." }
func (r *Realm) Type() string
Type is github
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 (s *Session) Authenticated() bool
Authenticated returns true if the user has completed the auth process
func (s *Session) ID() string
ID returns the session ID
func (s *Session) Info() interface{}
Info returns a list of possible repositories that this session can integrate with.
func (s *Session) RealmID() string
RealmID returns the realm ID of the realm which performed the authentication
func (s *Session) UserID() string
UserID returns the user_id who authorised with Github