Documentation ¶
Index ¶
- Constants
- Variables
- func Authorize(w http.ResponseWriter, r *http.Request)
- func CodeGrant(w http.ResponseWriter, r *http.Request)
- func CreateClient(w http.ResponseWriter, r *http.Request)
- func Info(w http.ResponseWriter, r *http.Request)
- func RandomString(n int) string
- func RespondWithJson(w http.ResponseWriter, resp interface{}) error
- func Token(w http.ResponseWriter, r *http.Request)
- type Client
- type Code
- type Handler
- type Middleware
- type User
- type UserInfo
Constants ¶
const AUTH_HEADER = "Authorization"
const BEARER_FORMAT = "Bearer %s"
const CLIENT_DURATION = 24 * time.Hour
const CODE_DURATION = 10 * time.Minute
const GCP_SOURCE_DIR = "serverless_function_source_code"
const LOCAL_USERS_FILE = "users.yaml"
const LOGIN_TEMPLATE = "login.tmpl"
const USER_DURATION = 24 * time.Hour
Variables ¶
var ParamKey contextKey = "params"
Functions ¶
func Authorize ¶
func Authorize(w http.ResponseWriter, r *http.Request)
Authorize Displays user form to log in and authorize the requesting client
func CodeGrant ¶
func CodeGrant(w http.ResponseWriter, r *http.Request)
CodeGrant Creates a new user and returns the redirect associated with the client
func CreateClient ¶
func CreateClient(w http.ResponseWriter, r *http.Request)
CreateClient Creates a new client to be used with the app
func Info ¶
func Info(w http.ResponseWriter, r *http.Request)
Info Given an auth token, returns user information
func RespondWithJson ¶
func RespondWithJson(w http.ResponseWriter, resp interface{}) error
Types ¶
type Client ¶
type Client struct { ClientId string `firestore:"client_id" json:"client_id"` ClientSecret string `firestore:"client_secret" json:"client_secret"` Expires time.Time `firestore:"expires" json:"expires"` Name string `firestore:"name" json:"name"` RedirectUri string `firestore:"redirect_uri" json:"redirect_uri"` }
Client representation of a client
type Code ¶
type Code struct { Code string `firestore:"code"` ClientId string `firestore:"client_id"` Expires time.Time `firestore:"expires"` Username string `firestore:"username"` }
Code representation of a code
type Handler ¶
A Handler is a type that handles an http request within our own little mini framework.
type Middleware ¶
Middleware is a function designed to run some code before and/or after another Handler. It is designed to remove boilerplate or other concerns not direct to any given Handler.
func AddSecurityHeaders ¶
func AddSecurityHeaders() Middleware
AddSecurityHeaders adds basic security headers to the response
func OnlyAllow ¶
func OnlyAllow(method string) Middleware
OnlyAllow Blocks handler from executing if request doesn't match method
func ParamsFromBody ¶
func ParamsFromBody() Middleware
func ParamsFromJson ¶
func ParamsFromJson() Middleware
func ParamsFromQuery ¶
func ParamsFromQuery() Middleware
func RequireBearer ¶
func RequireBearer() Middleware
RequireBearer Enforces that authorization header with bearer token is present
func SetCsrfCookie ¶
func SetCsrfCookie() Middleware
func ValidateCsrfToken ¶
func ValidateCsrfToken() Middleware