oauth

package
v0.0.0-...-55c0a6c Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AUTHORIZATION_CODE = "authorization_code"
	REFRESH_TOKEN      = "refresh_token"
	PASSWORD           = "password"
	CLIENT_CREDENTIALS = "client_credentials"
	ASSERTION          = "assertion"
	IMPLICIT           = "__implicit"
	LOGIN_PATH         = "login"
)
View Source
const AUTH_PATH = "/auth/"
View Source
const CLIENTBUCKET = "OAUTHCLIENTS"
View Source
const DBFILE = "oauthstore.db"
View Source
const DBFOLDER = "db"
View Source
const REDIRECT_PATH = "/redirect"
View Source
const REQUESTIDSIZE = 32
View Source
const SESSIONLIFETIME = 5
View Source
const TOKEN_PATH = "/token"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationEndpoint

type AuthorizationEndpoint struct {
	LoginView       *template.Template
	BaseEndpointUrl url.URL
}

func (*AuthorizationEndpoint) Handle

func (ae *AuthorizationEndpoint) Handle(w http.ResponseWriter, r *http.Request, s *Session, client *Client)

func (*AuthorizationEndpoint) SetLoginTemplate

func (s *AuthorizationEndpoint) SetLoginTemplate(templateString string) error

func (*AuthorizationEndpoint) SetLoginTemplateFile

func (s *AuthorizationEndpoint) SetLoginTemplateFile(templateFile string) error

type Client

type Client struct {
	ClientId     string
	Title        string
	Description  string
	ClientUri    *url.URL
	LoginName    string
	PasswordName string
	Key          []byte
}

func NewClient

func NewClient(name string, urlString string) (*Client, error)

func (*Client) AddToUrl

func (c *Client) AddToUrl(key string, value string) error

func (*Client) GetFormToken

func (c *Client) GetFormToken(r *Session) (b64 string, err error)

func (*Client) ValidateURL

func (c *Client) ValidateURL(reqUrl string) (bool, error)

type OAuth

type OAuth struct {
	AuthEndpoint     *AuthorizationEndpoint
	TokenEndpoint    *TokenEndpoint
	RedirectEndpoint *RedirectEndpoint
	Clients          map[string]*Client
	http.Handler
	Initialized bool
	Store       *Store
	// contains filtered or unexported fields
}

func GetHandler

func GetHandler() OAuth

func (*OAuth) AddClient

func (s *OAuth) AddClient(client *Client)

OAtuh

func (*OAuth) HandleAuthorization

func (s *OAuth) HandleAuthorization(w http.ResponseWriter, r *http.Request)

func (*OAuth) HasClient

func (s *OAuth) HasClient(client_id string) bool

func (*OAuth) HasSession

func (s *OAuth) HasSession(ses *Session) bool

func (*OAuth) LoadConfiguration

func (s *OAuth) LoadConfiguration() error

func (*OAuth) ResolveClient

func (s *OAuth) ResolveClient(client_id string) (*Client, error)

func (OAuth) ServeHTTP

func (s OAuth) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RedirectEndpoint

type RedirectEndpoint struct {
}

func (*RedirectEndpoint) Handle

func (t *RedirectEndpoint) Handle(w http.ResponseWriter, r *http.Request)

type Response

type Response struct {
	Type               ResponseType
	StatusCode         int
	StatusText         string
	ErrorStatusCode    int
	URL                string
	Headers            http.Header
	IsError            bool
	ErrorId            string
	InternalError      error
	RedirectInFragment bool
	Output             ResponseData
}

func NewResponse

func NewResponse() *Response

func (*Response) Close

func (r *Response) Close()

func (*Response) SetErrorState

func (r *Response) SetErrorState(id string, description string, state string)

func (*Response) SetErrorUri

func (r *Response) SetErrorUri(id string, description string, uri string, state string)

type ResponseData

type ResponseData map[string]interface{}

type ResponseType

type ResponseType int
const (
	DATA ResponseType = iota
	REDIRECT
)

type Session

type Session struct {
	ClientId      string
	State         string
	Scope         string
	UserAgent     string
	Cookies       string
	RequestId     string
	ResponseType  string
	Code          string
	GrantType     string
	RemoteAddr    string
	RedirectUri   string
	FormToken     *token.FVT
	FormTokenText string
	RequestFailes uint8
}

func (*Session) GetCSRFRoken

func (er *Session) GetCSRFRoken(key []byte, timestamp int) string

type Store

type Store struct {
	// contains filtered or unexported fields
}

func (*Store) Close

func (s *Store) Close() error

func (*Store) GetClients

func (s *Store) GetClients() (clients map[string]*Client, err error)

func (*Store) GetSession

func (s *Store) GetSession(sessId string) (*Session, error)

func (*Store) SetSession

func (s *Store) SetSession(ses *Session) error

type TemplateData

type TemplateData struct {
	LoginTarget        string
	FormToken          string
	LoginFieldName     string
	LoginFieldTitle    string
	PasswordFieldName  string
	PasswordFieldTitle string
	SubmitName         string
}

type TokenEndpoint

type TokenEndpoint struct {
}

func (*TokenEndpoint) Handle

func (t *TokenEndpoint) Handle(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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