Learn how to authenticate SPIRE workloads with Infisical using OpenID Connect (OIDC).
OIDC Auth is a platform-agnostic JWT-based authentication method that can be used to authenticate from any platform or environment using an identity provider with OpenID Connect.
The following sequence diagram illustrates the OIDC Auth workflow for authenticating SPIRE workloads with Infisical.
At a high-level, Infisical authenticates a SPIRE workload by verifying the JWT-SVID and checking that it meets specific requirements (e.g. it is issued by a trusted SPIRE server) at the /api/v1/auth/oidc-auth/login
endpoint. If successful,
then Infisical returns a short-lived access token that can be used to make authenticated requests to the Infisical API.
To be more specific:
/api/v1/auth/oidc-auth/login
endpoint.Before following this guide, ensure you have:
For detailed SPIRE setup instructions, refer to the SPIRE documentation.
To enable JWT-SVID verification with Infisical, you need to deploy the OIDC Discovery Provider alongside your SPIRE Server. The OIDC Discovery Provider runs as a separate service that exposes the necessary OIDC endpoints.
In Kubernetes deployments, this is typically done by adding an oidc-discovery-provider
container to your SPIRE Server StatefulSet:
The OIDC Discovery Provider will expose the OIDC Discovery endpoint at https://<spire-oidc-host>/.well-known/openid_configuration
, which Infisical will use to fetch the public keys for JWT-SVID verification.
In the following steps, we explore how to create and use identities to access the Infisical API using the OIDC Auth authentication method with SPIFFE/SPIRE.
Creating an identity
To create an identity, head to your Organization Settings > Access Control > Identities and press Create identity.
When creating an identity, you specify an organization level role for it to assume; you can configure roles in Organization Settings > Access Control > Organization Roles.
Now input a few details for your new identity. Here’s some guidance for each field:
Once you’ve created an identity, you’ll be redirected to a page where you can manage the identity.
Since the identity has been configured with Universal Auth by default, you should re-configure it to use OIDC Auth instead. To do this, press to edit the Authentication section, remove the existing Universal Auth configuration, and add a new OIDC Auth configuration onto the identity.
Here’s some more guidance on each field:
https://<spire-server-host>:<port>/.well-known/openid_configuration
https://<spire-server-host>:<port>
spiffe://<trust-domain>/<workload-path>
. For example: spiffe://example.org/workload/api-server
infisical
or your service name). Configure this to match what your workloads use.sub
(SPIFFE ID), aud
(audience), exp
(expiration), and iat
(issued at). You can also configure custom claims if your SPIRE Server includes additional metadata.2592000
equivalent to 30 days): The lifetime for an access token in seconds. This value will be referenced at renewal time.2592000
equivalent to 30 days): The maximum lifetime for an access token in seconds. This value will be referenced at renewal time.0
): The maximum number of times that an access token can be used; a value of 0
implies infinite number of uses.0.0.0.0/0
, allowing usage from any network address.
sub
(SPIFFE ID), aud
(audience), exp
, and iat
. The audience is typically specified when requesting the JWT-SVID (e.g., spire-agent api fetch jwt -audience infisical
).subject
, audiences
, and claims
fields support glob pattern matching; however, we highly recommend using hardcoded SPIFFE IDs whenever possible for better security.Adding an identity to a project
To enable the identity to access project-level resources such as secrets within a specific project, you should add it to that project.
To do this, head over to the project you want to add the identity to and go to Project Settings > Access Control > Machine Identities and press Add identity.
Next, select the identity you want to add to the project and the project level role you want to allow it to assume. The project role assigned will determine what project level resources this identity can have access to.
Using JWT-SVID to authenticate with Infisical
Here’s an example of how a workload can use its JWT-SVID to authenticate with Infisical and retrieve secrets:
Each identity access token has a time-to-live (TTL) which you can infer from the response of the login operation;
the default TTL is 7200
seconds which can be adjusted.
If an identity access token expires, it can no longer authenticate with the Infisical API. In this case, a new access token should be obtained by performing another login operation.
JWT-SVIDs from SPIRE have their own expiration time (typically short-lived). Ensure your application handles both JWT-SVID renewal from SPIRE and access token renewal from Infisical appropriately.