A minimal standalone Angular 18 app demonstrating the
@authdog/angular SDK.
provideAuthdog({ publicKey, loginPath })— wires the SDK into the standalone app config.authdogInterceptor— functional HTTP interceptor registered viaprovideHttpClient(withInterceptors([authdogInterceptor])). It attachesAuthorization: Bearer <token>to outgoing requests when a session token is present.AuthdogServicesignals —token(),isLoading(),user(),error(),isAuthenticated()drive the navbar and pages reactively. The service bootstraps a?token=query parameter (validated as a JWT) and persists the token inlocalStorage.authdogGuard— gates navigation to/profile.
From the repo root:
bun installSet your public key in src/environments/environment.ts:
export const environment = {
authdogPublicKey: "pk_your_public_key_here",
};Then start the dev server:
moon run angular-app:dev
# or
cd examples/angular && bun run devThe app runs on http://localhost:4205.
| Route | Description |
|---|---|
/ |
Home — explains the demo and shows the auth state. |
/profile |
Calls fetchUser() and renders the profile (guarded). |
authdogGuard is presentational/UX only — it runs entirely in the browser
and is trivially bypassable. It only prevents an unauthenticated user from
navigating to a route so they see a login redirect instead of a broken page.
Every protected operation must be independently enforced server-side: the
API behind the route has to validate the session on each request regardless of
what the guard decides.