This commit is contained in:
parent
cefcd14fda
commit
b0bff28194
3 changed files with 5 additions and 16 deletions
|
|
@ -91,7 +91,7 @@ public class KeycloakRestTemplateAuthenticationProvider implements Authenticatio
|
|||
final KeycloakAccount account = new SimpleKeycloakAccount(principal, roles, skSession);
|
||||
KeycloakAuthenticationToken keycloakAuthenticationToken = new KeycloakAuthenticationToken(account, false, realmRoles);
|
||||
keycloakAuthenticationToken.setAuthenticated(true);
|
||||
checkRightsAndCreate(principalName, accessToken.getId(), roles);
|
||||
checkRightsAndCreate(principalName, roles);
|
||||
return keycloakAuthenticationToken;
|
||||
|
||||
} catch (VerificationException vex) {
|
||||
|
|
@ -101,14 +101,14 @@ public class KeycloakRestTemplateAuthenticationProvider implements Authenticatio
|
|||
}
|
||||
}
|
||||
|
||||
private void checkRightsAndCreate(String username, String id, Set<String> roles) {
|
||||
private void checkRightsAndCreate(String username, Set<String> roles) {
|
||||
|
||||
log.debug("login successful: login {}, roles {}", username, String.join(";", roles));
|
||||
//todo remove hardcode
|
||||
if (roles.contains("admin") || roles.contains("default-roles-master")) {
|
||||
String clientIp = currentHttpRequest != null ? currentHttpRequest.getRemoteAddr() : null;
|
||||
String serverIp = currentHttpRequest != null ? currentHttpRequest.getLocalAddr() : null;
|
||||
userAutoCreation.sendUserInfo(username, id, roles, clientIp, serverIp);
|
||||
userAutoCreation.sendUserInfo(username, roles, clientIp, serverIp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,11 +31,10 @@ public class UserAuthProcessor {
|
|||
this.operator = operator;
|
||||
}
|
||||
|
||||
public void sendUserInfo(String username, String identifier, Collection<String> roles, String userIp, String serverIp) {
|
||||
public void sendUserInfo(String identifier, Collection<String> roles, String userIp, String serverIp) {
|
||||
UserAuthAction authEvent = new UserAuthAction();
|
||||
UserAuthRequest requestData = authEvent.getAuthRequest();
|
||||
requestData.setUsername(username);
|
||||
requestData.setIdentifier(identifier);
|
||||
requestData.setUsername(identifier);
|
||||
requestData.setTime(Instant.now());
|
||||
requestData.setRoles(new ArrayList<>(roles));
|
||||
requestData.setServerIp(serverIp + ":" + serverPort); //getServerAddress() + ":" + serverPort
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ public class UserAuthRequest {
|
|||
@JsonProperty
|
||||
private String username;
|
||||
@JsonProperty
|
||||
private String identifier;
|
||||
@JsonProperty
|
||||
private List<String> roles = new ArrayList<>();
|
||||
@JsonSerialize(using = InstantSerializer.class)
|
||||
@JsonDeserialize(using = InstantDeserializer.class)
|
||||
|
|
@ -34,14 +32,6 @@ public class UserAuthRequest {
|
|||
this.username = username;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public List<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue