authz

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Overview

Package authz provides simple rule-based authorization that can be used to implement access control

Index

Constants

View Source
const GroupAnonymous = "anonymous"

GroupAnonymous is the group name for unauthenticated users

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims added in v1.3.0

type Claims struct {
	Username string
	Groups   []string
	Roles    []string
	ClientID string // for tokens issued as part of client credentials grant
	// Status is the message given when token is not validated
	Status string
}

Claims are the profile attributes of user/client that are part of the JWT claims

type Conf

type Conf struct {
	// Enabled toggles authorization
	Enabled bool `json:"enabled"`
	// Authorization rules
	Rules Rules `json:"rules"`
}

Authorization struct

func (Conf) Validate

func (authz Conf) Validate() error

Validate authorization config

type Rule

type Rule struct {
	Paths                  []string `json:"paths"`
	Methods                []string `json:"methods"`
	Users                  []string `json:"users"`
	Groups                 []string `json:"groups"`
	Roles                  []string `json:"roles"`
	Clients                []string `json:"clients"`
	ExcludePathSubstrtings []string `json:"excludePathSubstrings"`
	// Deprecated. Use Paths instead.
	Resources []string `json:"resources"`
	// Deprecated. Use ExcludePathSubstrtings instead.
	DenyPathSubstrtings []string `json:"denyPathSubstrings"`
}

Authorization rule

type Rules added in v1.4.1

type Rules []Rule

func (Rules) Authorized added in v1.4.1

func (rules Rules) Authorized(path, method string, claims *Claims) bool

Authorized checks whether a request is authorized given the path, method, and claims

Jump to

Keyboard shortcuts

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