How do you implement OAuth2 authentication in Spring Boot?
Add OAuth2 and OpenID Connect sign-in to a Spring Boot web app with Google, GitHub or a custom provider using Spring Security's oauth2Login.
2,886 posts about Java: questions with answers, tutorials and articles, newest first.
Add OAuth2 and OpenID Connect sign-in to a Spring Boot web app with Google, GitHub or a custom provider using Spring Security's oauth2Login.
AuthenticationManager is the entry point of Spring Security authentication. Learn how ProviderManager works and how to expose the manager as a bean in Spring Security 6.
Configure form login with a SecurityFilterChain bean, a UserDetailsService and a password encoder. Includes a custom login page and success handlers.
SecurityContextHolder gives you the signed-in user anywhere in a Spring app. Learn how it stores context per thread, how to set it safely and how to share it with async code.
Connect a Spring Boot backend to Firebase Realtime Database with the Admin SDK, from credentials and configuration to reads, writes and listeners.
Use RDS automated backups for point-in-time recovery and the AWS SDK for Java v2 to snapshot and restore from Spring Boot. Every restore creates a new instance.
Connect Spring Boot to Amazon RDS MySQL with the right security group, driver, datasource properties and TLS, and keep credentials in Secrets Manager.
Create the RDS instance, lock down its security group and point spring.datasource.url at the endpoint. Covers TLS, secrets, pooling and common errors.
Connect Spring Boot to Amazon RDS with the right security group, a TLS JDBC URL, managed credentials, Spring Data JPA and a sized connection pool.
Invoke AWS Lambda from Spring Boot with the v2 SDK, check status code and functionError, and parse the payload into Java objects safely.
Use the AWS SDK for Java 2.x LambdaClient in Spring Boot to invoke Lambda synchronously or as an event, handle function errors and secure access with IAM.
AWSLambdaClient is the legacy AWS SDK v1 Lambda client. Replace it with a LambdaClient bean from SDK v2 to invoke functions safely from Spring Boot.
Two ways to run Spring Boot on AWS Lambda, Spring Cloud Function and the Serverless Java Container, plus deployment and cold start tips.
Use condition expressions and version attributes with the DynamoDB Enhanced Client in Spring Boot, and handle ConditionalCheckFailedException properly.
Implement LogoutHandler, register it with addLogoutHandler in your SecurityFilterChain, and use a LogoutSuccessHandler to control the response.
@CrossOrigin adds CORS headers to Spring endpoints, but Spring Security must also enable cors() or preflight requests fail. Examples for Spring Security 6.
Learn how Spring Boot 3 protects against CSRF by default, how to send tokens from forms and SPAs, and when it is safe to disable protection.
@Secured applies role-based checks to methods in Spring Security. See how to enable it, how to write role names, and when @PreAuthorize is a better fit.
Replace the generated Spring Security login form with your own page, then configure redirects and handlers using the Spring Security 6 SecurityFilterChain DSL.
UserDetailsService loads a user by username for Spring Security authentication. See a database-backed implementation, configuration and common mistakes.