liveBook · Manning

Endpoint

As explained in Spring Security in Action, Second Edition

An endpoint is a network-accessible entry point representing an operation or resource in an application.

An endpoint is a network-accessible entry point representing an operation or resource in an application. A REST endpoint exposes a route that clients can request, such as GET /hello. section 2.1

Spring Boot can secure an endpoint automatically when the web and security dependencies are present. The default setup applies authentication mechanisms, including HTTP Basic and Form Login, and rejects an unauthenticated request with HTTP 401. section 2.0 section 2.1

Endpoint access can be customized with authorization rules:

  • permitAll() allows every request without authentication. section 7.1.1
  • hasAuthority() requires one specified authority, while hasAnyAuthority() accepts at least one authority from a list. section 7.1.1
  • access() supports custom authorization rules through an AuthorizationManager or an expression such as hasAuthority('WRITE'). section 7.1.1

Protecting /hello

A controller maps GET /hello to a method returning “Hello!”. Without credentials, curl receives 401 Unauthorized. Supplying the generated user and password through HTTP Basic returns “Hello!”. If access requires WRITE, Jane succeeds while John receives 403 Forbidden when only READ is assigned. section 2.1 section 7.1.1

Figure 2.1 Our initial application employs HTTP Basic for user authentication and authorization when accessing an endpoint. It offers a REST endpoint at a specified route (/hello). Upon a successful request, it issues an HTTP 200 status message along with a response body. This instance illustrates the default authentication and authorization mechanisms set up by Spring Security.

Diagram the route, HTTP Basic credentials, successful HTTP 200 response, and Spring Security’s default authentication and authorization flow. section 2.1

How Spring Security in Action, Second Edition covers it

How deep it goes
Defines routes, demonstrates default authentication, and configures authority checks, but stops short of endpoint implementation internals.
Examples
Uses GET /hello, curl requests, HTTP 401 and 403 responses, and READ or WRITE authority assignments.
What it assumes
Uses a small Spring web application and relies on understanding UserDetails and GrantedAuthority contracts for authority-based restrictions.
What you can do after
Configure endpoint authentication and authorization with Spring Security’s SecurityFilterChain and authority-based request rules.
How it connects
Connects REST endpoints with HTTP Basic authentication, Form Login, authorization, and user authorities.

Also explained in

Compare how 26 books explain endpoint →

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.