Merge branch 'refactoring' into error-handling
# Conflicts: # src/main/java/mops/gruppen2/controller/Gruppen2Controller.java # src/main/java/mops/gruppen2/domain/Exceptions/UserAlreadyExistsException.java # src/main/java/mops/gruppen2/domain/Exceptions/UserNotFoundException.java # src/main/java/mops/gruppen2/domain/Group.java # src/main/java/mops/gruppen2/domain/event/AddUserEvent.java # src/main/java/mops/gruppen2/domain/event/CreateGroupEvent.java # src/main/java/mops/gruppen2/domain/event/DeleteUserEvent.java # src/main/java/mops/gruppen2/domain/event/Event.java # src/main/java/mops/gruppen2/domain/event/UpdateGroupDescriptionEvent.java # src/main/java/mops/gruppen2/domain/event/UpdateGroupTitleEvent.java # src/main/java/mops/gruppen2/domain/event/UpdateRoleEvent.java # src/main/java/mops/gruppen2/domain/exception/EventException.java # src/main/java/mops/gruppen2/domain/exception/GroupIdMismatchException.java # src/main/java/mops/gruppen2/domain/exception/GroupNotFoundException.java # src/main/java/mops/gruppen2/domain/exception/NoValueException.java # src/main/java/mops/gruppen2/service/ControllerService.java # src/main/java/mops/gruppen2/service/GroupService.java # src/main/java/mops/gruppen2/service/UserService.java # src/main/resources/templates/errorRenameLater.html
This commit is contained in:
@ -1,16 +1,16 @@
|
||||
package mops.gruppen2.security;
|
||||
|
||||
import java.util.Set;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Value;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
import java.util.Set;
|
||||
|
||||
@Value
|
||||
public class Account {
|
||||
private final String name; //user_id
|
||||
private final String email;
|
||||
private final String image;
|
||||
private final String givenname;
|
||||
private final String familyname;
|
||||
private final Set<String> roles;
|
||||
|
||||
String email;
|
||||
String image;
|
||||
String name; //user_id
|
||||
String givenname;
|
||||
String familyname;
|
||||
Set<String> roles;
|
||||
}
|
||||
|
||||
@ -16,39 +16,30 @@ import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Configuration
|
||||
public class KeycloakConfig {
|
||||
|
||||
@Value("${keycloak.resource}")
|
||||
private String clientId;
|
||||
|
||||
@Value("${keycloak.credentials.secret}")
|
||||
private String clientSecret;
|
||||
|
||||
@Value("${hhu_keycloak.token-uri}")
|
||||
private String tokenUri;
|
||||
|
||||
@Bean
|
||||
public KeycloakSpringBootConfigResolver keycloakConfigResolver() {
|
||||
return new KeycloakSpringBootConfigResolver();
|
||||
}
|
||||
|
||||
@Value("${keycloak.resource}")
|
||||
|
||||
private String clientId;
|
||||
|
||||
@Value("${keycloak.credentials.secret}")
|
||||
|
||||
private String clientSecret;
|
||||
|
||||
@Value("${hhu_keycloak.token-uri}")
|
||||
|
||||
private String tokenUri;
|
||||
|
||||
|
||||
@Bean
|
||||
public RestTemplate serviceAccountRestTemplate() {
|
||||
|
||||
ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails();
|
||||
|
||||
resourceDetails.setGrantType(OAuth2Constants.CLIENT_CREDENTIALS);
|
||||
|
||||
resourceDetails.setAccessTokenUri(tokenUri);
|
||||
|
||||
resourceDetails.setClientId(clientId);
|
||||
|
||||
resourceDetails.setClientSecret(clientSecret);
|
||||
|
||||
|
||||
return new OAuth2RestTemplate(resourceDetails);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
@Scope(scopeName = WebApplicationContext.SCOPE_REQUEST,
|
||||
proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public AccessToken getAccessToken() {
|
||||
HttpServletRequest request =
|
||||
((ServletRequestAttributes) RequestContextHolder
|
||||
@ -57,14 +57,14 @@ class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
super.configure(http);
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/actuator/**")
|
||||
.hasRole("monitoring")
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/h2-console/**")
|
||||
.permitAll()
|
||||
.anyRequest()
|
||||
.permitAll();
|
||||
.antMatchers("/actuator/**")
|
||||
.hasRole("monitoring")
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/h2-console/**")
|
||||
.permitAll()
|
||||
.anyRequest()
|
||||
.permitAll();
|
||||
|
||||
http.csrf().disable();
|
||||
http.headers().frameOptions().disable();
|
||||
@ -84,5 +84,6 @@ class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
|
||||
jsr250Enabled = true)
|
||||
public static class MethodSecurityConfig
|
||||
extends GlobalMethodSecurityConfiguration {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user