Merge pull request #2067 from stianst/KEYCLOAK-2346

KEYCLOAK-2346 Add identity provider and external username to event wh…
This commit is contained in:
Stian Thorgersen 2016-01-20 13:00:22 +01:00
commit c4b1acb8eb
3 changed files with 8 additions and 5 deletions

View file

@ -121,7 +121,7 @@ public class AuthenticationManager {
backchannelLogoutClientSession(session, realm, clientSession, userSession, uriInfo, headers);
}
if (logoutBroker) {
String brokerId = userSession.getNote(IdentityBrokerService.BROKER_PROVIDER_ID);
String brokerId = userSession.getNote(Details.IDENTITY_PROVIDER);
if (brokerId != null) {
IdentityProvider identityProvider = IdentityBrokerService.getIdentityProvider(session, realm, brokerId);
try {
@ -220,7 +220,7 @@ public class AuthenticationManager {
}
}
String brokerId = userSession.getNote(IdentityBrokerService.BROKER_PROVIDER_ID);
String brokerId = userSession.getNote(Details.IDENTITY_PROVIDER);
if (brokerId != null) {
IdentityProvider identityProvider = IdentityBrokerService.getIdentityProvider(session, realm, brokerId);
Response response = identityProvider.keycloakInitiatedBrowserLogout(userSession, uriInfo, realm);

View file

@ -94,7 +94,6 @@ import static org.keycloak.models.Constants.ACCOUNT_MANAGEMENT_CLIENT_ID;
public class IdentityBrokerService implements IdentityProvider.AuthenticationCallback {
private static final Logger LOGGER = Logger.getLogger(IdentityBrokerService.class);
public static final String BROKER_PROVIDER_ID = "BROKER_PROVIDER_ID";
private final RealmModel realmModel;
@ -514,7 +513,8 @@ public class IdentityBrokerService implements IdentityProvider.AuthenticationCal
TokenManager.attachClientSession(userSession, clientSession);
context.getIdp().attachUserSession(userSession, clientSession, context);
userSession.setNote(BROKER_PROVIDER_ID, providerId);
userSession.setNote(Details.IDENTITY_PROVIDER, providerId);
userSession.setNote(Details.IDENTITY_PROVIDER_USERNAME, context.getUsername());
if (isDebugEnabled()) {
LOGGER.debugf("Performing local authentication for user [%s].", federatedUser);

View file

@ -776,7 +776,10 @@ public class LoginActionsService {
.detail(Details.AUTH_METHOD, userSession.getAuthMethod())
.detail(Details.USERNAME, userSession.getLoginUsername())
.detail(Details.RESPONSE_TYPE, responseType)
.detail(Details.RESPONSE_MODE, responseMode.toString().toLowerCase());
.detail(Details.RESPONSE_MODE, responseMode.toString().toLowerCase())
.detail(Details.IDENTITY_PROVIDER, userSession.getNote(Details.IDENTITY_PROVIDER))
.detail(Details.IDENTITY_PROVIDER_USERNAME, userSession.getNote(Details.IDENTITY_PROVIDER_USERNAME));
if (userSession.isRememberMe()) {
event.detail(Details.REMEMBER_ME, "true");
}