agentleFS
andreab67andreab67/agent-skills/login-gov/SKILL.md

login-gov

Skill1 starsChanged 2 months agoBSD-3-ClauseView on GitHub

Integrate with login.gov as a federal identity provider — OIDC federation (SAML exists but is out of scope here), private_key_jwt client authentication, ACR value selection (auth-only, verified, facial-match, PIV/CAC), sandbox and production setup, token flow implementation, user attribute scopes, and Partner Portal configuration. Use this skill whenever the user mentions login.gov, federal SSO, private_key_jwt, IAL2, ACR values, identity proofing, PIV/CAC authentication, the login.gov Partner Portal, or any error from the login.gov IdP — even if they just say "integrate with login.gov" or "federal identity" without more detail.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 1 is distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do NOT use for:

    line 19
  2. Very specific:

    Verify state matches the value you stored.

    line 124
  3. Very specific:

    Verify signature using RS256 with the matching key (kid header)

    line 173
  4. Very specific:

    Verify iss = login.gov IdP URL

    line 174
  5. Very specific:

    Verify aud = your client_id

    line 175
  6. Very specific:

    Verify nonce = the nonce you sent in Step 1

    line 176
  7. Very specific:

    Verify exp is in the future

    line 177
  8. Very specific:

    Create an app — get a client_id

    line 211
  9. Very specific:

    Test users: create accounts at https://idp.int.identitysandbox.gov

    line 214

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

login-gov

