Penv Cloud
Start free
Docs
Reference

Duende IdentityServer

Services authenticate with the subject their IdentityServer client claims.

Services authenticate with the subject their IdentityServer client claims.

Identity proof

The token has to come from https://identity.acme.com, and its sub claim has to match the workload you named. We compare that claim byte for byte, with no wildcards.

Every token also has to name your workspace as its audience. Ask for this audience and no other. A token requested for two audiences fails every exchange.

Console fields

FieldExampleAdvancedWhat it pins
Issuer URLhttps://identity.acme.comnoThe issuer your /.well-known/openid-configuration shows. Must be reachable from the internet.
Subjectpenv-billing-workernoThe sub client claim you gave this client. Every machine holding its secret matches.

The console also asks which project and environment this identity reaches and which role it gets, with the credential lifetime behind Advanced.

Trust

Built from the example answers above:

WhatValue
Issuerhttps://identity.acme.com
Claim comparedsub
Subjectpenv-billing-worker
Identity nameduende-penv-billing-worker

We name the identity for you, so the form never asks for one.

Console snippet

# IdentityServer config, once. The ApiResource and its one scope take your workspace id:
#   new ApiScope("YOUR_WORKSPACE_ID"),
#   new ApiResource("YOUR_WORKSPACE_ID") { Scopes = { "YOUR_WORKSPACE_ID" } },
#   new Client {
#     ClientId = "billing-worker",
#     AllowedGrantTypes = GrantTypes.ClientCredentials,
#     ClientSecrets = { new Secret(hashedSecret) },
#     AllowedScopes = { "YOUR_WORKSPACE_ID" },
#     ClientClaimsPrefix = "",
#     Claims = { new ClientClaim("sub", "penv-billing-worker") },
#   }
# Allow that scope to machine clients alone, and give each a sub that no user id can take.
# Leave EmitStaticAudienceClaim off: it adds a second audience. Sign with an RSA or EC P-256 key.
# Ask for this audience and no other. A token requested for two audiences fails every exchange.
# Set IssuerUri, or call the public URL: otherwise the issuer is taken from the request host.
# $DUENDE_CLIENT_ID and $DUENDE_CLIENT_SECRET are this client's own, already on the machine.
URL=$(curl -fsS "<ISSUER>/.well-known/openid-configuration" | jq -r .token_endpoint)
T=$(jq -jn \
  '"grant_type=client_credentials&client_id=\((env.DUENDE_CLIENT_ID // "" | if . == "" then error("DUENDE_CLIENT_ID is not set") else . end)|@uri)&client_secret=\((env.DUENDE_CLIENT_SECRET // "" | if . == "" then error("DUENDE_CLIENT_SECRET is not set") else . end)|@uri)&scope=YOUR_WORKSPACE_ID"' \
  | curl -fsS "$URL" --data-binary @- | jq -r .access_token)
C=$(T="$T" jq -n '{token:env.T}' | curl -sS "https://penv.cloud/api/v1/auth/oidc" \
  -H 'content-type: application/json' --data-binary @- | jq -r .credential)
PENV_TOKEN="$C" penv pull

The snippet finishes with penv pull, which writes a file. We recommend penv run for a process; penv pull is for a host that needs a file on disk. Connect your CI has the wrapped step.