gauth

package module
v0.0.0-...-f641761 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 License: MIT Imports: 5 Imported by: 0

README

gauth

CircleCI

Handles authentication using basic auth or JWTs.

Types
  • JWTAuth: Does JWT authentication. Contains the secret key used to sign JWTs as well as the expiration time.
  • BasicAuth: Defines an interface for handling basic auth.
  • StaticBasicAuth: BasicAuth implementation that uses a static username and password.
Methods
  • JWTAuth.Create: Creates a JWT token with the provided metadata.
  • JWTAuth.Extract: Extracts metadata from the given JWT token.
  • StaticBasicAuth.Validate: Validates the given username and password with it's static values.
Testing

make test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAuth

type BasicAuth interface {
	Validate(username string, password string) bool
}

BasicAuth defines an interface for interaction with the Basic Auth protocol.

type JWTAuth

type JWTAuth struct {
	Secret string
}

JWTAuth handles encoding and decoding JWT tokens.

func (*JWTAuth) Create

func (auth *JWTAuth) Create(meta interface{}, issuer string, expirationInMinutes uint) (string, error)

Create creates a JWT token for a given user ID.

func (*JWTAuth) Extract

func (auth *JWTAuth) Extract(rawToken string) (interface{}, error)

Extract will take a raw token and extract the value.

func (*JWTAuth) ExtractFromHeader

func (auth *JWTAuth) ExtractFromHeader(tokenHeader string) (interface{}, error)

ExtractFromHeader returns the encoded object from the header.

type StaticBasicAuth

type StaticBasicAuth struct {
	Username string
	Password string
}

StaticBasicAuth takes a static username/password combo.

func (*StaticBasicAuth) Validate

func (auth *StaticBasicAuth) Validate(username string, password string) bool

Validate that the given username and password are correct.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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