Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions e2e/dpop/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Public OAuth client identifiers; these are not secrets.
REACT_CLIENT_ID=replace-with-react-client-id
VUE_CLIENT_ID=replace-with-vue-client-id
ANGULAR_CLIENT_ID=replace-with-angular-client-id

# The current FusionAuth tenant issuer.
EXPECTED_ISSUER=https://example.com
FUSIONAUTH_JWKS_URL=http://host.orb.internal:9011/.well-known/jwks.json

# Canonical public origin used for DPoP htu validation.
API_EXTERNAL_ORIGIN=https://api.fusionauth-dpop.orb.local
2 changes: 2 additions & 0 deletions e2e/dpop/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env

46 changes: 46 additions & 0 deletions e2e/dpop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Manual DPoP browser demo

This fixture builds the React, Vue, and Angular SDKs from this checkout, then
serves three minimal browser apps and one DPoP-protected Express API through
OrbStack. OrbStack terminates TLS.

## Configure and start

Prerequisites: OrbStack with Docker Compose, and FusionAuth available at
`https://local.fusionauth.io`.

Create three public FusionAuth applications with Authorization Code and Refresh
Token grants, client authentication disabled, PKCE required with S256, and
asymmetric access-token signing. Use each app URL below as its exact authorized
redirect and logout URL. Add all three origins to FusionAuth CORS and allow the
`Authorization`, `Content-Type`, and `DPoP` headers with `GET`, `POST`, and
`OPTIONS` methods.
Comment thread
mrudatsprint marked this conversation as resolved.

```bash
cd e2e/dpop
cp .env.example .env
# Edit .env with the three public client IDs.
docker compose build
docker compose up -d
docker compose ps
```

Open:

- https://react.fusionauth-dpop.orb.local
- https://vue.fusionauth-dpop.orb.local
- https://angular.fusionauth-dpop.orb.local
- https://api.fusionauth-dpop.orb.local/health

In each app, click **Login**, authenticate, click **Call resource server**, and
confirm the protected response. Click **Logout** to finish.

Stop the fixture with:

```bash
docker compose down
```

The `.env` values are public identifiers, but `.env` is local configuration and
must not contain secrets.

24 changes: 24 additions & 0 deletions e2e/dpop/angular/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:24.15.0-alpine AS sdk-build
WORKDIR /repo
ENV HUSKY=0
COPY package.json yarn.lock tsconfig.json ./
COPY packages ./packages
RUN corepack enable && corepack prepare yarn@1.22.22 --activate
RUN yarn install --frozen-lockfile --ignore-engines --non-interactive
RUN yarn build:sdk-angular

FROM node:24.15.0-alpine AS app-build
WORKDIR /app
ARG CLIENT_ID
RUN corepack enable && corepack prepare yarn@1.22.22 --activate
COPY e2e/dpop/angular/package.json ./
COPY --from=sdk-build /repo/packages/sdk-angular/dist/fusionauth-angular-sdk ./vendor/angular-sdk
RUN yarn install --non-interactive
COPY e2e/dpop/angular/angular.json e2e/dpop/angular/tsconfig.json ./
COPY e2e/dpop/angular/src ./src
RUN test -n "$CLIENT_ID" && sed -i "s|__CLIENT_ID__|$CLIENT_ID|" src/main.ts
RUN yarn build

FROM nginx:1.29-alpine
COPY e2e/dpop/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=app-build /app/dist/angular/browser /usr/share/nginx/html
28 changes: 28 additions & 0 deletions e2e/dpop/angular/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular": {
"projectType": "application",
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular/build:application",
"options": {
"browser": "src/main.ts",
"index": "src/index.html",
"outputPath": "dist/angular",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.json"
}
}
}
}
},
"cli": {
"analytics": false
}
}
24 changes: 24 additions & 0 deletions e2e/dpop/angular/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "dpop-angular-demo",
"private": true,
"version": "0.0.0",
"scripts": {
"build": "ng build"
},
"dependencies": {
"@angular/common": "22.0.0",
"@angular/compiler": "22.0.0",
"@angular/core": "22.0.0",
"@angular/platform-browser": "22.0.0",
"@fusionauth/angular-sdk": "file:vendor/angular-sdk",
"rxjs": "7.8.2",
"tslib": "2.8.1",
"zone.js": "0.15.1"
},
"devDependencies": {
"@angular/build": "22.0.0",
"@angular/cli": "22.0.0",
"@angular/compiler-cli": "22.0.0",
"typescript": "6.0.2"
}
}
12 changes: 12 additions & 0 deletions e2e/dpop/angular/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
Comment thread
mrudatsprint marked this conversation as resolved.
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Angular DPoP demo</title>
<base href="/" />
</head>
<body>
<app-root></app-root>
</body>
</html>
53 changes: 53 additions & 0 deletions e2e/dpop/angular/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Component, inject } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { FusionAuthModule, FusionAuthService } from '@fusionauth/angular-sdk';

const apiUrl = 'https://api.fusionauth-dpop.orb.local/resource';
const appUrl = 'https://angular.fusionauth-dpop.orb.local';

@Component({
imports: [FusionAuthModule],
selector: 'app-root',
standalone: true,
template: `
<main>
<h1>Angular DPoP demo</h1>
@if (fusionAuth.isLoggedInSignal()) {
<button (click)="fusionAuth.logout()">Logout</button>
<button (click)="callResource()">Call resource server</button>
} @else {
<button (click)="fusionAuth.startLogin()">Login</button>
}
<pre>{{ result }}</pre>
</main>
`,
})
class AppComponent {
readonly fusionAuth = inject(FusionAuthService);
result = '';

async callResource() {
try {
const response = await this.fusionAuth.dpopFetch(apiUrl);
const body = await response.text();
this.result = response.ok ? body : `HTTP ${response.status}: ${body}`;
} catch (error) {
this.result = error instanceof Error ? error.message : 'Request failed';
}
}
}

bootstrapApplication(AppComponent, {
providers: [
...FusionAuthModule.forRoot({
clientId: '__CLIENT_ID__',
dpopTokenStorage: 'localStorage',
postLogoutRedirectUri: appUrl,
redirectUri: appUrl,
serverUrl: 'https://local.fusionauth.io',
useDpop: true,
}).providers!,
],
}).catch(() => {
document.body.textContent = 'Application failed to start';
});
14 changes: 14 additions & 0 deletions e2e/dpop/angular/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"lib": ["ES2022", "DOM"],
"module": "preserve",
"moduleResolution": "bundler",
"strict": true,
"target": "ES2022"
},
"angularCompilerOptions": {
"strictTemplates": true
},
"files": ["src/main.ts"]
}
11 changes: 11 additions & 0 deletions e2e/dpop/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:24.15.0-alpine
WORKDIR /app
ENV NODE_ENV=production
RUN corepack enable && corepack prepare yarn@1.22.22 --activate
COPY e2e/dpop/api/package.json ./
RUN yarn install --production --non-interactive
COPY e2e/dpop/api/server.mjs ./
USER node
EXPOSE 3000
CMD ["node", "server.mjs"]

11 changes: 11 additions & 0 deletions e2e/dpop/api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "dpop-resource-server",
"private": true,
"version": "0.0.0",
"type": "module",
"dependencies": {
"cors": "2.8.5",
"express": "5.1.0",
"jose": "6.1.0"
}
}
Loading
Loading