Documentation
¶
Index ¶
- Constants
- Variables
- type Authenticator
- func (a *Authenticator) CallbackHandler(res http.ResponseWriter, req *http.Request)
- func (a *Authenticator) LoginHandler(res http.ResponseWriter, req *http.Request)
- func (a *Authenticator) RequireJWTCookie(w http.ResponseWriter, r *http.Request) (*jwt.Token, error)
- func (a *Authenticator) WhoAmIHandler(res http.ResponseWriter, req *http.Request)
- type Config
- type GithubAccessTokenRequest
- type GithubAccessTokenResponse
- type GithubData
- type GithubUserResponse
- type User
Constants ¶
View Source
const (
SCOPES = "read:user,user:email"
)
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
func NewAuthenticator ¶
func NewAuthenticator(config *Config) *Authenticator
func (*Authenticator) CallbackHandler ¶
func (a *Authenticator) CallbackHandler(res http.ResponseWriter, req *http.Request)
CallbackHandler handles the OAuth callback, obtaining the GitHub's Bearer token for the logged-in user, and generating a wrapper JWT for our upld session.
func (*Authenticator) LoginHandler ¶
func (a *Authenticator) LoginHandler(res http.ResponseWriter, req *http.Request)
LoginHandler handles login requests, redirecting the web client to GitHub's first stage for the OAuth flow, where the user has to grant access to the specified scopes
func (*Authenticator) RequireJWTCookie ¶
func (a *Authenticator) RequireJWTCookie(w http.ResponseWriter, r *http.Request) (*jwt.Token, error)
func (*Authenticator) WhoAmIHandler ¶
func (a *Authenticator) WhoAmIHandler(res http.ResponseWriter, req *http.Request)
type Config ¶
type Config struct {
ClientID string // The OAuth client ID
ClientSecret string // The OAuth client secret
BaseURL *url.URL // The base URL from where cartabinaria/upld is being served from
SigningKey []byte // The key to sign the JWTs with
Expiration time.Duration // How long should user sessions last?
}
type GithubAccessTokenRequest ¶
type GithubAccessTokenRequest struct {
ClientId string `json:"client_id"`
ClientSecret string `json:"client_secret"`
Code string `json:"code"`
}
GithubAccessTokenRequest is the request we send to GitHub to request for a token
type GithubAccessTokenResponse ¶
type GithubAccessTokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
Scope string `json:"scope"`
}
GithubAccessTokenResponse is the response received from GitHub when requesting for a token
type GithubData ¶
type GithubData struct {
// contains filtered or unexported fields
}
type GithubUserResponse ¶
Click to show internal directories.
Click to hide internal directories.