Using AAF with OIDC
v 1.1
Ray Liu
Document History
Section titled “Document History”| Version | Date | Who | Change Summary |
|---|---|---|---|
| 1.0 | Apr 2026 | RL | Created |
| 1.1 | Jul 2026 | RL | Scope guidance after feedback from Patrick at AAF |
Introduction
Section titled “Introduction”This guide shows how to register an Australian Access Federation (AAF) OpenID Connect service and connect it to a backend-owned login flow.
Use this guide when the frontend should initiate login, but the backend is the one that holds the AAF client secret, exchanges the authorization code, creates the application session, and returns only local session state to the browser.
This guide uses the Flask example using Python, for its code and deployment instructions. A companion Express example implements the same OIDC flow and route contract using Bun and TypeScript.
The AAF registration flow applies to both examples except where step 3 notes a different authentication method. Follow the companion example’s README for its Express-specific installation, configuration, and session guidance.
Before You Start
Section titled “Before You Start”Have these ready:
- AAF login access.
- Permission to register a service for an AAF subscriber organisation.
- For the Flask example, Python 3.11 or later and
uv. - For the Express example, Bun 1.3.14 or later.
- The URL where users start login.
- The backend callback URL that AAF redirects to after login.
For the local demo:
URL: http://localhost:5000/Redirect URL: http://localhost:5000/auth/callbackThe screenshots and example registration values use The University of Melbourne. Substitute the organisation that owns your service and the IdP your users will select.
1. Confirm the IdP Is Available Through AAF
Section titled “1. Confirm the IdP Is Available Through AAF”Before registering a service, confirm that the users’ organisation has an active Identity Provider (IdP) in AAF. There are two ways to check.
Option 1: AAF Subscribers Page
Section titled “Option 1: AAF Subscribers Page”- Open the AAF subscribers page.
- Search for the organisation users will choose during institution discovery.
- Confirm that the expected organisation appears in the public directory.

The AAF subscribers page provides a quick public view of participating organisations.
The subscriber directory may lag behind the active federation metadata, and not every active IdP will necessarily appear there. Use the metadata explorer when the expected organisation is missing or when you want to confirm another organisation.
Option 2: REFEDS Metadata Explorer
Section titled “Option 2: REFEDS Metadata Explorer”- Open the Australian Access Federation in the REFEDS Metadata Explorer.
- Confirm that the IDP entity type is selected.
- Search or browse the entity list for the organisation’s display name or IdP entity ID.
- Confirm that the organisation has an active IdP in the Australian Access Federation metadata.

The REFEDS Metadata Explorer shows IdPs published in the Australian Access Federation metadata and can confirm organisations not shown in the public subscriber directory.
If neither source shows the expected organisation, pause production setup and confirm its federation access with the organisation or AAF Support. It may be available through eduGAIN or another federation path.
2. Start a New OIDC Service in AAF Test
Section titled “2. Start a New OIDC Service in AAF Test”Use the AAF Test Federation first. The test service gives you a client identifier and client secret for local development.
- Open AAF Test Federation Manager.
- Select Login with the AAF.
- Select your organisation and continue the login process.

Select the organisation that lets you manage the service registration.
- On the Federation Manager dashboard, choose Connect a service.

The service registration starts from the Connect a service card.
- Choose OpenID Connect as the protocol.

Choose OpenID Connect for this backend-owned login flow.
3. Register the Local Demo Service
Section titled “3. Register the Local Demo Service”The registered AAF service represents the backend OIDC client. The frontend is still where users start, but the backend is the component that stores the secret and handles the callback.
For the local demo, fill the form with:
Name: OIDC Demo AppDescription: A minimal local OpenID Connect demo application for testing AAF login with University of Melbourne users.URL: http://localhost:5000/Authentication methods: SecretRedirect URL: http://localhost:5000/auth/callbackOrganisation: The University of MelbourneFor the Flask example used throughout this guide, select Secret because the backend can store the client secret safely.
The Express example also uses PKCE, so select Secret and PKCE when registering a service for that implementation. If you test both authentication methods, use separate AAF client registrations so that each registration matches its implementation.
Do not put the client secret in frontend JavaScript.

The Flask backend serves both the frontend HTML and the API on the same port.
Select Register Service.
4. Save the Secret and Activate the Service
Section titled “4. Save the Secret and Activate the Service”After registration, AAF shows the client secret once.
- Copy the secret immediately and store it in your backend
.envfile asAAF_CLIENT_SECRET. - Review the service details.
- Select Activate.

Copy the secret before leaving the page, then activate the test service.
After activation, open the service details page.

The service details page lets you review the active client configuration.
Copy the Identifier into your backend .env file as AAF_CLIENT_ID.

AAF says new test services can take up to two hours before they can be used, so wait if the flow fails immediately after registration.
5. Select Only the Required Scopes
Section titled “5. Select Only the Required Scopes”Open the registered service and select the Scopes tab.
If Selected Scopes is empty, Federation Manager uses all scopes from the incoming OIDC request. Explicitly selecting the minimum required scopes limits the user information that the AAF Central OIDC Proxy can release to the application.

This screenshot shows the initial empty state, which uses the default behavior. Add an explicit subset containing only the scopes the application needs.
For the local demo, add only:
openidfor OIDC authentication and the signed-in user’s subject identifier.profilefor basic profile claims such as the user’s name.emailfor email claims when the user’s home organisation provides them.
After adding them, confirm that all three appear under Selected Scopes. Scope changes may take up to two hours to appear on attribute-release consent pages.
These selections match the scopes requested by the backend in step 6. Do not add
other scopes, such as the eduPerson scopes, unless the application has a
documented requirement for those attributes.
Requesting a scope does not guarantee that every corresponding claim will be returned. The application must handle optional profile and email claims being absent when the user’s home organisation does not release them.
6. Configure the Local Flask Backend
Section titled “6. Configure the Local Flask Backend”The Flask backend is the OIDC Relying Party for the Flask example. It starts the AAF redirect, handles the callback, exchanges the authorization code for tokens, reads user claims, and creates the application session cookie.
Dependencies are declared in pyproject.toml, so uv manages the local Python environment on first run.
[project]dependencies = [ "authlib", "flask", "python-dotenv", "requests",]Create local configuration:
cd example-projects/aai-aaf-pythoncp .env.example .envuv run python -c "import secrets; print(secrets.token_urlsafe(32))"Fill in .env:
FLASK_SECRET_KEY=<generated-secret>AAF_CLIENT_ID=<identifier-from-aaf>AAF_CLIENT_SECRET=<secret-from-aaf>AAF_DISCOVERY_URL=https://central.test.aaf.edu.au/.well-known/openid-configurationAAF_REDIRECT_URI=http://localhost:5000/auth/callbackThe backend loads those values before Flask starts:
load_dotenv()
REQUIRED_ENV_VARS = [ "FLASK_SECRET_KEY", "AAF_CLIENT_ID", "AAF_CLIENT_SECRET", "AAF_DISCOVERY_URL", "AAF_REDIRECT_URI",]Register AAF with Authlib using the discovery URL and requested scopes:
oauth.register( name="aaf", client_id=config["AAF_CLIENT_ID"], client_secret=config["AAF_CLIENT_SECRET"], server_metadata_url=config["AAF_DISCOVERY_URL"], client_kwargs={ "scope": "openid email profile", "token_endpoint_auth_method": "client_secret_post", },)Start login by redirecting the browser to AAF:
@app.get("/auth/login")def login(): return oauth.aaf.authorize_redirect(config["AAF_REDIRECT_URI"])Handle the callback by exchanging the code and storing minimal claims in the session:
@app.get("/auth/callback")def auth_callback(): token = oauth.aaf.authorize_access_token() userinfo = token.get("userinfo") or oauth.aaf.userinfo(token=token)
session["user"] = { "sub": userinfo.get("sub"), "name": userinfo.get("name"), "email": userinfo.get("email"), "preferred_username": userinfo.get("preferred_username"), }
return redirect("/?view=protected")The runnable Flask and Express examples also expose raw_claims so developers
can inspect the AAF response during local testing. This is development-only
behavior. Remove raw_claims before production and retain only the claims the
application needs.
Run the backend:
uv run app.pyOpen:
http://localhost:50007. Configure the Local Flask Frontend
Section titled “7. Configure the Local Flask Frontend”The frontend HTML lives in templates/index.html and is served by Flask at GET /. Because the browser and the API share the same origin, there is no cross-origin setup required.
Start login with a browser redirect. This keeps the OAuth flow out of frontend state:
function startLogin() { window.location.href = "/auth/login";}Use relative paths and same-origin credentials for API requests so Flask can read the session:
async function fetchMe() { const response = await fetch("/api/me", { credentials: "same-origin", });
return response.json();}
The static frontend starts the login flow by redirecting the browser to the Flask backend.
8. Test the Login Flow
Section titled “8. Test the Login Flow”- Open
http://localhost:5000. - Select Login with AAF.
- Confirm that AAF redirects to
http://localhost:5000/auth/callback. - Confirm that the backend redirects the browser to
http://localhost:5000/?view=protected. - Confirm that the protected view shows user claims from
/api/me.

After the callback succeeds, the frontend reads the Flask session through backend APIs and displays the returned claims.
9. Troubleshoot the Local Demo
Section titled “9. Troubleshoot the Local Demo”Check these first if login fails:
- The Redirect URL registered in Federation Manager at step 3 must exactly match
AAF_REDIRECT_URIin the.envfile. - The test service has finished provisioning.
- The backend has the current client identifier and secret.
- The backend requests only scopes allowed for the service.
- Frontend fetch calls use
credentials: "same-origin". - The Flask example’s session cookie is not blocked by browser settings.
Discussion: Deploying the Flask Example Beyond the Local Demo
Section titled “Discussion: Deploying the Flask Example Beyond the Local Demo”This section covers the Flask example. Treat cloud deployment as a separate design decision because it changes URLs, secrets, cookies, CORS, monitoring, and the AAF registration. For Express-specific configuration and session requirements, refer to the Express example README.
Production URL Shape
Section titled “Production URL Shape”Choose stable HTTPS URLs before registering a production AAF service.
The simplest approach keeps frontend and backend on the same domain, the same way the local demo does:
URL: https://app.example.org/Redirect URL: https://app.example.org/auth/callbackThen update backend configuration:
AAF_DISCOVERY_URL=https://central.aaf.edu.au/.well-known/openid-configurationAAF_REDIRECT_URI=https://app.example.org/auth/callbackIf you later separate the frontend to its own CDN origin (for example S3 + CloudFront at https://app.example.org with the API at https://api.example.org), that becomes a cross-origin deployment. You will need to add flask-cors back, configure CORS(app, origins=["https://app.example.org"], supports_credentials=True), and switch fetch calls back to credentials: "include". Register the public frontend URL in AAF as the service URL and update AAF_REDIRECT_URI to the API callback.
Backend Deployment Notes
Section titled “Backend Deployment Notes”On AWS, a typical backend path is ECS Fargate, App Runner, Elastic Beanstalk, or Lambda behind API Gateway if the Flask app is adapted for Lambda. Put it behind HTTPS using ACM with an Application Load Balancer, CloudFront, or API Gateway.
Store these values outside the image and inject them at deploy time:
FLASK_SECRET_KEYAAF_CLIENT_IDAAF_CLIENT_SECRETAAF_DISCOVERY_URLAAF_REDIRECT_URIUse AWS Secrets Manager or SSM Parameter Store for AAF_CLIENT_SECRET and FLASK_SECRET_KEY. Build from pyproject.toml; once dependency versions are final, commit and deploy with uv.lock.
For Google Cloud, the equivalent options are Cloud Run, App Engine, or GKE with secrets stored in Secret Manager.
Frontend Deployment Notes
Section titled “Frontend Deployment Notes”When Flask serves the frontend (the same-origin approach), the HTML in templates/index.html is deployed with the backend container. On AWS that is ECS Fargate, App Runner, Elastic Beanstalk, or Lambda with a web adapter. On Google Cloud that is Cloud Run or App Engine.
The frontend uses relative paths, so no URL configuration is needed:
window.location.href = "/auth/login";
await fetch("/api/me", { credentials: "same-origin" });Do not store AAF access tokens, ID tokens, or the AAF client secret in browser storage.
Cookie and CORS Notes
Section titled “Cookie and CORS Notes”For production HTTPS, update the backend session configuration:
app.config.update( SESSION_COOKIE_HTTPONLY=True, SESSION_COOKIE_SAMESITE="Lax", SESSION_COOKIE_SECURE=True,)No CORS configuration is needed when the frontend is served from the same origin as the API. If you later move the frontend to a separate CDN origin, add flask-cors and configure CORS as described in the production URL shape note above.
Production AAF Registration
Section titled “Production AAF Registration”Register production only after the public URLs are stable.
- Open AAF Production Federation Manager.
- Register a new OpenID Connect service.
- Use the production application URL as the service URL and the callback as the Redirect URL.
URL: https://app.example.org/Redirect URL: https://app.example.org/auth/callbackAuthentication Methods: SecretOrganisation: <your AAF subscriber organisation>Copy the production Identifier and Secret into the production secret store, allow the required scopes, and wait for organisational or AAF approval before testing production login.
When deploying the Express example instead, register it with Secret and PKCE to match its authorization request.
Operational Notes
Section titled “Operational Notes”Before handing the service to users:
- Record the AAF service name, owner, redirect URIs, and scopes.
- Record where
AAF_CLIENT_SECRETandFLASK_SECRET_KEYare stored. - Document who can rotate the AAF secret.
- Add a smoke test for
/auth/login,/auth/callback,/api/me, protected routes, and logout. - Keep only the claims required by the application in its session.
- Remove development-only
raw_claimsstorage and display.