İstənilən tətbiqi standart OAuth/OIDC vasitəsilə qoşun.
OpenProof protokol sərhədində proqramlaşdırma dilindən asılı deyil. Faydalı olduqları yerdə təqdim olunan SDK-lərdən istifadə edin və ya HTTPS və OAuth 2.0/OpenID Connect dəstəkləyən istənilən dildən inteqrasiya edin.
İnteqrasiya modeli
Your app ↓ redirect OpenProof /oauth/authorize ↓ authentication / provider / passkey / wallet ↓ your callback?code=...&state=...&iss=... ↓ code + verifier OpenProof /oauth/token ↓ access_token + id_token + optional refresh_token
Məhsul inteqrasiyası üçün OAuth/OIDC token-lərindən istifadə edin. Təhlükəsiz OpenProof sessiya cookie-si OpenProof account/admin origin-inə aiddir və məhsul domain-inizə kopyalanmamalıdır.
Discovery ilə başlayın
https://auth.example.com/.well-known/openid-configuration https://auth.example.com/.well-known/jwks.json
Təkrar istifadə olunan client-lərin authorization, token, UserInfo, introspection və əlaqəli protokol endpoint-lərini öyrənməsi üçün üstün tutulan yol Discovery-dir.
Məhsulunuzu qeyd edin
IAL2 səviyyəsində aktiv owner istifadə edə bilər: /admin/console və ya administration API.
Application yaradın
curl --fail-with-body -b owner.cookies \
https://auth.example.com/admin/applications \
-H 'Content-Type: application/json' \
-d '{
"identifier":"example-web",
"name":"Example Web",
"environment":"production"
}'Client yaradın
curl --fail-with-body -b owner.cookies \
https://auth.example.com/admin/clients \
-H 'Content-Type: application/json' \
-d '{
"application_id":"APPLICATION_ID",
"name":"Example Web",
"kind":"web",
"redirect_uris":["https://app.example.com/oauth/callback"],
"scopes":["openid","profile","offline_access"]
}'| Növ | Tipik client | Secret |
|---|---|---|
browser | SPA / yalnız brauzer | Yoxdur |
native | iOS / Android / desktop | Yoxdur |
web | Server-rendered / backend veb tətbiqi | Bir dəfə qaytarılır; yalnız backend |
service | Maşından maşına | Bir dəfə qaytarılır |
Authorization Code + PKCE S256
Təsadüfi verifier yaradın, onun S256 challenge-ını çıxarın və təsadüfi state and nonce. yaradın. verifier/state/nonce dəyərlərini yalnız həmin giriş əməliyyatının ömrü boyunca saxlayın.
GET /oauth/authorize? response_type=code &client_id=CLIENT_ID &redirect_uri=https://app.example.com/oauth/callback &scope=openid profile offline_access &code_challenge=PKCE_CHALLENGE &code_challenge_method=S256 &state=STATE &nonce=NONCE
Callback zamanı qaytarılan state and iss dəyərinin token exchange-dən əvvəl əməliyyat/konfiqurasiya olunmuş issuer ilə uyğun olmasını tələb edin.
Token exchange
curl --fail-with-body https://auth.example.com/oauth/token \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=authorization_code' \ --data-urlencode 'client_id=CLIENT_ID' \ --data-urlencode 'code=AUTHORIZATION_CODE' \ --data-urlencode 'redirect_uri=https://app.example.com/oauth/callback' \ --data-urlencode 'code_verifier=PKCE_VERIFIER'
ID token yoxlaması
RS256 imzasını issuer JWKS ilə yoxlayın. Ən azı bunları doğrulayın: iss, aud, exp, iat və ilkin nonce; həmçinin nbf, azp and at_hash mövcud olduqda nəzərə alın.
JavaScript / brauzer
Repository brauzer yönümlü bu SDK paketini təqdim edir: @openproof/identity. Bu paket PKCE/state/nonce yaradır, callback state/issuer dəyərlərini yoxlayır və RS256 ID token-i JWKS ilə təsdiqləyir.
import { OpenProofIdentity } from "@openproof/identity";
const identity = new OpenProofIdentity({
issuer: "https://auth.example.com",
clientId: "CLIENT_ID",
redirectUri: "https://app.example.com/oauth/callback",
scopes: ["openid", "profile", "offline_access"]
});
await identity.login();const tokens = await identity.handleCallback(); console.log(tokens.id_token_claims.sub); const profile = await identity.userInfo(tokens.access_token);
Məxfi web or service client secret-i istifadəçiyə göndərilən JavaScript daxilində yerləşdirməyin.
Node.js
Framework üçün yetkin OIDC client istifadə edin və ya sənədləşdirilmiş protokol üçün native fetch() istifadə edin. Məxfi credential-ları server mühitində/secret store-da saxlayın.
const body = new URLSearchParams({
grant_type: "authorization_code",
client_id: process.env.OPENPROOF_CLIENT_ID,
code,
redirect_uri: "https://app.example.com/oauth/callback",
code_verifier: verifier
});
const response = await fetch(
"https://auth.example.com/oauth/token",
{
method: "POST",
headers: {
"content-type":
"application/x-www-form-urlencoded"
},
body
}
);
if (!response.ok) {
throw new Error(
`OpenProof token exchange failed: ${response.status}`
);
}
const tokens = await response.json();JWKS cache, imza yoxlaması və claim validation üçün kriptoqrafik yoxlamanı özünüz yazmaq əvəzinə OIDC/JWT kitabxanasından istifadə edin.
PHP
Dəstəklənən istənilən PHP OAuth/OIDC kitabxanası OpenProof-u issuer kimi istifadə edə bilər. Birbaşa protokol adi HTTPS və form-encoded OAuth-dur.
<?php
$payload = http_build_query([
'grant_type' => 'authorization_code',
'client_id' => getenv('OPENPROOF_CLIENT_ID'),
'code' => $_GET['code'],
'redirect_uri' =>
'https://app.example.com/oauth/callback',
'code_verifier' =>
$_SESSION['openproof_pkce_verifier'],
]);
$curl = curl_init(
'https://auth.example.com/oauth/token'
);
curl_setopt_array($curl, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/x-www-form-urlencoded'
],
]);
$body = curl_exec($curl);
if ($body === false) {
throw new RuntimeException(curl_error($curl));
}ID token-ləri dəstəklənən JWT/OIDC paketi və issuer JWKS ilə doğrulayın. RSA/JWK yoxlamasını ad hoc tətbiq etməyin.
C++
Repository-dəki C++26 SDK bu adla export olunur: openproof.sdk. Transport qatından asılı deyil, buna görə mövcud Boost.Beast, Qt Network və ya libcurl stack-inizi saxlaya bilərsiniz.
import openproof.sdk;
auto config =
openproof::sdk::ClientConfig::create(
"https://auth.example.com",
"CLIENT_ID",
"http://127.0.0.1:49152/callback",
{"openid", "profile", "offline_access"});
openproof::sdk::IdentityClient client{
std::move(config).value()
};
auto login = client.beginLogin();
std::cout <<
login->authorizationUrl()
<< '\n';SDK giriş əməliyyatının yaradılması, authorization-code sorğusunun qurulması, refresh və UserInfo üçün helper-lər verir. Minimal relying-party nümunəsi burada yerləşir: examples/reference-client.
Python, Go, Rust, Java, C# və digər dillər
OpenProof-a xüsusi SDK lazım deyil. Standartlara uyğun OAuth/OIDC kitabxanasını OpenProof issuer ilə konfiqurasiya edin. Minimum təhlükəsiz implementasiya belədir: Discovery → PKCE/state/nonce → authorization redirect → callback yoxlamaları → token exchange → JWKS imza/claim validation → access-token authorization.
UserInfo və refresh
curl --fail-with-body \ https://auth.example.com/oauth/userinfo \ -H 'Authorization: Bearer ACCESS_TOKEN'
curl --fail-with-body \ https://auth.example.com/oauth/token \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=refresh_token' \ --data-urlencode 'client_id=CLIENT_ID' \ --data-urlencode 'refresh_token=REFRESH_TOKEN'
Refresh token-lər rotate olunur. Yeni token-i atomik şəkildə saxlayın və köhnə dəyəri atın. Replay qoruması bütün ailəni revoke edə bilər.
API-nizi qoruyun
Dəqiq audience və məhdud scope-larla resource qeyd edin.
curl --fail-with-body -b owner.cookies \
https://auth.example.com/admin/resources \
-H 'Content-Type: application/json' \
-d '{
"audience":"https://api.example.com/rides",
"name":"Ride API",
"scopes":["rides:read","rides:request"]
}'Backend token etibarlılığını, dəqiq audience-ı, tələb olunan scope-u və məhsulun biznes qaydalarını authorize etməlidir. Etibarlı token təkbaşına kifayət qədər authorization deyil.
Introspection
curl --fail-with-body \ https://auth.example.com/oauth/introspect \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'client_id=CONFIDENTIAL_CLIENT_ID' \ --data-urlencode 'client_secret=CLIENT_SECRET' \ --data-urlencode 'token=ACCESS_TOKEN'
OpenProof gateway
Alternativ olaraq məhsul route-larını OpenProof arxasına yerləşdirin və backend-ə proxy etməzdən əvvəl statik route policy daxilində role, assurance, scope və audience tətbiq edin.
Xidmətdən xidmətə
Bir service client istifadə edin, icazə verilən audience/scope-ları provision edin və sonra access token-i bununla istəyin: client_credentials.
curl --fail-with-body \ https://auth.example.com/oauth/token \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=client_credentials' \ --data-urlencode 'client_id=CLIENT_ID' \ --data-urlencode 'client_secret=CLIENT_SECRET' \ --data-urlencode 'scope=rides:dispatch' \ --data-urlencode 'resource=https://api.example.com/dispatch'
Nəticə yalnız access token-dir. Refresh token və insan sessiyası yoxdur.
Hesab API-ləri
Account self-service və verification delivery aktiv olduqda OpenProof qeydiyyat, təsdiqlənmiş e-poçt/telefon sahibliyi, parol sıfırlama, profil, TOTP, recovery code və passkey imkanlarını təqdim edir.
| Məqsəd | Endpoint |
|---|---|
| Qeydiyyat | POST /account/signup |
| E-poçt yoxlaması | POST /account/email/verify |
| Parol sıfırlamanı başladın | POST /account/password/forgot |
| Parol sıfırlamanı tamamlayın | POST /account/password/reset |
| Profil | GET/PATCH /account/profile |
| TOTP qeydiyyatı | POST /account/totp/start → /complete |
| Passkey girişi | POST /auth/passkey/options → /verify |
| Bağlı üsullar | GET /account/connections |
Məhsul istifadəçisini Google/GitHub e-poçtuna görə key etməyin. İstifadəçi eyni stabil OpenProof subject-i saxlayaraq bir neçə giriş üsulunu bağlaya bilər.
Xəta idarəetməsi və secret gigiyenası
Xətalar stabil code, client üçün təhlükəsiz mesaj və request ID ehtiva edir. Mətnə deyil, code/status-a görə qərar verin. 401-i çatışmayan/etibarsız autentifikasiya, 403-ü kifayət etməyən səlahiyyət/assurance, 409-u state konflikti və 429-u backoff siqnalı kimi qəbul edin.
Parol, TOTP/recovery code, verification secret, authorization code, access/refresh token, məxfi client secret, cookie, DPoP proof və ya private key heç vaxt log edilməməlidir.