liveBook · Manning

Scope

As explained in Spring Security in Action, Second Edition

An OAuth scope is a named permission value that limits the access or identity information requested by a client.

An OAuth scope is a named permission value that limits the access or identity information requested by a client. OpenID Connect standardizes values such as `openid` and `profile`, while OAuth 2 also permits application-specific names. section 13.4

Use scopes to make token purpose explicit:

  • Assign distinct scopes when separating user-dependent grants from client-independent grants. section 14.3
  • Choose names that reveal the permitted operation, such as `LIVENESS` for checking resource-server availability. section 14.3

Requesting a client-credentials scope

A client registers the `CUSTOM` scope, requests it with `grant_type=client_credentials`, and receives an access token whose response records `scope: CUSTOM`. section 14.3

Listing 14.8 Configuring a registered client for the client credentials grant type
@Bean
public RegisteredClientRepository registeredClientRepository() {
  RegisteredClient registeredClient = 
    RegisteredClient.withId(UUID.randomUUID().toString())
      .clientId("client")
      .clientSecret("secret")
      .clientAuthenticationMethod(
         ClientAuthenticationMethod.CLIENT_SECRET_BASIC)                 #1
      .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS)
      .scope("CUSTOM")                                                   #2
      .build();

    return new InMemoryRegisteredClientRepository(registeredClient);
}

Shows the registered-client configuration that assigns a custom scope to the client-credentials grant. section 14.3

How Spring Security in Action, Second Edition covers it

How deep it goes
Defines standardized and custom values, then demonstrates registration and token-request configuration for client credentials.
Examples
Uses `openid`, `profile`, `CUSTOM`, and `LIVENESS`, plus a cURL request and scoped token response.
What it assumes
Assumes OAuth 2 grant types and client authentication; teaches scope naming through a client-credentials configuration.
What you can do after
Operate/configure registered clients with meaningful scopes and request those scopes during client-credentials token exchange.
How it connects
Connects scopes with OAuth 2, OpenID Connect, access tokens, grant types, client authentication, and resource servers.

Also explained in

Compare how 9 books explain scope →

Related concepts

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