auth0

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MPL-2.0 Imports: 13 Imported by: 0

README

Vault Secrets Plugin - Auth0

Vault secrets plugins to simplying creation, management, and revocation of auth0 management API tokens.

Usage

Setup Endpoint
  1. Download and enable plugin locally (TODO)

  2. Configure the plugin

    vault write /auth0/config/root domain=<token> client_id=<client-id> client_secret=<client-secret>
    
  3. Add one or more policies

Configure Policies
vault write /auth0/roles/<role-name> scopes=["test"]

you can then read from the role using

vault read /auth0/creds/<role-name>
Rotating the Root Token

The plugin supports rotating the configured admin token to seamlessly improve security.

To rotate the token, perform a 'write' operation on the config/rotate-root endpoint

> export VAULT_ADDR="http://localhost:8200"
> vault write -f config/rotate-root
vault write -f auth0/config/rotate-root
Key       Value
---       -----
domain    <domain>
id        <client_id>
Generate a new Token

To generate a new token:

Create a new auth0 policy and perform a 'read' operation on the creds/<role-name> endpoint.

# To read data using the api
$ vault read auth0/role/create-user
Key                Value
---                -----
lease_id           auth0/creds/test/arwU5tYDdw05Vwa306AOfjeP
lease_duration     24h
lease_renewable    false
token              <token>
token_type         Bearer

Development

The provided Earthfile (think makefile, but using docker) is used to build, test, and publish the plugin. See the build targets for more information. Common targets include

# build a local version of the plugin
$ earthly +build

# execute integration tests
#
# use https://developers.auth0.com/api/tokens/create to create a token
# with 'User:API Tokens:Edit' permissions
$ TEST_auth0_TOKEN=<YOUR_auth0_TOKEN> earthly --secret TEST_auth0_TOKEN +test

# start vault and enable the plugin locally
earthly +dev

Documentation

Index

Constants

View Source
const (
	SecretTokenType = "token"
)

Variables

This section is empty.

Functions

func Factory

func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error)

Factory configures and returns Mock backends

func WithHeader

func WithHeader(rt http.RoundTripper) withHeader

Types

type Auth0Error

type Auth0Error struct {
	StatusCode int    `json:"statusCode"`
	ErrorType  string `json:"error"`
	Message    string `json:"message"`
	ErrorCode  string `json:"errorCode"`
}

func (Auth0Error) Error

func (e Auth0Error) Error() string

type Client

type Client struct {
	BaseURL string
	// contains filtered or unexported fields
}

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

type ClientGrantResponse

type ClientGrantResponse struct {
	ID       string   `json:"id"`
	ClientID string   `json:"client_id"`
	Audience string   `json:"audience"`
	Scopes   []string `json:"scope"`
}

type ClientResponse

type ClientResponse struct {
	Tenant                         string `json:"tenant"`
	Global                         bool   `json:"global"`
	IsTokenEndpointIPHeaderTrusted bool   `json:"is_token_endpoint_ip_header_trusted"`
	Name                           string `json:"name"`
	IsFirstParty                   bool   `json:"is_first_party"`
	OIDCConformant                 bool   `json:"oidc_conformant"`
	SSODisabled                    bool   `json:"sso_disabled"`
	CrossOriginAuth                bool   `json:"cross_origin_auth"`
	// RefreshToken
	// SigningKeys
	ClientID            string `json:"client_id"`
	CallbackURLTemplate bool   `json:"callback_url_template"`
	ClientSecret        string `json:"client_secret"`
	// JWTConfiguration
	TokenEndpointAuthMethod string   `json:"token_endpoint_auth_method"`
	AppType                 string   `json:"app_type"`
	GrantTypes              []string `json:"grant_types"`
	CustomLoginPageOn       bool     `json:"custom_login_page_on"`
}

https://auth0.com/docs/api/management/v2#!/Clients/post_rotate_secret TODO: verify if this works also with create client

type CreateClientBody

type CreateClientBody struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	GrantTypes  []string `json:"grant_types"`
}

https://auth0.com/docs/api/management/v2#!/Clients/post_clients

type CreateClientGrantBody

type CreateClientGrantBody struct {
	ClientID string   `json:"client_id"`
	Audience string   `json:"audience"`
	Scopes   []string `json:"scope"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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