İçeriğe geç

Referans

OpenID Connect

PHP kullanmıyor musunuz? Identvia standart bir OpenID Connect sağlayıcısıdır. Sertifikalı herhangi bir kitaplığı aşağıdaki issuer’a yöneltin.

Yapay zekâ ajanınız için istemi kopyalayın

Kodlama ajanı mı kullanıyorsunuz? Bu istem onu bu belgelere yönlendirir ve uyması gereken kuralları listeler. Yazdıklarını diğer kodlar gibi inceleyin.

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.

Keşif

Issuerhttps://id.identvia.com
Keşifhttps://id.identvia.com/.well-known/openid-configuration
Yetkilendirmehttps://id.identvia.com/oauth/authorize
Jetonhttps://id.identvia.com/oauth/token
Userinfohttps://id.identvia.com/oauth/userinfo
JWKShttps://id.identvia.com/oauth/jwks.json
İptalhttps://id.identvia.com/oauth/revoke
Oturumu sonlandırhttps://id.identvia.com/oauth/logout

Identvia’nın uyguladığı kurallar

  • Yalnızca yetkilendirme kodu akışı (response_type=code). Örtük veya hibrit yok.
  • Herkese açık istemciler için S256 ile PKCE zorunludur (tek sayfa, mobil ve yerel uygulamalar) ve tüm istemciler için önerilir. client secret ile kimlik doğrulayan sunucu tarafı uygulamalar bunu kullanmayabilir, OpenID Connect’in izin verdiği gibi nonce da göndermeyebilir.
  • Yönlendirme URI’leri karakter karakter tam eşleşir. Joker veya parça yok. http://localhost yalnızca Development ortamlarında.
  • Yetkilendirme kodları tek kullanımlıktır ve 60 saniye sonra sona erer. Yeniden kullanmak ürettiği jetonları iptal eder.
  • ID token’lar RS256 ile imzalanır. Access token’lar 10 dakika sürer. Yenileme jetonları (kapsam offline_access) her kullanımda döner; eskisini yeniden oynatmak zinciri iptal eder.
  • Geri çağırma iss içerir (RFC 9207). Kontrol edin.
  • sub pairwise’dır: her uygulama aynı kişi için farklı, kararlı bir ID görür.

1. Yetkilendirme isteği

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

İsteğe bağlı: prompt=none|login|consent, max_age, login_hint.

2. Jeton isteği

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=…

Herkese açık istemciler gizli yerine gövdede client_id gönderir.

Response
{
  "token_type": "Bearer",
  "access_token": "eyJ…",
  "expires_in": 600,
  "id_token": "eyJ…",
  "refresh_token": "…",          // yalnızca offline_access ile
  "scope": "openid email profile"
}

3. ID token’ı doğrula

  1. Eşleşen kid’li JWKS anahtarıyla imzayı doğrulayın. Yalnızca RS256 kabul edin.
  2. iss https://id.identvia.com’ye eşit; aud client ID’nizi içerir; azp varsa client ID’nizdir.
  3. exp gelecekte, iat değil (bir dakika sapmaya izin verin).
  4. nonce gönderdiğinizle eşit.
  5. max_age gönderdiyseniz auth_time’ı kontrol edin.

Claim’ler

KapsamClaim’ler
openidsub, auth_time, amr
emailemail, email_verified (yalnızca kullanıcı paylaşırsa)
profilename, given_name, family_name, picture, updated_at (yalnızca kullanıcının paylaştığı)
offline_accessBir yenileme jetonu

Kullanıcılar onay ekranında ne paylaşacaklarını seçer; istediğiniz kapsam claim’siz dönebilir. Bunu yönetin.

Yerel ve masaüstü uygulamalar

Ortamı geliştirici portalında Yerel & masaüstü uygulama olarak kaydedin. Yönlendirme URI'leri şunları kullanabilir:

  • Özel kullanım URI şemaları ters alan biçiminde (RFC 8252 §7.1), örn. com.example.app:/oauth/identvia. myapp: gibi kısa şemalar reddedilir.
  • Talep Edilen HTTPS Uygulama Bağlantıları (iOS Universal Links / Android App Links).
  • Loopback http://127.0.0.1:{port}/… veya http://[::1]:{port}/…. Herhangi bir port eşleşir; yol tam olarak eşleşmelidir (RFC 8252 §7.3).

iOS 17.4'ten eski: ASWebAuthenticationSession güvenilir bir şekilde https:// geri dönüşleri döndürmez. Bu sürümlerde özel kullanım şemasını tercih edin; iOS 17.4 ve sonrası için Universal Links kullanın.