参考
OpenID Connect
不用 PHP?Identvia 是标准 OpenID Connect 提供方。使用任何已认证库并指向下方 issuer。
复制给你的 AI 代理用的提示词
在用编程代理?这段提示词会把它指向这些文档,并列出它必须遵守的规则。像审查其他代码一样审查它写的代码。
You are helping me add "Sign in with Identvia" to my app (PHP). Identvia is an OpenID Connect provider.
Read these first (they are plain Markdown and are the source of truth; prefer them over anything you remember):
- https://id.identvia.com/developers/docs/quickstart.md
- https://id.identvia.com/developers/docs/oidc.md
- https://id.identvia.com/developers/docs/security.md
- Discovery: https://id.identvia.com/.well-known/openid-configuration
Stack: plain PHP 8.1+ (no framework). Use the official SDK identvia/identvia-php (composer require identvia/identvia-php, or the zip with vendor/ from https://id.identvia.com/developers/docs/php for hosts without Composer). Create identvia.php (config), login.php (redirectToSignIn), callback.php (handleCallback, then session_regenerate_id(true) and store sub) and logout.php. Read secrets from environment variables or a config file outside the web root.
Requirements:
1. Authorization code flow with PKCE (S256 only), a random state and a nonce per sign-in. No implicit flow.
2. Validate the ID token: RS256 signature from the JWKS, iss = https://id.identvia.com, aud contains my client_id, exp/iat, and the nonce.
3. Identify users by sub (it is pairwise: different for every app). Treat email as optional, because the person may choose not to share it.
4. Redirect URIs must match exactly. Keep the client secret and refresh tokens server-side; never log tokens.
5. Ask only for the scopes I need (openid, plus email/profile if used). Handle the user canceling (error=access_denied) gracefully.
Optional, only if I ask for AI-agent access later:
- AgentPass (agents acting for a user with single-use, holder-bound passes): https://id.identvia.com/developers/docs/agentpass.md
- MCP server for agent clients: https://id.identvia.com/developers/docs/mcp.md
- Token exchange, rich authorization requests and CIBA: https://id.identvia.com/developers/docs/delegation.md
Before writing code, tell me which files you will add or change. Don't invent endpoints or options that aren't in the docs; if something is unclear, ask me.
You are helping me add "Sign in with Identvia" to my app (Laravel). Identvia is an OpenID Connect provider.
Read these first (they are plain Markdown and are the source of truth; prefer them over anything you remember):
- https://id.identvia.com/developers/docs/quickstart.md
- https://id.identvia.com/developers/docs/oidc.md
- https://id.identvia.com/developers/docs/security.md
- Discovery: https://id.identvia.com/.well-known/openid-configuration
Stack: Laravel. Use the official SDK identvia/identvia-php (framework-agnostic) from a small service class bound in a service provider, not a hand-written OAuth client. Add GET /auth/identvia/redirect and GET /auth/identvia/callback routes in the web middleware group. After the callback, find-or-create the user by the Identvia sub (not by email), call Auth::login() and $request->session()->regenerate(). Put the client secret in .env and config/services.php.
Requirements:
1. Authorization code flow with PKCE (S256 only), a random state and a nonce per sign-in. No implicit flow.
2. Validate the ID token: RS256 signature from the JWKS, iss = https://id.identvia.com, aud contains my client_id, exp/iat, and the nonce.
3. Identify users by sub (it is pairwise: different for every app). Treat email as optional, because the person may choose not to share it.
4. Redirect URIs must match exactly. Keep the client secret and refresh tokens server-side; never log tokens.
5. Ask only for the scopes I need (openid, plus email/profile if used). Handle the user canceling (error=access_denied) gracefully.
Optional, only if I ask for AI-agent access later:
- AgentPass (agents acting for a user with single-use, holder-bound passes): https://id.identvia.com/developers/docs/agentpass.md
- MCP server for agent clients: https://id.identvia.com/developers/docs/mcp.md
- Token exchange, rich authorization requests and CIBA: https://id.identvia.com/developers/docs/delegation.md
Before writing code, tell me which files you will add or change. Don't invent endpoints or options that aren't in the docs; if something is unclear, ask me.
You are helping me add "Sign in with Identvia" to my app (Symfony). Identvia is an OpenID Connect provider.
Read these first (they are plain Markdown and are the source of truth; prefer them over anything you remember):
- https://id.identvia.com/developers/docs/quickstart.md
- https://id.identvia.com/developers/docs/oidc.md
- https://id.identvia.com/developers/docs/security.md
- Discovery: https://id.identvia.com/.well-known/openid-configuration
Stack: Symfony. Use the official SDK identvia/identvia-php wrapped in a service, plus a custom authenticator (AbstractAuthenticator) on the callback route. Map users by the Identvia sub, not email. Keep the client secret in Symfony secrets or env vars, never in committed config.
Requirements:
1. Authorization code flow with PKCE (S256 only), a random state and a nonce per sign-in. No implicit flow.
2. Validate the ID token: RS256 signature from the JWKS, iss = https://id.identvia.com, aud contains my client_id, exp/iat, and the nonce.
3. Identify users by sub (it is pairwise: different for every app). Treat email as optional, because the person may choose not to share it.
4. Redirect URIs must match exactly. Keep the client secret and refresh tokens server-side; never log tokens.
5. Ask only for the scopes I need (openid, plus email/profile if used). Handle the user canceling (error=access_denied) gracefully.
Optional, only if I ask for AI-agent access later:
- AgentPass (agents acting for a user with single-use, holder-bound passes): https://id.identvia.com/developers/docs/agentpass.md
- MCP server for agent clients: https://id.identvia.com/developers/docs/mcp.md
- Token exchange, rich authorization requests and CIBA: https://id.identvia.com/developers/docs/delegation.md
Before writing code, tell me which files you will add or change. Don't invent endpoints or options that aren't in the docs; if something is unclear, ask me.
You are helping me add "Sign in with Identvia" to my app (Node.js). Identvia is an OpenID Connect provider.
Read these first (they are plain Markdown and are the source of truth; prefer them over anything you remember):
- https://id.identvia.com/developers/docs/quickstart.md
- https://id.identvia.com/developers/docs/oidc.md
- https://id.identvia.com/developers/docs/security.md
- Discovery: https://id.identvia.com/.well-known/openid-configuration
Stack: Node.js. There is no Identvia JavaScript SDK; use a certified OpenID Connect relying-party library (for example openid-client) with discovery from the issuer. Use the authorization code flow with PKCE (S256), state and nonce, keep tokens server-side in the session store, and regenerate the session id after sign-in.
Requirements:
1. Authorization code flow with PKCE (S256 only), a random state and a nonce per sign-in. No implicit flow.
2. Validate the ID token: RS256 signature from the JWKS, iss = https://id.identvia.com, aud contains my client_id, exp/iat, and the nonce.
3. Identify users by sub (it is pairwise: different for every app). Treat email as optional, because the person may choose not to share it.
4. Redirect URIs must match exactly. Keep the client secret and refresh tokens server-side; never log tokens.
5. Ask only for the scopes I need (openid, plus email/profile if used). Handle the user canceling (error=access_denied) gracefully.
Optional, only if I ask for AI-agent access later:
- AgentPass (agents acting for a user with single-use, holder-bound passes): https://id.identvia.com/developers/docs/agentpass.md
- MCP server for agent clients: https://id.identvia.com/developers/docs/mcp.md
- Token exchange, rich authorization requests and CIBA: https://id.identvia.com/developers/docs/delegation.md
Before writing code, tell me which files you will add or change. Don't invent endpoints or options that aren't in the docs; if something is unclear, ask me.
You are helping me add "Sign in with Identvia" to my app (Python). Identvia is an OpenID Connect provider.
Read these first (they are plain Markdown and are the source of truth; prefer them over anything you remember):
- https://id.identvia.com/developers/docs/quickstart.md
- https://id.identvia.com/developers/docs/oidc.md
- https://id.identvia.com/developers/docs/security.md
- Discovery: https://id.identvia.com/.well-known/openid-configuration
Stack: Python. There is no Identvia Python SDK; use a maintained OpenID Connect client library (for example Authlib) with discovery from the issuer. Use the authorization code flow with PKCE (S256), state and nonce, and keep tokens server-side.
Requirements:
1. Authorization code flow with PKCE (S256 only), a random state and a nonce per sign-in. No implicit flow.
2. Validate the ID token: RS256 signature from the JWKS, iss = https://id.identvia.com, aud contains my client_id, exp/iat, and the nonce.
3. Identify users by sub (it is pairwise: different for every app). Treat email as optional, because the person may choose not to share it.
4. Redirect URIs must match exactly. Keep the client secret and refresh tokens server-side; never log tokens.
5. Ask only for the scopes I need (openid, plus email/profile if used). Handle the user canceling (error=access_denied) gracefully.
Optional, only if I ask for AI-agent access later:
- AgentPass (agents acting for a user with single-use, holder-bound passes): https://id.identvia.com/developers/docs/agentpass.md
- MCP server for agent clients: https://id.identvia.com/developers/docs/mcp.md
- Token exchange, rich authorization requests and CIBA: https://id.identvia.com/developers/docs/delegation.md
Before writing code, tell me which files you will add or change. Don't invent endpoints or options that aren't in the docs; if something is unclear, ask me.
发现
| 签发方 | https://id.identvia.com |
|---|---|
| 发现 | https://id.identvia.com/.well-known/openid-configuration |
| 授权 | https://id.identvia.com/oauth/authorize |
| 令牌 | https://id.identvia.com/oauth/token |
| Userinfo | https://id.identvia.com/oauth/userinfo |
| JWKS | https://id.identvia.com/oauth/jwks.json |
| 撤销 | https://id.identvia.com/oauth/revoke |
| 结束会话 | https://id.identvia.com/oauth/logout |
Identvia 强制执行的规则
- 仅授权码流程(response_type=code)。无隐式或混合流程。
- 公共客户端必须使用 S256 PKCE(单页应用、移动应用和原生应用),并建议所有客户端都使用。使用 client secret 进行身份验证的服务器端应用可以省略 PKCE,也可以按 OpenID Connect 的规定省略 nonce。
- 重定向 URI 必须逐字符完全匹配。无通配符、无片段。http://localhost 仅用于 Development 环境。
- 授权码一次性使用,60 秒后过期。重复使用会撤销其产生的令牌。
- ID token 使用 RS256 签名。Access token 有效期 10 分钟。Refresh token(范围 offline_access)每次使用都会轮换;重放旧令牌会撤销整条链。
- 回调包含 iss(RFC 9207)。请检查。
- sub 为 pairwise:每个应用对同一人看到不同且稳定的 ID。
1. 授权请求
HTTP
GET https://id.identvia.com/oauth/authorize
?response_type=code
&client_id=oid_…
&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback
&scope=openid%20email%20profile
&state=<random, 32+ bytes>
&nonce=<random, 32+ bytes>
&code_challenge=<BASE64URL(SHA256(code_verifier))>
&code_challenge_method=S256可选:prompt=none|login|consent、max_age、login_hint。
2. 令牌请求
HTTP
POST https://id.identvia.com/oauth/token
Authorization: Basic base64(client_id:client_secret)
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&code=…&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&code_verifier=…公共客户端在正文中发送 client_id,而不是密钥。
Response
{
"token_type": "Bearer",
"access_token": "eyJ…",
"expires_in": 600,
"id_token": "eyJ…",
"refresh_token": "…", // 仅配合 offline_access
"scope": "openid email profile"
}3. 验证 ID token
- 用 JWKS 中 kid 匹配的密钥验证签名。仅接受 RS256。
- iss 等于 https://id.identvia.com;aud 包含你的 client ID;若存在 azp,则为其为你的 client ID。
- exp 在未来,且 iat 不在未来(允许一分钟偏差)。
- nonce 与你发送的一致。
- 若发送了 max_age,请检查 auth_time。
声明
| 范围 | 声明 |
|---|---|
| openid | sub、auth_time、amr |
| email、email_verified(仅当用户分享时) | |
| profile | name、given_name、family_name、picture、updated_at(仅用户分享的内容) |
| offline_access | 刷新令牌 |
用户在同意屏幕上选择分享内容,因此你请求的范围仍可能缺少其声明。请妥善处理。
本地和桌面应用程序
在开发者门户中将环境注册为 本地 & 桌面应用。重定向 URI 可以使用:
- 私有使用的 URI 方案 采用反向域名形式(RFC 8252 §7.1),例如 com.example.app:/oauth/identvia。短方案如 myapp: 会被拒绝。
- 声明的 HTTPS 应用链接(iOS 通用链接 / Android 应用链接)。
- 回环 http://127.0.0.1:{port}/… 或 http://[::1]:{port}/…。任何端口都匹配;路径必须完全匹配(RFC 8252 §7.3)。
iOS 版本低于 17.4: ASWebAuthenticationSession 不可靠地返回 https:// 回调。在这些版本中,建议使用私有使用方案;从 iOS 17.4 开始使用通用链接。