• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.circleci/H04-Aug-2021-

.github/H04-Aug-2021-

cmd/vault-plugin-auth-jwt/H04-Aug-2021-

scripts/H04-Aug-2021-

vendor/H03-May-2022-

.gitignoreH A D04-Aug-2021857

CHANGELOG.mdH A D04-Aug-2021212

LICENSEH A D04-Aug-202115.5 KiB

MakefileH A D04-Aug-20211.5 KiB

README.mdH A D04-Aug-20215 KiB

backend.goH A D04-Aug-20213.5 KiB

claims.goH A D04-Aug-20214.7 KiB

claims_test.goH A D04-Aug-202112.1 KiB

cli.goH A D04-Aug-20217.8 KiB

cli_responses.goH A D04-Aug-202125 KiB

cli_test.goH A D04-Aug-20211.2 KiB

go.modH A D04-Aug-2021979

go.sumH A D04-Aug-202144.9 KiB

path_config.goH A D04-Aug-202115.3 KiB

path_config_test.goH A D04-Aug-202119.6 KiB

path_login.goH A D04-Aug-20218.6 KiB

path_login_test.goH A D04-Aug-202138.4 KiB

path_oidc.goH A D04-Aug-202116 KiB

path_oidc_test.goH A D04-Aug-202137.1 KiB

path_role.goH A D04-Aug-202119 KiB

path_role_test.goH A D04-Aug-202124.4 KiB

path_ui.goH A D04-Aug-2021811

provider_azure.goH A D04-Aug-20216 KiB

provider_azure_test.goH A D04-Aug-20214.7 KiB

provider_config.goH A D04-Aug-20212.2 KiB

provider_config_test.goH A D04-Aug-20213.1 KiB

provider_gsuite.goH A D04-Aug-20217.4 KiB

provider_gsuite_test.goH A D04-Aug-202115.8 KiB

README.md

1# Vault Plugin: JWT Auth Backend [![CircleCI](https://circleci.com/gh/hashicorp/vault-plugin-auth-jwt.svg?style=svg)](https://circleci.com/gh/hashicorp/vault-plugin-auth-jwt)
2
3This is a standalone backend plugin for use with [Hashicorp Vault](https://www.github.com/hashicorp/vault).
4This plugin allows for JWTs (including OIDC tokens) to authenticate with Vault.
5
6**Please note**: We take Vault's security and our users' trust very seriously. If you believe you have found a security issue in Vault, _please responsibly disclose_ by contacting us at [security@hashicorp.com](mailto:security@hashicorp.com).
7
8## Quick Links
9    - Vault Website: https://www.vaultproject.io
10    - JWT Auth Docs: https://www.vaultproject.io/docs/auth/jwt.html
11    - Main Project Github: https://www.github.com/hashicorp/vault
12
13## Getting Started
14
15This is a [Vault plugin](https://www.vaultproject.io/docs/internals/plugins.html)
16and is meant to work with Vault. This guide assumes you have already installed Vault
17and have a basic understanding of how Vault works.
18
19Otherwise, first read this guide on how to [get started with Vault](https://www.vaultproject.io/intro/getting-started/install.html).
20
21To learn specifically about how plugins work, see documentation on [Vault plugins](https://www.vaultproject.io/docs/internals/plugins.html).
22
23## Usage
24
25Please see [documentation for the plugin](https://www.vaultproject.io/docs/auth/jwt.html)
26on the Vault website.
27
28This plugin is currently built into Vault and by default is accessed
29at `auth/jwt`. To enable this in a running Vault server:
30
31```sh
32$ vault auth enable jwt
33Successfully enabled 'jwt' at 'jwt'!
34```
35
36To see all the supported paths, see the [JWT auth backend docs](https://www.vaultproject.io/docs/auth/jwt.html).
37
38## Developing
39
40If you wish to work on this plugin, you'll first need
41[Go](https://www.golang.org) installed on your machine.
42
43For local dev first make sure Go is properly installed, including
44setting up a [GOPATH](https://golang.org/doc/code.html#GOPATH).
45Next, clone this repository into
46`$GOPATH/src/github.com/hashicorp/vault-plugin-auth-jwt`.
47You can then download any required build tools by bootstrapping your
48environment:
49
50```sh
51$ make bootstrap
52```
53
54To compile a development version of this plugin, run `make` or `make dev`.
55This will put the plugin binary in the `bin` and `$GOPATH/bin` folders. `dev`
56mode will only generate the binary for your platform and is faster:
57
58```sh
59$ make
60$ make dev
61```
62
63Put the plugin binary into a location of your choice. This directory
64will be specified as the [`plugin_directory`](https://www.vaultproject.io/docs/configuration/index.html#plugin_directory)
65in the Vault config used to start the server.
66
67```json
68...
69plugin_directory = "path/to/plugin/directory"
70...
71```
72
73Start a Vault server with this config file:
74```sh
75$ vault server -config=path/to/config.json ...
76...
77```
78
79Once the server is started, register the plugin in the Vault server's [plugin catalog](https://www.vaultproject.io/docs/internals/plugins.html#plugin-catalog):
80
81```sh
82$ vault write sys/plugins/catalog/jwt \
83        sha_256=<expected SHA256 Hex value of the plugin binary> \
84        command="vault-plugin-auth-jwt"
85...
86Success! Data written to: sys/plugins/catalog/jwt
87```
88
89Note you should generate a new sha256 checksum if you have made changes
90to the plugin. Example using openssl:
91
92```sh
93openssl dgst -sha256 $GOPATH/vault-plugin-auth-jwt
94...
95SHA256(.../go/bin/vault-plugin-auth-jwt)= 896c13c0f5305daed381952a128322e02bc28a57d0c862a78cbc2ea66e8c6fa1
96```
97
98Enable the auth plugin backend using the JWT auth plugin:
99
100```sh
101$ vault auth enable -plugin-name='jwt' plugin
102...
103
104Successfully enabled 'plugin' at 'jwt'!
105```
106
107### Provider-specific handling
108
109Provider-specific handling can be added by writing an object that conforms to
110one or more interfaces in [provider_config.go](provider_config.go). Some
111interfaces will be required, like [CustomProvider](provider_config.go), and
112others will be invoked if present during the login process (e.g. GroupsFetcher).
113The interfaces themselves will be small (usually a single method) as it is
114expected that the parts of the login that need specialization will be different
115per provider. This pattern allows us to start with a minimal set and add
116interfaces as necessary.
117
118If a custom provider is configured on the backend object and satisfies a given
119interface, the interface will be used during the relevant part of the login
120flow. e.g. after an ID token has been received, the custom provider's
121UserInfoFetcher interface will be used, if present, to fetch and merge
122additional identity data.
123
124The custom handlers will be standalone objects defined in their own file (one
125per provider). They'll be part of the main jwtauth package to avoid potential
126circular import issues.
127
128### Tests
129
130If you are developing this plugin and want to verify it is still
131functioning (and you haven't broken anything else), we recommend
132running the tests.
133
134To run the tests, invoke `make test`:
135
136```sh
137$ make test
138```
139
140You can also specify a `TESTARGS` variable to filter tests like so:
141
142```sh
143$ make test TESTARGS='--run=TestConfig'
144```
145