I couldn’t find any page saying that Vault can act as an OAuth or OpenIDC provider.
However, Vault can issue OIDC identity tokens:
Unfortunately, I don’t think this by itself is sufficient to turn Vault into an OpenID Connect provider (in the style of Dex IDP or Keycloak), although it could be a building block.
Firstly, the OIDC provider needs to act as an endpoint for the OIDC protocol exchange, rather than the Vault REST API.
Secondly, the user has to authenticate themselves to Vault, and then use their Vault token to issue an OIDC token. In the simplest case, an OIDC frontend could display a webpage asking for username and password, and use the userpass secrets engine to get a vault token for that user. Making this properly secure would require some form of 2FA.
Thirdly, the OIDC provider needs to store a client_id and client_secret for each OIDC client (although I note that identity/oidc/role
already includes a client_id
. Maybe the role name is really the client_id, and the client_id is really the client_secret? Except that allowed_client_ids
in the key contradicts that)
And fourthly, the OIDC provider must include additional claims in the JWT, limited to the scopes which the client requested, and which the user has explicitly granted permission for. The endpoint which issues tokens doesn’t seem to have a way to control claims, although the role includes a “template string to use for generating tokens” (without further explanation).
If I decode the sample token shown in the API response at jsonwebtoken.io, I get:
# Header
{
"typ": "JWT",
"alg": "RS256",
"kid": "2d0b8b9d-f04d-71ec-b674-c7358432bc5b"
}
# Payload
{
"aud": "P6CfCzyHsQY4pMcA6kWAOCItA7",
"exp": 1561488412,
"iat": 1561402012,
"iss": "https://example.com:1234",
"sub": "6c65eaf7-d4f4-1333-02bc-1c75219c3102"
}
As far as I can see, this is the most important missing piece: the ability to map entity metadata to JWT claims, and to control which claims are included on a token-by-token basis. (This includes mapping Vault groups to JWT group claims).
If that existed, so that Vault could become a general OIDC provider, that would indeed be awesome!