auth

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Router *chi.Mux
	// contains filtered or unexported fields
}

Auth hold root server state

func New

func New(db Database, opts Options) Auth

New creates server, it won't run till Auth.Router.Start

type AuthorizationCodeGrantResponse

type AuthorizationCodeGrantResponse struct {
	TokenType    string `json:"token_type"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	// In seconds
	ExpiresIn int `json:"expires_in"`
}

AuthorizationCodeGrantResponse is struct which you get in response for authorization code grant if everything is successful

type Database

type Database interface {
	AddUser(ctx context.Context, user types.User) (id string, err error)
	GetUserByEmail(ctx context.Context, email string) (*types.User, error)
}

Database is database interface

type LoginCredentials

type LoginCredentials struct {
	Email    string `schema:"email"`
	Password string `schema:"password"`
}

LoginCredentials is body of the request sent to /login

type LoginPageQuery

type LoginPageQuery struct {
	ClientID     string `schema:"client_id" binding:"required"`
	RedirectURI  string `schema:"redirect_uri" binding:"required"`
	State        string `schema:"state" binding:"required"`
	Scope        string `schema:"scope"`
	ResponseType string `schema:"response_type" binding:"required"`
	UserLocale   string `schema:"user_locale"`
}

LoginPageQuery sent by google

type Options

type Options struct {
	// ProjectID set in Google Cloud Console
	//
	// *Required*
	ProjectID string `env:"PROJECT_ID,required"`

	// ClientID set Actions account linking tab
	//
	// *Required*
	ClientID string `env:"OAUTH_CLIENT_ID,required"`

	// ClientSecret set Actions account linking tab
	//
	// *Required*
	ClientSecret string `env:"OAUTH_CLIENT_SECRET,required"`

	// AccessKey is secret for signing access tokens
	//
	// *Required*
	AccessKey string `env:"ACCESS_KEY,required"`

	// AuthorizationCodeKey is secret for signing authorization codes
	//
	// *Required*
	AuthorizationCodeKey string `env:"AUTHORIZATION_CODE_KEY,required"`

	// RefreshKey is secret for signing refresh tokens
	//
	// *Required*
	RefreshKey string `env:"REFRESH_KEY,required"`

	// Template of login site
	//
	// *Required*
	LoginSiteTemplate *template.Template
}

Options defines options for auth

type RefreshTokenGrantResponse

type RefreshTokenGrantResponse struct {
	TokenType   string `json:"token_type"`
	AccessToken string `json:"access_token"`
	// In seconds
	ExpiresIn int `json:"expires_in"`
}

RefreshTokenGrantResponse is struct which you get in response for refresh code grant if everything is successful

type TokenQuery

type TokenQuery struct {
	ClientID     string `schema:"client_id" binding:"required"`
	ClientSecret string `schema:"client_secret" binding:"required"`
	GrantType    string `schema:"grant_type" binding:"required"`
	Code         string `schema:"code" binding:"required_if=GrantType authorization_code"`
	RedirectURI  string `schema:"redirect_uri" binding:"required_if=GrantType authorization_code"`
	RefreshToken string `schema:"refresh_token" binding:"required_if=GrantType refresh_token"`
}

TokenQuery sent by google

Jump to

Keyboard shortcuts

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