liveBook · Manning

Authorization code flow

As explained in Quarkus in Action

The authorization code flow is an OAuth-based authentication pattern in which a client redirects an unauthenticated user to an identity provider and exchanges a returned authorization code for tokens.

The authorization code flow protects a web application by redirecting unauthenticated requests to an identity provider, then returning the user to the application after authentication. In a Quarkus web application, setting the application type to web_app selects this interaction; service applications instead commonly use an Authorization header. section 6.1.2

A practical configuration combines application-wide protection with session logout:

  • Require authentication for every path by assigning /* to an authenticated permission policy. section 6.1.2
  • Set quarkus.oidc.application-type=web_app to enable the redirect-oriented flow. section 6.1.2
  • Set quarkus.oidc.logout.path=/logout to invalidate the active session. section 6.1.2

Logging in through Keycloak

Refreshing a protected /whoami page redirects the user to Keycloak. Signing in with the configured alice user returns the browser to /whoami as an authenticated user; invoking /logout invalidates the session. section 6.1.2

Listing 6.3 Security-related configuration in the Users service
quarkus.http.auth.permission.all-resources.paths=/*
quarkus.http.auth.permission.all-resources.policy=authenticated
quarkus.oidc.application-type=web_app
quarkus.oidc.logout.path=/logout

Inspect the compact Quarkus configuration that protects all resources, selects the web application flow, and exposes logout. section 6.1.2

How Quarkus in Action covers it

How deep it goes
Explains redirect behavior and Quarkus configuration but does not detail token exchange internals.
Examples
Demonstrates a protected /whoami page, Keycloak login with alice, and a /logout endpoint.
What it assumes
Assumes a Quarkus application and identity-provider configuration while demonstrating authentication from an unauthenticated request.
What you can do after
Operate a Quarkus web application secured through Keycloak redirects and configured session logout.
How it connects
Connects OAuth, OpenID Connect, Keycloak, authentication policies, sessions, and logout.

Also explained in

Compare how 8 books explain authorization code flow →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.