Conversation
Copilot created this pull request from a session on behalf of
OxyFlax
June 8, 2026 09:45
View session
OxyFlax
requested changes
Jun 8, 2026
|
|
||
| @Autowired | ||
| private List<OAuthTokenVerifier> verifiers; | ||
| private static final Logger logger = LoggerFactory.getLogger(OAuthProviderRegistry.class); |
Owner
There was a problem hiding this comment.
@copilot the indentation in this file is broken. Fix it
Author
There was a problem hiding this comment.
Fixed — the file now uses tab indentation consistent with the rest of the codebase in 133cd9a.
Author
OxyFlax
approved these changes
Jun 8, 2026
There was a problem hiding this comment.
Pull request overview
This PR adds AMPECO as an OAuth2 login provider and introduces a reusable “userinfo endpoint” verification mechanism so additional OAuth2/OIDC providers can be enabled via configuration, without writing new Java code.
Changes:
- Added a reusable
AbstractUserInfoOAuthTokenVerifierbase that calls a provideruserinfoendpoint and maps standard OIDC claims intoOAuthUserInfo. - Added configuration-driven provider registration (
OAuthProviderProperties+ConfigurableUserInfoTokenVerifier) and updatedOAuthProviderRegistryto merge built-in and config-declared providers. - Documented OAuth2 usage in
library/README.mdand updated the demoapplication.ymlwith AMPECO and an example config provider.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| library/src/main/java/fr/iolabs/leaf/authentication/oauth/OAuthProviderRegistry.java | Registers built-in and config-defined verifiers and normalizes provider lookup. |
| library/src/main/java/fr/iolabs/leaf/authentication/oauth/OAuthProviderProperties.java | Adds leaf.oauth.providers.* configuration model for userinfo-based providers. |
| library/src/main/java/fr/iolabs/leaf/authentication/oauth/ConfigurableUserInfoTokenVerifier.java | Implements a verifier entirely backed by OAuthProviderProperties claim/userinfo config. |
| library/src/main/java/fr/iolabs/leaf/authentication/oauth/AmpecoTokenVerifier.java | Adds AMPECO provider backed by the generic userinfo verifier base. |
| library/src/main/java/fr/iolabs/leaf/authentication/oauth/AbstractUserInfoOAuthTokenVerifier.java | Provides the shared outbound userinfo call + claim mapping logic. |
| library/README.md | Documents OAuth2 endpoint usage, built-in providers, and config-based extension. |
| demo/src/main/resources/application.yml | Adds AMPECO config and a commented example for adding config-only providers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+42
to
+53
| for (Map.Entry<String, ProviderConfig> entry : this.providerProperties.getProviders().entrySet()) { | ||
| String provider = entry.getKey().toLowerCase(); | ||
| if (Strings.isBlank(entry.getValue().getUserInfoUri())) { | ||
| logger.warn("Skipping OAuth provider '{}': missing userInfoUri", provider); | ||
| continue; | ||
| } | ||
| if (this.verifierMap.containsKey(provider)) { | ||
| logger.warn("Ignoring configuration for OAuth provider '{}': a built-in verifier already exists", provider); | ||
| continue; | ||
| } | ||
| this.verifierMap.put(provider, new ConfigurableUserInfoTokenVerifier(provider, entry.getValue())); | ||
| } |
| if (Strings.isBlank(provider)) { | ||
| throw new BadRequestException("Missing OAuth provider"); | ||
| } | ||
| OAuthTokenVerifier verifier = verifierMap.get(provider.toLowerCase()); |
Comment on lines
+111
to
+114
| HttpResponse<JsonNode> response = Unirest.get(userInfoUri) | ||
| .header("Authorization", "Bearer " + accessToken) | ||
| .header("Accept", "application/json") | ||
| .asJson(); |
Comment on lines
+97
to
+101
| Leaf provides turnkey OAuth2 login/registration. The frontend obtains a token | ||
| from the provider and posts it to: | ||
|
|
||
| POST /api/account/oauth/{provider} | ||
| { "idToken": "<provider token>", "name": "<optional display name>" } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds AMPECO as an OAuth2 login provider and generalizes the OAuth2 layer so any future provider exposing an OpenID Connect
userinfoendpoint can be added with minimal or zero code.Reusable core (
fr.iolabs.leaf.authentication.oauth)AbstractUserInfoOAuthTokenVerifier— base verifier that calls a provider'suserinfoendpoint with the access token, maps standard OIDC claims (sub,email,given_name,family_name,name,picture) ontoOAuthUserInfo, splits a singlenameclaim when first/last are absent, and tolerates adata-wrapped payload. Claim names are overridable.OAuthProviderProperties+ConfigurableUserInfoTokenVerifier— declare any provider purely vialeaf.oauth.providers.<name>config, no code required.OAuthProviderRegistry— now merges code-defined verifiers (google/apple/ampeco) with config-declared ones; skips entries missinguserInfoUriand won't override built-ins.Ampeco provider
AmpecoTokenVerifier— thin@Componenton the base, tenant-configurable vialeaf.oauth.ampeco.userInfoUri. Reachable atPOST /api/account/oauth/ampeco. Google/Apple ID-token verifiers are untouched.Config & docs
demoapplication.yml: Ampeco entry + commentedproviders:example.library/README.md: OAuth2 section covering built-in providers and both extension paths.Adding a provider via config only
For providers needing custom verification (e.g. locally validated ID tokens), implement
OAuthTokenVerifierand expose it as a@Component.Notes for reviewers
OAuthTokenVerifier.verify(String)contract is reused; for userinfo-based providers the passed token is the access token (carried by the login action'sidTokenfield).