auth

package
v0.0.0-...-3329678 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationManager

type AuthenticationManager struct {
	AuthMethods []AuthenticationMethod
}

AuthenticationManager A simple type for managing abstract authentication methods

func (*AuthenticationManager) MatchToken

func (am *AuthenticationManager) MatchToken(prefix string) *AuthenticationMethod

MatchToken matches a provided string with the token format of an AuthenticationMethod

func (*AuthenticationManager) RegisterAuthenticationMethod

func (am *AuthenticationManager) RegisterAuthenticationMethod(method AuthenticationMethod)

RegisterAuthenticationMethod Registers an authentication method with the manager

func (*AuthenticationManager) RegisterHandlers

func (am *AuthenticationManager) RegisterHandlers(e *gin.Engine)

RegisterHandlers Registers the http handlers for each of the authentication methods with a gin Engine

type AuthenticationMethod

type AuthenticationMethod interface {
	// Register any handlers required for handling the user's authentication.  Note: for externally-authenticated
	//	methods, this may not be required
	RegisterHandlers(*gin.Engine)
	// Takes an authorization token and extracts the user's identity from it (a simple string user id for now)
	ExtractIdentity(string) (string, error)
	// The prefix used to the actual token in the authorization header
	AuthHeaderPrefix() string
	// Injects a "login" prompt / button into the "login methods" popup
	GetLoginButton() template.HTML
	// Injects into the "head" of the HTML any scripts or meta info
	GetLoginHeader() template.HTML
}

AuthenticationMethod An interface for authentication methods to plug into the router and the web page

func NewNoAuth

func NewNoAuth() AuthenticationMethod

NewNoAuth Creates a new instance of the no-pw-required authentication method for testing / development

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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