middleware

package module
v0.0.0-...-938ccfa Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 8 Imported by: 0

README

Auth0 Scopes

Consume Auth0 Scopes in Go A Go middleware for gin.

License MIT

Check out Examples - for an idea on how to use this with Gin

Installation

# Go package install
go get github.com/colwill/go-auth0-scopes/

Basic Usage

import (
    middleware "github.com/colwill/go-auth0-scopes"
)

var router = gin.Default()

func main() {

    router.Use(middleware.ScopeUnwrap())
    router.GET("/protected", middleware.Authorise("read:protected"), func(c *gin.Context) {
        c.IndentedJSON(http.StatusOK, gin.H{"message": "this is a protected route!"})
    })

    err = router.Run()
	if err != nil {
		return
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authorise

func Authorise(scope string) gin.HandlerFunc

func ScopeUnwrap

func ScopeUnwrap() gin.HandlerFunc

Types

type CustomAuthClaims

type CustomAuthClaims struct {
	Scope string `json:"scope"`
}

func (CustomAuthClaims) Validate

func (c CustomAuthClaims) Validate(ctx context.Context) error

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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