auth

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: Apache-2.0 Imports: 6 Imported by: 3

README

Auth package readme

Example usage

router := mux.NewRouter().StrictSlash(true)
for _, api := range routers {
    for _, route := range api.Routes() {
        var handler http.Handler
        handler = route.HandlerFunc
        handler = utils.Logger(auth.CorsWrapper.Handler(auth.Middleware.Handler(handler)), route.Name)
        router.
            Methods(route.Method).
            Path(route.Pattern).
            Name(route.Name).
            Handler(handler)
        observability.Info(fmt.Sprintf("Route=%s Path=%s Method=%s", route.Name, route.Pattern, route.Method))

    }
}

Auth0

https://auth0.com/blog/authentication-in-golang/ https://github.com/auth0/go-jwt-middleware

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CorsWrapper = cors.New(cors.Options{
	AllowedMethods: []string{"GET", "POST"},
	AllowedHeaders: []string{"Content-Type", "Origin", "Accept", "*"},
})

For dev only - Set up CORS so React client can consume our API

View Source
var Middleware = jwtmiddleware.New(jwtmiddleware.Options{
	ValidationKeyGetter: getValidationKey,
	SigningMethod:       jwt.SigningMethodRS256,
})

Functions

This section is empty.

Types

type JSONWebKeys

type JSONWebKeys struct {
	Kty string   `json:"kty"`
	Kid string   `json:"kid"`
	Use string   `json:"use"`
	N   string   `json:"n"`
	E   string   `json:"e"`
	X5c []string `json:"x5c"`
}

type Jwks

type Jwks struct {
	Keys []JSONWebKeys `json:"keys"`
}

Jump to

Keyboard shortcuts

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