oauthdebugger

package
v0.0.0-...-7ee9cf0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const AUTH_HEADER = "Authorization"
View Source
const BEARER_FORMAT = "Bearer %s"
View Source
const CLIENT_DURATION = 24 * time.Hour
View Source
const CODE_DURATION = 10 * time.Minute
View Source
const GCP_SOURCE_DIR = "serverless_function_source_code"
View Source
const LOCAL_USERS_FILE = "users.yaml"
View Source
const LOGIN_TEMPLATE = "login.tmpl"
View Source
const USER_DURATION = 24 * time.Hour

Variables

View Source
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 RandomString

func RandomString(n int) string

RandomString gives a random string of n runes

func RespondWithJson

func RespondWithJson(w http.ResponseWriter, resp interface{}) error

func Token

func Token(w http.ResponseWriter, r *http.Request)

Token Returns authorization token and user info

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

type Handler func(ctx context.Context, w http.ResponseWriter, r *http.Request) error

A Handler is a type that handles an http request within our own little mini framework.

type Middleware

type Middleware func(Handler) Handler

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

type User

type User struct {
	ClientId     string    `firestore:"client_id"`
	RefreshToken string    `firestore:"refresh_token"`
	Token        string    `firestore:"token"`
	TokenExpires time.Time `firestore:"token_expires"`
	Username     string    `firestore:"username"`
	Uuid         string    `firestore:"uuid"`
}

type UserInfo

type UserInfo struct {
	Breed    string `yaml:"breed"`
	ImageUrl string `yaml:"image_url"`
	Name     string `yaml:"name"`
	Username string `yaml:"username"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL