jwt

package
v0.0.0-...-4b0699c Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package jwt provides a helper function used to access ArangoDB servers using a JWT secret.

Authenticating with a JWT secret results in "super-user" access to the database.

To use a JWT secret to access your database, use code like this:

// Create an HTTP connection to the database
conn, err := http.NewConnection(http.ConnectionConfig{
	Endpoints: []string{"http://localhost:8529"},
})
if err != nil {
	// Handle error
}

// Prepare authentication
hdr, err := CreateArangodJwtAuthorizationHeader("yourJWTSecret", "yourUniqueServerID")
if err != nil {
	// Handle error
}
auth := driver.RawAuthentication(hdr)

// Create a client
c, err := driver.NewClient(driver.ClientConfig{
	Connection:     conn,
	Authentication: auth,
})
if err != nil {
	// Handle error
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateArangodJwtAuthorizationHeader

func CreateArangodJwtAuthorizationHeader(jwtSecret, serverID string) (string, error)

CreateArangodJwtAuthorizationHeader calculates a JWT authorization header, for authorization of a request to an arangod server, based on the given secret. If the secret is empty, nothing is done. Use the result of this function as input for driver.RawAuthentication.

func CreateArangodJwtAuthorizationHeaderAllowedPaths

func CreateArangodJwtAuthorizationHeaderAllowedPaths(jwtSecret, serverID string, paths []string) (string, error)

CreateArangodJwtAuthorizationHeaderAllowedPaths calculates a JWT authorization header, for authorization of a request to an arangod server, based on the given secret. If the secret is empty, nothing is done. Use the result of this function as input for driver.RawAuthentication. Additionally allowed paths can be specified

Types

This section is empty.

Jump to

Keyboard shortcuts

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