Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store authorzied clients into http session #17528

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
package com.azure.spring.aad.implementation;

import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.client.InMemoryOAuth2AuthorizedClientService;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.security.oauth2.client.web.AuthenticatedPrincipalOAuth2AuthorizedClientRepository;
import org.springframework.security.oauth2.client.web.HttpSessionOAuth2AuthorizedClientRepository;
import org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository;
import org.springframework.security.oauth2.core.OAuth2AccessToken;
import org.springframework.security.oauth2.core.OAuth2RefreshToken;
Expand All @@ -23,16 +21,12 @@ public class AzureOAuth2AuthorizedClientRepository implements OAuth2AuthorizedCl
private final AzureClientRegistrationRepository azureClientRegistrationRepository;
private final OAuth2AuthorizedClientRepository delegatedOAuth2AuthorizedClientRepository;

private static OAuth2AuthorizedClientRepository createDefaultDelegate(
ClientRegistrationRepository clientRegistrationRepository
) {
return new AuthenticatedPrincipalOAuth2AuthorizedClientRepository(
new InMemoryOAuth2AuthorizedClientService(clientRegistrationRepository)
);
private static OAuth2AuthorizedClientRepository createDefaultDelegate() {
return new HttpSessionOAuth2AuthorizedClientRepository();
}

public AzureOAuth2AuthorizedClientRepository(AzureClientRegistrationRepository azureClientRegistrationRepository) {
this(azureClientRegistrationRepository, createDefaultDelegate(azureClientRegistrationRepository));
this(azureClientRegistrationRepository, createDefaultDelegate());
}

public AzureOAuth2AuthorizedClientRepository(
Expand Down