liveBook · Manning

Credential

As explained in Spring Start Here, Second Edition

A credential is information, such as a username and password, used to verify a user's identity.

A credential is information used to verify a user’s identity, such as a username and password. In a web login, the form sends these values with an HTTP request so the application can check them. section 9.1

A Spring login example stores the submitted username and password in a request-scoped bean, limiting their lifetime to that request. Its credentials are hard-coded for demonstration; real applications store users in a database and encrypt passwords. Use Spring Security for production authentication and authorization rather than implementing them yourself. section 9.1

Login form

The example form asks for a username and password. A controller passes the submitted values to a login processor, which checks them and returns a success or failure result. section 9.1

Figure 9.1 We’ll implement the login functionality in three steps. For each step we implement, we’ll need to use a different bean scope. We use a request-scoped bean to implement the login logic without risking storing the credentials for longer than the login request. We’ll then decide what details we need to store for the authenticated user in a session-scoped bean. Finally, we’ll implement a feature to count all the login requests, and we’ll use an application-scoped bean to keep the number.

Shows how login credentials are kept for the request, before authenticated-user details are handled in session scope. section 9.1

How Spring Start Here, Second Edition covers it

How deep it goes
Defines credentials and traces their submission to a login check, while deferring production authentication to Spring Security.
Examples
Uses a username-and-password form and a hard-coded login check with illustrative credentials.
What you can do after
Understand how a Spring login handler receives credentials and checks them through a request-scoped processor.
How it connects
Connects credentials with HTTP requests, request scope, authentication, authorization, and Spring Security.

Also explained in

Compare how 10 books explain credential →

Related concepts

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