Tham chiếu
OpenID Connect
Không dùng PHP? Identvia là nhà cung cấp OpenID Connect chuẩn. Dùng thư viện được chứng nhận bất kỳ và trỏ tới issuer bên dưới.
Sao chép prompt cho tác nhân AI của bạn
Đang dùng tác nhân lập trình? Prompt này hướng nó tới tài liệu này và liệt kê các quy tắc nó phải tuân theo. Hãy xem lại những gì nó viết như mọi đoạn code khác.
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.
Khám phá
| Issuer | https://id.identvia.com |
|---|---|
| Khám phá | https://id.identvia.com/.well-known/openid-configuration |
| Ủy quyền | https://id.identvia.com/oauth/authorize |
| Token | https://id.identvia.com/oauth/token |
| Userinfo | https://id.identvia.com/oauth/userinfo |
| JWKS | https://id.identvia.com/oauth/jwks.json |
| Thu hồi | https://id.identvia.com/oauth/revoke |
| Kết thúc phiên | https://id.identvia.com/oauth/logout |
Quy tắc Identvia áp dụng
- Chỉ luồng mã ủy quyền (response_type=code). Không implicit hay hybrid.
- PKCE với S256 là bắt buộc đối với client công khai (ứng dụng một trang, di động và gốc) và được khuyến nghị cho mọi client. Ứng dụng phía máy chủ xác thực bằng client secret có thể bỏ qua, và cũng có thể bỏ qua nonce, như OpenID Connect cho phép.
- URI chuyển hướng khớp từng ký tự. Không wildcard, không fragment. http://localhost chỉ trong môi trường Development.
- Mã ủy quyền dùng một lần và hết hạn sau 60 giây. Dùng lại sẽ thu hồi token đã tạo.
- ID token ký bằng RS256. Access token sống 10 phút. Refresh token (phạm vi offline_access) xoay mỗi lần dùng; phát lại cái cũ thu hồi cả chuỗi.
- Callback gồm iss (RFC 9207). Hãy kiểm tra.
- sub là pairwise: mỗi ứng dụng thấy ID khác nhau, ổn định cho cùng một người.
1. Yêu cầu ủy quyền
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=S256Tùy chọn: prompt=none|login|consent, max_age, login_hint.
2. Yêu cầu token
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 công khai gửi client_id trong thân thay vì bí mật.
{
"token_type": "Bearer",
"access_token": "eyJ…",
"expires_in": 600,
"id_token": "eyJ…",
"refresh_token": "…", // chỉ với offline_access
"scope": "openid email profile"
}3. Xác thực ID token
- Xác minh chữ ký bằng khóa JWKS có kid khớp. Chỉ chấp nhận RS256.
- iss bằng https://id.identvia.com; aud chứa client ID của bạn; azp nếu có thì là client ID của bạn.
- exp ở tương lai và iat thì không (cho phép lệch một phút).
- nonce bằng cái bạn đã gửi.
- Nếu gửi max_age, kiểm tra auth_time.
Claims
| Phạm vi | Claims |
|---|---|
| openid | sub, auth_time, amr |
| email, email_verified (chỉ khi người dùng chia sẻ) | |
| profile | name, given_name, family_name, picture, updated_at (chỉ những gì người dùng chia sẻ) |
| offline_access | Một refresh token |
Người dùng chọn chia sẻ gì trên màn hình đồng ý, nên phạm vi bạn xin vẫn có thể thiếu claims. Hãy xử lý.
Ứng dụng gốc và máy tính để bàn
Đăng ký môi trường như một Ứng dụng gốc & máy tính để bàn trong cổng thông tin phát triển. Các URI chuyển hướng có thể sử dụng:
- Các sơ đồ URI sử dụng riêng theo dạng miền đảo ngược (RFC 8252 §7.1), ví dụ com.example.app:/oauth/identvia. Các sơ đồ ngắn như myapp: sẽ bị từ chối.
- Liên kết ứng dụng HTTPS đã được yêu cầu (Liên kết toàn cầu iOS / Liên kết ứng dụng Android).
- Loopback http://127.0.0.1:{port}/… hoặc http://[::1]:{port}/…. Bất kỳ cổng nào cũng phù hợp; đường dẫn phải khớp chính xác (RFC 8252 §7.3).
iOS cũ hơn 17.4: ASWebAuthenticationSession không trả về https:// một cách đáng tin cậy. Ưu tiên một sơ đồ sử dụng riêng trên các phiên bản đó; sử dụng Liên kết toàn cầu từ iOS 17.4 trở đi.