App Auth: Complete End-User Authentication & Role-Based Access Control
App Auth delivers turnkey user management for apps built on Apps Manager. Provision user accounts, verify credentials with secure bcrypt hashing, issue JWT access & refresh tokens, enforce Role-Based Access Control (RBAC), and manage end-user sessions from the dashboard.
Overview & Architecture
Building auth from scratch means implementing password hashing, JWT generation, token refresh rotations, password reset emails, and RBAC middleware. App Auth provides ready-to-use endpoints scoped specifically to your App Public ID at /apps/:appPublicId/auth. Your frontend or mobile app can register users, log them in, inspect profile sessions, and control access permissions effortlessly.
Core Capabilities
Detailed Implementation Guides
1Authentication Endpoints & Data Contracts
App Auth endpoints are exposed at /apps/:appPublicId/auth/ and require no backend server setup.
You can bind Database Collections to App Auth in Backend Studio! Configure collections to allow "Public Read, Authenticated Write", or "Owner Only" so users can only view and modify their own records.
| Action | Method & Path | Payload / Headers | Result |
|---|---|---|---|
| Sign Up | POST .../auth/register | { email, password, name, metadata } | Creates user account and returns JWT token + user profile |
| Sign In | POST .../auth/login | { email, password } | Validates credentials and returns JWT token + user profile |
| Get Profile | GET .../auth/me | Authorization: Bearer <USER_JWT> | Returns authenticated user information and active role |
| Refresh Token | POST .../auth/refresh | { refreshToken } | Issues fresh JWT access token without forcing user re-login |
| Forgot Password | POST .../auth/forgot-password | { email } | Generates password reset token and dispatches reset instructions |
| Reset Password | POST .../auth/reset-password | { token, newPassword } | Applies new password and invalidates previous sessions |
REST API Reference
Register a new end-user account with email, password, and custom attributes
Authenticate an existing user with email and password
Retrieve currently authenticated user session details
Production Code Integration
import { useState, useEffect, createContext, useContext } from 'react';
const BASE_URL = 'https://apps-manager.in';
const APP_PUBLIC_ID = 'app_pub_789456';
interface User {
_id: string;
email: string;
name: string;
role: string;
}
export function useAppAuth() {
const [user, setUser] = useState<User | null>(null);
const [token, setToken] = useState<string | null>(() => localStorage.getItem('am_user_token'));
const [loading, setLoading] = useState(true);
// Check existing session
useEffect(() => {
async function fetchMe() {
if (!token) {
setLoading(false);
return;
}
try {
const res = await fetch(`${BASE_URL}/apps/${APP_PUBLIC_ID}/auth/me`, {
headers: { 'Authorization': `Bearer ${token}` },
});
if (res.ok) {
const data = await res.json();
setUser(data.user);
} else {
logout();
}
} catch (err) {
logout();
} finally {
setLoading(false);
}
}
fetchMe();
}, [token]);
const login = async (email: string, password: string) => {
const res = await fetch(`${BASE_URL}/apps/${APP_PUBLIC_ID}/auth/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password }),
});
const data = await res.json();
if (!res.ok) throw new Error(data.message || 'Login failed');
localStorage.setItem('am_user_token', data.token);
setToken(data.token);
setUser(data.user);
return data.user;
};
const logout = () => {
localStorage.removeItem('am_user_token');
setToken(null);
setUser(null);
};
return { user, token, loading, login, logout };
}Frequently Asked Questions
Can end-users see or access data from other Apps?
No. Users registered under App A cannot authenticate or access resources in App B. All user tables, tokens, and sessions are strictly scoped by App Public ID.
How long do user JWT tokens remain valid?
Access tokens expire after 7 days by default, while refresh tokens can be configured for 30 days. When an access token expires, the client can call the refresh endpoint to obtain a new token transparently.
Start Building with Apps Manager Today
Build databases, create scraping APIs, convert websites to JSON, and issue Ed25519 cryptographic software licenses in minutes. Zero credit card required.