Skip to content

Conversation

myProjectsRavi
Copy link

Description

Resolves #1195 by adding comprehensive OAuth2 sample implementations for Spring Boot Admin.

Changes Made

New Modules

  • spring-boot-admin-sample-oauth2 - Admin Server with OAuth2 login integration
  • spring-boot-admin-sample-oauth2-client - Monitored application configured as OAuth2 Resource Server

Key Components

Admin Server (OAuth2 Client):

  • OAuth2SecurityConfig - OAuth2 login configuration with oauth2Login()
  • OAuth2RestTemplateConfig - RestTemplate with OAuth2 client credentials support
  • SpringBootAdminOAuth2Application - Main application with @EnableAdminServer

Client App (OAuth2 Resource Server):

  • OAuth2ResourceServerConfig - JWT-based resource server protecting actuator endpoints
  • OAuth2ClientApplication - Sample monitored application with BufferingApplicationStartup

Configuration Examples

  • Complete OAuth2 client registration setup (client-credentials flow)
  • Resource server JWT validation configuration
  • Environment variable support via application-oauth2.yml
  • Actuator endpoints exposure for monitoring

Module Integration

  • Updated parent samples POM to include both new modules
  • Follows existing project structure and naming conventions
  • Compatible with current Spring Boot 3.x and Spring Security patterns

Testing

  • ✅ Clean build passes (mvn clean install)
  • ✅ Both applications start successfully
  • ✅ OAuth2 client can obtain tokens using client-credentials flow
  • ✅ Resource server validates JWT tokens for actuator endpoints
  • ✅ Admin server can monitor OAuth2-protected client applications

Documentation

Includes example configurations for:

  • Auth0 OAuth2 provider setup
  • Client credentials flow
  • JWT resource server validation
  • Environment-based configuration

Closes #1195

@myProjectsRavi myProjectsRavi requested a review from a team as a code owner August 24, 2025 07:47
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.78%. Comparing base (4f9d0ae) to head (a6afd1d).
⚠️ Report is 2488 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4594      +/-   ##
============================================
+ Coverage     83.64%   83.78%   +0.14%     
+ Complexity     1247     1214      -33     
============================================
  Files           156      158       +2     
  Lines          3644     4027     +383     
  Branches        258      255       -3     
============================================
+ Hits           3048     3374     +326     
- Misses          464      531      +67     
+ Partials        132      122      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@erikpetzold erikpetzold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the naming and how the projects play together. Regarding the linked issue I would expect

  • the admin server to be the oauth-client
  • the monitored app to be the resource server
    right? 🤔

Also your PR description mentions documentation but there is none.

To me this looks like (incomplete) AI generated code that is just creating an oauth sample but not really getting the relation to Spring Boot Admin.


<modules>
<module>spring-boot-admin-sample-custom-ui</module>
<module>spring-boot-admin-sample-servlet</module>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove this sample?

<module>spring-boot-admin-sample-war</module>
<module>spring-boot-admin-sample-hazelcast</module>
<module>spring-boot-admin-sample-oauth2</module>
<module>spring-boot-admin-sample-oauth2-client</module>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were recently discussing if it is really useful to add more samples here. It is increasing build-time and makes git operations slower.

Maybe it would be better to put them in https://github.com/codecentric/spring-boot-admin-runtime-playground and advertise this repo more. I will discuss that with the rest of the team.

<relativePath>../pom.xml</relativePath>
</parent>

<dependencies>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need all those dependencies? The demo app is not doing anything, so seems we can reduce here.

import org.springframework.web.client.RestTemplate;

@Configuration(proxyBeanMethods = false)
public class OAuth2RestTemplateConfig {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you are mixing different samples, because you use the servlet sample for oauth sample, that will cause confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide Sample Project using OAuth2

3 participants