Federal identity provider integration using login.gov. Covers OIDC (login.gov's preferred protocol), private_key_jwt authentication, assurance level selection, and the full token exchange flow.

When to use

  • Integrating a web or mobile app with login.gov for federal SSO
  • Choosing between auth-only, identity-verified, and PIV/CAC assurance levels
  • Implementing OIDC authorization code + private_key_jwt flow
  • Setting up sandbox vs production environments
  • Requesting user attributes (email, phone, SSN, x509/PIV)
  • Debugging invalid_client, invalid_request, or token validation errors

Do NOT use for:

  • Non-federal identity providers (Okta, Auth0, Cognito — use their own SDKs)
  • SAML SP setup (login.gov supports SAML, but this skill covers OIDC only; confirm the user can use OIDC before proceeding)
  • Private-sector applications (login.gov is US federal agencies only)

Endpoints

EnvironmentDiscovery URL
Sandboxhttps://idp.int.identitysandbox.gov/.well-known/openid-configuration
Productionhttps://secure.login.gov/.well-known/openid-configuration

Key endpoints from discovery:

  • Authorization: https://idp.int.identitysandbox.gov/openid_connect/authorize
  • Token: https://idp.int.identitysandbox.gov/api/openid_connect/token
  • UserInfo: https://idp.int.identitysandbox.gov/api/openid_connect/userinfo
  • JWKS: https://idp.int.identitysandbox.gov/api/openid_connect/certs

Authentication methods

Web apps — private_key_jwt (required)

Generate a 2048-bit RSA key pair. Register the public certificate in the Partner Portal. Sign client assertions with the private key using RS256.

# Generate key pair
openssl genrsa -out private.pem 2048
openssl req -new -x509 -key private.pem -out public.crt -days 365 \
  -subj "/C=US/ST=DC/L=Washington/O=Agency/CN=myapp.agency.gov"

# View public key for Partner Portal upload
cat public.crt

Native mobile apps — PKCE (RFC 7636)

Generate a code_verifier (43–128 URL-safe random chars), hash it:

code_challenge = BASE64URL(SHA256(code_verifier))

Pass code_challenge and code_challenge_method=S256 in the authorization request.

Explicitly NOT supported

  • client_secret / client_secret_post / client_secret_basic
  • Implicit flow (response_type=token)

ACR values — choose the right level

ACR valueMeaningWhen to use
urn:acr.login.gov:auth-onlyPassword + optional MFAContent that needs a federal user account but no identity proof
urn:acr.login.gov:verifiedIdentity-verified (IAL2), no facial matchBenefits, grants, regulated services
urn:acr.login.gov:verified-facial-match-requiredIAL2 + facial biometric requiredHigh-value transactions, strict identity requirements
urn:acr.login.gov:verified-facial-match-preferredIAL2 + facial preferredUpgrade path — users without cameras can still proceed

AAL (Authentication Assurance Level) modifiers — combine with ACR:

AAL valueMeaning
urn:gov:gsa:ac:classes:sp:PasswordProtectedTransport:duoDefault 2FA
http://idmanagement.gov/ns/assurance/aal/2Strict AAL2 (non-remembered device)
http://idmanagement.gov/ns/assurance/aal/2?phishing_resistant=trueHardware key / passkey required
http://idmanagement.gov/ns/assurance/aal/2?hspd12=truePIV/CAC required

Pass multiple ACR values space-separated in the acr_values parameter.


Step 1 — Authorization request

GET https://idp.int.identitysandbox.gov/openid_connect/authorize
  ?acr_values=urn:acr.login.gov:auth-only
  &client_id=YOUR_CLIENT_ID
  &nonce=RANDOM_22_CHAR_MIN
  &prompt=select_account
  &redirect_uri=https://yourapp.agency.gov/auth/callback
  &response_type=code
  &scope=openid+email+profile
  &state=RANDOM_22_CHAR_MIN

Rules:

  • state and nonce must be ≥ 22 characters — login.gov will reject shorter values
  • prompt=select_account is required (no other values supported)
  • redirect_uri must exactly match a registered URI in the Partner Portal
  • Store state in session; store nonce for id_token validation

Step 2 — Handle the callback

GET https://yourapp.agency.gov/auth/callback
  ?code=AUTH_CODE
  &state=STATE_FROM_STEP1

Verify state matches the value you stored. Then exchange the code for tokens.


Step 3 — Token exchange

POST https://idp.int.identitysandbox.gov/api/openid_connect/token
Content-Type: application/x-www-form-urlencoded

client_assertion=SIGNED_JWT
&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer
&code=AUTH_CODE_FROM_CALLBACK
&grant_type=authorization_code

Build the client_assertion JWT

import jwt, time, uuid
from cryptography.hazmat.primitives.serialization import load_pem_private_key

private_key = load_pem_private_key(open("private.pem", "rb").read(), password=None)

claims = {
    "iss": CLIENT_ID,          # your client_id
    "sub": CLIENT_ID,          # also client_id
    "aud": "https://idp.int.identitysandbox.gov/api/openid_connect/token",
    "jti": str(uuid.uuid4()),  # unique per request
    "exp": int(time.time()) + 300,  # 5 minutes max
}

assertion = jwt.encode(claims, private_key, algorithm="RS256")

Token response

{
  "access_token": "TOKEN",
  "token_type": "Bearer",
  "expires_in": 900,
  "id_token": "SIGNED_JWT"
}

Validate the id_token

  1. Fetch login.gov's public keys from the JWKS endpoint
  2. Verify signature using RS256 with the matching key (kid header)
  3. Verify iss = login.gov IdP URL
  4. Verify aud = your client_id
  5. Verify nonce = the nonce you sent in Step 1
  6. Verify exp is in the future

Step 4 — Fetch user attributes

GET https://idp.int.identitysandbox.gov/api/openid_connect/userinfo
Authorization: Bearer ACCESS_TOKEN

Response attributes depend on scopes requested:

ScopeAttributes returned
openidsub (UUID, stable per client)
emailemail, email_verified
all_emailsall_emails array
phonephone, phone_verified
profilegiven_name, family_name, birthdate
profile:verified_atverified_at (Unix timestamp of identity verification; null if not verified) — not included in bare profile
profile:namegiven_name, family_name
profile:birthdatebirthdate
addressaddress object (street, city, state, zip)
social_security_numbersocial_security_number
x509x509_subject, x509_issuer, x509_presented (PIV/CAC)

Note: social_security_number and identity attributes require urn:acr.login.gov:verified or higher. Login.gov will reject the request if the ACR level doesn't support the requested scope.


Sandbox setup

  1. Register at https://dashboard.int.identitysandbox.gov
  2. Create an app — get a client_id
  3. Upload your public.crt
  4. Set redirect_uri values (can be http://localhost for dev)
  5. Test users: create accounts at https://idp.int.identitysandbox.gov
  6. For IAL2 testing: the sandbox has a bypass — enter any SSN/address and it will pass

Production deployment checklist

  • Inter-Agency Agreement (IAA) signed with GSA
  • Production app registered in https://dashboard.login.gov
  • Production key pair generated (separate from sandbox)
  • Redirect URIs use HTTPS with valid TLS
  • state and nonce are cryptographically random, stored server-side
  • id_token signature validation implemented
  • sub (UUID) used as the stable user identifier — not email (email can change)
  • Logout: redirect to https://secure.login.gov/openid_connect/logout?client_id=...&post_logout_redirect_uri=...&state=...

Common errors

ErrorCauseFix
invalid_clientWrong client_id or bad JWT signatureVerify client_id matches Partner Portal; check key pair matches
invalid_request: nonce too shortnonce < 22 charsGenerate ≥ 22 char random string
redirect_uri_mismatchURI not registeredAdd exact URI to Partner Portal (including trailing slash)
invalid_scopeScope not allowed for ACR levelUse urn:acr.login.gov:verified for identity attributes
id_token nonce mismatchNonce not stored/retrieved correctlyStore nonce in server-side session before redirect
exp claim rejectedclient_assertion JWT older than 5 minAlways generate assertion fresh per token request

Example prompts

  • "How do I integrate our agency web app with login.gov for federal SSO?"
  • "Generate the private_key_jwt client assertion JWT for the token exchange."
  • "What ACR value do I use if I need identity verification but not facial recognition?"
  • "My token request returns invalid_client. What could cause that?"
  • "How do I request the user's SSN and address attributes after they authenticate?"
  • "Walk me through setting up the login.gov sandbox — discovery URL, test users, IAL2 bypass."
  • "What's the production deployment checklist before we go live with login.gov?"

Related skills

  • arcgis-enterprise-k8s — if fronting ArcGIS with federal identity via login.gov
  • ubuntu24-stig — OS hardening for the server running the integration

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.