token

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package token provides the ability for inserting Vela token resources into or extracting Vela token resources from the middleware chain for the API.

Usage:

import "github.com/go-vela/server/router/middleware/token"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compose

func Compose(u *library.User) (string, error)

Compose generates the token unique to the provided user. It uses a secret hash, which is unique for every user, to sign the token which guarantees the signature is unique per token. The signed token is returned as a string.

func Parse

func Parse(t string, db database.Service) (*library.User, error)

Parse scans the signed JWT token as a string and extracts the user login from the claims to be looked up in the database. This function will return an error for a few different reasons:

* the token signature doesn't match what is expected * the token signing method doesn't match what is expected * the token is invalid (potentially expired or improper)

func Retrieve

func Retrieve(r *http.Request) (string, error)

Retrieve gets the token from the provided request http.Request to be parsed and validated. This is called on every request to enable capturing the user making the request and validating they have the proper access. The following methods of providing authentication to Vela are supported:

* Bearer token in `Authorization` header

Types

This section is empty.

Jump to

Keyboard shortcuts

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