-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
33 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,8 @@ | |
package uk.ac.ebi.ampt2d.registry; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.autoconfigure.security.oauth2.resource.AuthoritiesExtractor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.userdetails.User; | ||
|
@@ -34,8 +34,6 @@ | |
import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.test.web.servlet.request.RequestPostProcessor; | ||
import uk.ac.ebi.ampt2d.registry.config.security.CustomAuthoritiesExtractor; | ||
import uk.ac.ebi.ampt2d.registry.repositories.RegistryUserRepository; | ||
|
||
import java.io.Serializable; | ||
import java.util.Collection; | ||
|
@@ -46,6 +44,7 @@ | |
|
||
@Component | ||
@EnableAuthorizationServer | ||
@ConditionalOnProperty(name = "security.enabled", havingValue = "true") | ||
public class OAuthHelper extends AuthorizationServerConfigurerAdapter { | ||
|
||
@Autowired | ||
|
@@ -55,7 +54,7 @@ public class OAuthHelper extends AuthorizationServerConfigurerAdapter { | |
private ClientDetailsService clientDetailsService; | ||
|
||
@Autowired | ||
private RegistryUserRepository registryUserRepository; | ||
private AuthoritiesExtractor authoritiesExtractor; | ||
|
||
public RequestPostProcessor bearerToken(final String clientid) { | ||
return mockRequest -> { | ||
|
@@ -69,7 +68,7 @@ private OAuth2AccessToken createAccessToken(final String clientId) { | |
ClientDetails client = clientDetailsService.loadClientByClientId(clientId); | ||
Map<String, Object> clientEmailMap = new HashMap<>(); | ||
clientEmailMap.put("email", clientId); | ||
Collection<GrantedAuthority> authorities = authoritiesExtractor(registryUserRepository).extractAuthorities(clientEmailMap); | ||
Collection<GrantedAuthority> authorities = authoritiesExtractor.extractAuthorities(clientEmailMap); | ||
Set<String> resourceIds = client.getResourceIds(); | ||
Set<String> scopes = client.getScope(); | ||
|
||
|
@@ -97,9 +96,4 @@ public void configure(final ClientDetailsServiceConfigurer clients) throws Excep | |
.withClient("[email protected]").and() | ||
.withClient("[email protected]"); | ||
} | ||
|
||
@Bean | ||
public AuthoritiesExtractor authoritiesExtractor(RegistryUserRepository registryUserRepository) { | ||
return new CustomAuthoritiesExtractor(registryUserRepository); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
<include resource="org/springframework/boot/logging/logback/base.xml" /> | ||
<logger name="root" level="INFO"/> | ||
</configuration> |