शुरू करें
PHP SDK
identvia/identvia-php 1.1.1 उपयोगकर्ताओं को OpenID Connect से साइन इन कराता है। सादा PHP 8.1+, बिना फ्रेमवर्क, साझा होस्टिंग पर।
अपने 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.
आवश्यकताएँ
- PHP 8.1+ with openssl और json (हर जगह मानक)।
- वैकल्पिक: curl (अन्यथा PHP streams) और apcu (अन्यथा कुंजी कैश फ़ाइलें)।
- एक निर्भरता: हस्ताक्षर जाँच के लिए firebase/php-jwt। SDK स्वयं क्रिप्टोग्राफी लागू नहीं करता।
इंस्टॉल
composer require identvia/identvia-phpया cPanel File Manager से zip अपलोड करें और vendor/autoload.php शामिल करें।
कॉन्फ़िगरेशन
$identvia = new Identvia\Sdk\Identvia([
'issuer' => 'https://id.identvia.com', // आवश्यक
'client_id' => 'oid_…', // आवश्यक
'client_secret' => 'ivs_…', // केवल गोपनीय ऐप्स
'redirect_uri' => 'https://example.com/callback.php', // ठीक मेल खाना चाहिए
'scopes' => ['email', 'profile'], // openid हमेशा जोड़ा जाता है
'cache_dir' => __DIR__ . '/../storage/identvia', // वैकल्पिक; डिफ़ॉल्ट: सिस्टम temp डिर
'leeway' => 60, // अनुमत घड़ी विचलन, सेकंड
'timeout' => 10, // HTTP टाइमआउट, सेकंड
]);| विकल्प | नोट्स |
|---|---|
| token_auth | client_secret_basic (डिफ़ॉल्ट) या client_secret_post |
| ca_bundle | होस्ट का प्रमाणपत्र स्टोर पुराना हो तो CA फ़ाइल का पथ। TLS सत्यापन बंद नहीं हो सकता। |
| cache, http, state_store | अपना कैश, HTTP क्लाइंट या state स्टोरेज लाएँ (src/ में इंटरफ़ेस)। |
सीक्रेट कोड रिपॉज़िटरी से बाहर रखें: पर्यावरण चर, या web root के बाहर config.php।
साइन इन
// login.php: उपयोगकर्ता को Identvia भेजता है (state, nonce, PKCE आपके लिए)
$identvia->redirectToSignIn([
'return_to' => '/account', // वैकल्पिक; केवल same-site पथ स्वीकृत
// 'prompt' => 'login', // ताज़ा साइन-इन बाध्य करें
// 'max_age' => 300, // पिछले 5 मिनट में साइन-इन आवश्यक
]);
// callback.php: पूरा करता है
$signIn = $identvia->handleCallback($_GET);
$signIn->sub(); // the user's ID for your app
$signIn->email(); // साझा न हो तो null
$signIn->emailVerified();
$signIn->name();
$signIn->amr(); // e.g. ['hwk', 'user'] for a passkey
$signIn->tokens; // TokenSet: accessToken, refreshToken, idToken, expiresAt
$signIn->returnTo;त्रुटियाँ
| अपवाद | कब | क्या करें |
|---|---|---|
| AuthorizationException | उपयोगकर्ता ने रद्द दबाया (userCancelled()) या Identvia ने त्रुटि दी | मित्रवत संदेश दिखाएँ |
| InvalidStateException | समाप्त, पुन: प्रयुक्त या जाली कॉलबैक; गलत issuer | साइन इन फिर शुरू करें |
| TokenException | कोड एक्सचेंज विफल (invalid_grant, invalid_client) | अपना सीक्रेट जाँचें; फिर शुरू करें |
| ValidationException | ID token जाँच में विफल | उपयोगकर्ता को साइन इन न करें; लॉग करें |
| HttpException | नेटवर्क या TLS विफलता | बाद में पुनः प्रयास |
सभी Identvia\Sdk\Exception\IdentviaException का विस्तार करते हैं।
Userinfo, refresh, revoke, logout
$claims = $identvia->userinfo($tokens->accessToken, $signIn->sub());
// offline_access scope चाहिए। Identvia refresh tokens घुमाता है: हमेशा नया सहेजें।
$tokens = $identvia->refresh($tokens->refreshToken, $signIn->sub());
$identvia->revoke($tokens->refreshToken); // साइन-आउट पर
// वैकल्पिक: Identvia सत्र भी समाप्त करें
header('Location: ' . $identvia->logoutUrl($tokens->idToken, 'https://example.com/'));SDK क्या जाँचता है
- state: यादृच्छिक, एक-बार, 10 मिनट में समाप्त; कई टैब एक साथ साइन इन कर सकते हैं।
- PKCE (S256) हर अनुरोध पर, गोपनीय ऐप्स सहित।
- कॉलबैक पर iss (RFC 9207), पहचान-प्रदाता मिश्रण से बचाव।
- Identvia की प्रकाशित कुंजियों से ID token हस्ताक्षर (केवल RS256/ES256, कभी none या HMAC नहीं); कुंजियाँ एक घंटे कैश, रोटेशन पर एक बार फिर।
- iss, aud, azp, exp, iat, nonce, auth_time बनाम max_age, और at_hash।
- हर कॉल पर प्रमाणपत्र सत्यापन वाला HTTPS; http:// केवल localhost के लिए।
सत्र
SDK लंबित साइन-इन PHP सत्र में रखता है और ज़रूरत पर शुरू करता है। Identvia वापस भेजे तो सत्र कुकी जानी चाहिए — SameSite=Lax (न कि Strict)। सफल साइन-इन के बाद session_regenerate_id(true)।
उदाहरण ऐप: Identvia Notes
सख्त CSP, बटन, साइन-इन/आउट और प्रति-उपयोगकर्ता नोट्स वाला पूरा ऐप। zip में examples/notes-app।
cd identvia-php/examples/notes-app
cp config.example.php config.php # अपना client ID और सीक्रेट चिपकाएँ
php -S localhost:9999 -t public # फिर http://localhost:9999 खोलें