🚀 Documentación de OrzattyAccount
Integración completa de autenticación y autorización OAuth 2.0 con soporte para biometría (WebAuthn/FIDO2).
¿Qué es OrzattyAccount?
OrzattyAccount es una solución de autenticación empresarial similar a Google Account u Auth0. Ofrece:
- ✅ OAuth 2.0 con PKCE seguro
- 🔒 Autenticación biométrica (huella digital, reconocimiento facial)
- 🛡️ 2FA/MFA con TOTP
- 📱 Gestión de sesiones multi-dispositivo
- 🔑 Seguridad de nivel empresarial
🟡 SDK JavaScript
La forma más rápida de integrar autenticación en tu web.
Instalación
<script src="https://orzatty.com/sdk/orzatty-auth.js"></script>
Uso Básico
const orzatty = new OrzattyAuth({
clientId: 'tu_client_id',
redirectUri: 'https://tuapp.com/callback',
apiBase: 'https://orzatty.com'
});
// Mostrar botón de login
orzatty.renderLoginButton('#login-container');
// Manejar callback
orzatty.handleCallback().then(user => {
console.log('Usuario:', user);
localStorage.setItem('access_token', orzatty.getToken());
});
Con Autenticación Biométrica
// El usuario puede elegir biometría directamente
orzatty.renderLoginButton('#login-container', {
theme: 'dark',
enableBiometric: true,
buttonText: 'Inicia sesión con OrzattyAccount'
});
🐍 SDK Python
Para aplicaciones Flask o FastAPI.
Instalación
pip install orzatty-auth
Con Flask
from flask import Flask, redirect
from orzatty_auth import OrzattyAuth, require_auth
app = Flask(__name__)
orzatty = OrzattyAuth(
client_id='tu_client_id',
client_secret='tu_client_secret',
redirect_uri='https://tuapp.com/callback'
)
@app.route('/protected')
@require_auth
def protected_route(user):
return f'Hola {user["email"]}'
@app.route('/callback')
def callback():
user = orzatty.handle_callback()
return redirect('/')
Con FastAPI
from fastapi import FastAPI, Depends
from orzatty_auth import OrzattyAuthDep
app = FastAPI()
orzatty_dep = OrzattyAuthDep(client_id='...', client_secret='...')
@app.get('/protected')
async def protected(user = Depends(orzatty_dep)):
return {'email': user['email']}
📱 SDK Flutter
Para aplicaciones móviles iOS y Android.
Instalación
flutter pub add orzatty_auth
Uso Básico
import 'package:orzatty_auth/orzatty_auth.dart';
final orzatty = OrzattyAuth(
clientId: 'tu_client_id',
scheme: 'com.example.app',
);
// Botón de login
OrzattyLoginButton(
orzatty: orzatty,
onLoginSuccess: (user) {
print('Usuario: ${user.email}');
},
)
// O login manual
final user = await orzatty.login();
final token = orzatty.getToken();
Deep Linking
// AndroidManifest.xml
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.example.app"
android:host="callback" />
</intent-filter>
</activity>
🔐 Autenticación Biométrica
Permite a tus usuarios autenticarse sin contraseña usando huella digital o reconocimiento facial.
POST /api/biometric/register/begin
Inicia el registro de un dispositivo biométrico
Inicia el registro de un dispositivo biométrico
// Solicitar challenge para registro
const beginResponse = await fetch(
`${API_BASE}/api/biometric/register/begin`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
}
);
const { challenge, rp_id } = await beginResponse.json();
// El navegador solicita la biometría del usuario
const credential = await navigator.credentials.create({
publicKey: {
challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)),
rp: { name: 'OrzattyStudios' },
user: {
id: Uint8Array.from('user123', c => c.charCodeAt(0)),
name: 'usuario@orzatty.com',
displayName: 'Usuario'
},
pubKeyCredParams: [
{ type: 'public-key', alg: -7 }
]
}
});
POST /api/biometric/register/complete
Completa el registro biométrico
Completa el registro biométrico
// Completa el registro enviando la credencial
await fetch(
`${API_BASE}/api/biometric/register/complete`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
credential_response: credential,
device_name: 'iPhone 15 Pro'
})
}
);
🔑 Flujo OAuth 2.0
OrzattyAccount implementa OAuth 2.0 con PKCE para máxima seguridad.
Paso 1: Generar PKCE
// Generar code_verifier (43-128 caracteres)
const codeVerifier = generateRandomString(128);
// Crear code_challenge
const encoder = new TextEncoder();
const data = encoder.encode(codeVerifier);
const hash = await crypto.subtle.digest('SHA-256', data);
const codeChallenge = btoa(hash)
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
Paso 2: Redirigir a OrzattyAccount
const authUrl = new URL('https://orzatty.com/oauth/authorize');
authUrl.searchParams.set('client_id', 'tu_client_id');
authUrl.searchParams.set('redirect_uri', 'https://tuapp.com/callback');
authUrl.searchParams.set('response_type', 'code');
authUrl.searchParams.set('scope', 'openid profile email');
authUrl.searchParams.set('code_challenge', codeChallenge);
authUrl.searchParams.set('code_challenge_method', 'S256');
window.location.href = authUrl.toString();
Paso 3: Intercambiar código por token
// En tu backend
const tokenResponse = await fetch(
'https://orzatty.com/oauth/token',
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
grant_type: 'authorization_code',
code: authCode,
client_id: 'tu_client_id',
client_secret: 'tu_client_secret',
code_verifier: codeVerifier,
redirect_uri: 'https://tuapp.com/callback'
})
}
);
const { access_token, id_token } = await tokenResponse.json();
💡 Ejemplos Completos
Aplicación Web Simple (HTML + JS)
<!DOCTYPE html>
<html>
<head>
<script src="https://orzatty.com/sdk/orzatty-auth.js"></script>
</head>
<body>
<div id="login-btn"></div>
<script>
const orzatty = new OrzattyAuth({
clientId: 'tu_client_id',
redirectUri: window.location.origin + '/callback.html',
apiBase: 'https://orzatty.com'
});
orzatty.renderLoginButton('#login-btn', {
theme: 'dark',
enableBiometric: true
});
</script>
</body>
</html>
Verificación de Token en Backend
import jwt
from functools import wraps
SECRET_KEY = 'tu_client_secret'
def verify_token(token):
try:
payload = jwt.decode(
token,
SECRET_KEY,
algorithms=['HS256']
)
return payload
except jwt.InvalidTokenError:
return None
def require_auth(f):
@wraps(f)
def decorated_function(*args, **kwargs):
token = request.headers.get('Authorization', '').replace('Bearer ', '')
user = verify_token(token)
if not user:
return {'error': 'Unauthorized'}, 401
return f(user, *args, **kwargs)
return decorated_function
📞 Soporte
¿Preguntas sobre la integración? Contáctanos:
- 📧 Email: orzattystudios@gmail.com
- 💬 Chat: https://orzatty.com/support
- 🐛 Issues: https://github.com/orzattystudios/orzatty-account/issues