security

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package security creates valid user objects for the system Starter code credit to: github.com/mura123yasu/go-cognito@master:6/1/2019 (base starter) Updated to remove region checks - pull and check from the JWT itself instead Updated to add JWK cache - will enable refresh in future, I don't think AWS rotates yet Updated to remove redundant checks with the JWT library Changed the order significantly so that it can self serve in library Modified to be more consistent within this overall frameowrk (more work to do here later: future)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAnonymous

func IsAnonymous(ctx context.Context) bool

IsAnonymous - if security context is not set or user is empty or the string anonymousit will return true/ not logged in

func SetupAuthFromHTTP

func SetupAuthFromHTTP(r *http.Request) (context.Context, error)

SetupAuthFromHTTP - Enables Auth for later retrieval in the request flow, value added to returned Context

func SetupTestAuthFromContext

func SetupTestAuthFromContext(ctx context.Context, userNumber uint) context.Context

SetupTestAuthFromContext - Enables Auth for later retrieval in the request flow, , value added to returned Context

Types

type Auth

type Auth interface {
	GetUser() string
	GetAuthHeader() string
	IsAdmin() bool
}

Auth - Interface for setting up and retrieving authentication data

func GetAuth

func GetAuth(ctx context.Context) Auth

GetAuth - returns Auth from the provided context

type BasicAuth

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

BasicAuth - authentication data holder

func (*BasicAuth) GetAuthHeader

func (t *BasicAuth) GetAuthHeader() string

GetAuthHeader - returns the Authorization Header associated with this request if http request

func (*BasicAuth) GetUser

func (t *BasicAuth) GetUser() string

GetUser - returns end user

func (*BasicAuth) IsAdmin

func (t *BasicAuth) IsAdmin() bool

IsAdmin - returns if user is an admin TODO: this always will be false till implemented

func (*BasicAuth) String

func (t *BasicAuth) String() string

type JWK

type JWK struct {
	Keys []JWKKey
}

JWK is json data struct for JSON Web Key

type JWKKey

type JWKKey struct {
	Alg string
	E   string
	Kid string
	Kty string
	N   string
	Use string
}

JWKKey is json data struct for cognito jwk key

Jump to

Keyboard shortcuts

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