liveBook · Manning

Public client

As explained in Software Security for Developers

A public client is an OAuth client that cannot keep client credentials confidential, such as a client distributed to users or running in a browser.

A public client is an application that cannot store client credentials safely. Mobile apps and single-page web apps are exposed because attackers can inspect the application and recover embedded secrets. section 13.1 section 13.2

This creates a risk in the authorization code flow: an attacker who intercepts an authorization code may use recovered client credentials to obtain an access token and reach protected resources. section 13.1

Protect public clients with these practices:

  • Use PKCE. Generate a random code verifier, derive a code challenge with a one-way hash such as SHA-256, and present the verifier when exchanging the authorization code. section 13.5 section 13.1
  • Pair refresh tokens with PKCE, keep scopes limited, rotate refresh tokens after use, set expiration times, and revoke suspicious tokens. section 13.5 section 13.2
  • Use TLS/SSL for communication among the client, authorization server, and resource server. section 13.2

How Software Security for Developers covers it

How deep it goes
Explains credential exposure, authorization-code interception, PKCE steps, and refresh-token safeguards without detailing implementation code.
Examples
Uses mobile apps, single-page web apps, IoT devices, intercepted authorization codes, and verifier-challenge pairs.
What it assumes
Assumes OAuth 2 tokens and authorization flows while introducing PKCE, refresh-token security, and OpenID Connect connections.
What you can do after
Apply PKCE and safer refresh-token practices when configuring OAuth 2 clients that cannot protect secrets.
How it connects
Connects public clients to OAuth 2, OpenID Connect, authorization code flow, PKCE, refresh tokens, and access tokens.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Security for Developers. The section links point to the parts of the book it draws on.