Authentication Workflows
This tutorial demonstrates how to implement various authentication workflows with the EntityDataManager.
Basic Authentication
// Check authentication status
const isAuthenticated = await manager.isAuthenticated();
console.log("Currently authenticated:", isAuthenticated);
// Login with username/password (default provider)
const credentials: PasswordCredentials = {
username: "admin@example.com",
password: "password123"
};
await manager.login(credentials);
console.log("Login successful");
// Verify authentication
const authenticated = await manager.isAuthenticated();
console.log("Authentication status:", authenticated);
Provider-Specific Authentication
// Login with Auth0
await manager.login(null, "auth0");
// Login with Keycloak
await manager.login(null, "keycloak");
// Login with token
const tokenCredentials: TokenCredentials = {
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
};
await manager.login(tokenCredentials, "auth0");
Token Management
// Handle authentication callback (for OAuth flows)
await manager.handleCallback("auth0");
// Logout
await manager.logout();
console.log("Logged out successfully");