Mongo fixes & few other fixes
This commit is contained in:
parent
d958d85290
commit
0092d9f74d
7 changed files with 28 additions and 23 deletions
|
@ -28,7 +28,7 @@
|
||||||
</column>
|
</column>
|
||||||
<column name="ALIAS" type="VARCHAR(255)"/>
|
<column name="ALIAS" type="VARCHAR(255)"/>
|
||||||
<column name="REALM_ID" type="VARCHAR(36)"/>
|
<column name="REALM_ID" type="VARCHAR(36)"/>
|
||||||
<column name="PROVIDER_ID" type="VARCHAR(36)"/>
|
<column name="PROVIDER_ID" type="VARCHAR(255)"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
<createTable tableName="AUTHENTICATION_FLOW">
|
<createTable tableName="AUTHENTICATION_FLOW">
|
||||||
<column name="ID" type="VARCHAR(36)">
|
<column name="ID" type="VARCHAR(36)">
|
||||||
|
|
|
@ -43,7 +43,10 @@ public class DefaultMongoConnectionFactoryProvider implements MongoConnectionPro
|
||||||
"org.keycloak.models.entities.ProtocolMapperEntity",
|
"org.keycloak.models.entities.ProtocolMapperEntity",
|
||||||
"org.keycloak.models.entities.IdentityProviderMapperEntity",
|
"org.keycloak.models.entities.IdentityProviderMapperEntity",
|
||||||
"org.keycloak.models.mongo.keycloak.entities.MongoUserConsentEntity",
|
"org.keycloak.models.mongo.keycloak.entities.MongoUserConsentEntity",
|
||||||
"org.keycloak.models.mongo.keycloak.entities.MongoMigrationModelEntity"
|
"org.keycloak.models.mongo.keycloak.entities.MongoMigrationModelEntity",
|
||||||
|
"org.keycloak.models.entities.AuthenticationExecutionEntity",
|
||||||
|
"org.keycloak.models.entities.AuthenticationFlowEntity",
|
||||||
|
"org.keycloak.models.entities.AuthenticatorEntity",
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(DefaultMongoConnectionFactoryProvider.class);
|
private static final Logger logger = Logger.getLogger(DefaultMongoConnectionFactoryProvider.class);
|
||||||
|
|
|
@ -76,13 +76,17 @@ public class MongoAdminEventQuery implements AdminEventQuery{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AdminEventQuery fromTime(Date fromTime) {
|
public AdminEventQuery fromTime(Date fromTime) {
|
||||||
query.put("time", BasicDBObjectBuilder.start("$gte", fromTime.getTime()).get());
|
BasicDBObject time = query.containsField("time") ? (BasicDBObject) query.get("time") : new BasicDBObject();
|
||||||
|
time.append("$gte", fromTime.getTime());
|
||||||
|
query.put("time", time);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AdminEventQuery toTime(Date toTime) {
|
public AdminEventQuery toTime(Date toTime) {
|
||||||
query.put("time", BasicDBObjectBuilder.start("$lte", toTime.getTime()).get());
|
BasicDBObject time = query.containsField("time") ? (BasicDBObject) query.get("time") : new BasicDBObject();
|
||||||
|
time.append("$lte", toTime.getTime());
|
||||||
|
query.put("time", time);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class LDAPFederationProviderFactory extends UserFederationEventAwareProvi
|
||||||
UserAttributeLDAPFederationMapper.READ_ONLY, readOnly);
|
UserAttributeLDAPFederationMapper.READ_ONLY, readOnly);
|
||||||
realm.addUserFederationMapper(mapperModel);
|
realm.addUserFederationMapper(mapperModel);
|
||||||
|
|
||||||
mapperModel = KeycloakModelUtils.createUserFederationMapperModel("username2", newProviderModel.getId(), UserAttributeLDAPFederationMapperFactory.PROVIDER_ID,
|
mapperModel = KeycloakModelUtils.createUserFederationMapperModel("username-cn", newProviderModel.getId(), UserAttributeLDAPFederationMapperFactory.PROVIDER_ID,
|
||||||
UserAttributeLDAPFederationMapper.USER_MODEL_ATTRIBUTE, UserModel.USERNAME,
|
UserAttributeLDAPFederationMapper.USER_MODEL_ATTRIBUTE, UserModel.USERNAME,
|
||||||
UserAttributeLDAPFederationMapper.LDAP_ATTRIBUTE, LDAPConstants.CN,
|
UserAttributeLDAPFederationMapper.LDAP_ATTRIBUTE, LDAPConstants.CN,
|
||||||
UserAttributeLDAPFederationMapper.READ_ONLY, readOnly);
|
UserAttributeLDAPFederationMapper.READ_ONLY, readOnly);
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class AuthenticationExecutionEntity {
|
||||||
protected AuthenticationExecutionModel.Requirement requirement;
|
protected AuthenticationExecutionModel.Requirement requirement;
|
||||||
protected int priority;
|
protected int priority;
|
||||||
private boolean userSetupAllowed;
|
private boolean userSetupAllowed;
|
||||||
private boolean autheticatorFlow;
|
private boolean authenticatorFlow;
|
||||||
private String parentFlow;
|
private String parentFlow;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -56,12 +56,12 @@ public class AuthenticationExecutionEntity {
|
||||||
this.userSetupAllowed = userSetupAllowed;
|
this.userSetupAllowed = userSetupAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAutheticatorFlow() {
|
public boolean isAuthenticatorFlow() {
|
||||||
return autheticatorFlow;
|
return authenticatorFlow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAutheticatorFlow(boolean autheticatorFlow) {
|
public void setAuthenticatorFlow(boolean authenticatorFlow) {
|
||||||
this.autheticatorFlow = autheticatorFlow;
|
this.authenticatorFlow = authenticatorFlow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getParentFlow() {
|
public String getParentFlow() {
|
||||||
|
|
|
@ -1287,7 +1287,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
model.setPriority(entity.getPriority());
|
model.setPriority(entity.getPriority());
|
||||||
model.setAuthenticator(entity.getAuthenticator());
|
model.setAuthenticator(entity.getAuthenticator());
|
||||||
model.setParentFlow(entity.getParentFlow());
|
model.setParentFlow(entity.getParentFlow());
|
||||||
model.setAutheticatorFlow(entity.isAutheticatorFlow());
|
model.setAutheticatorFlow(entity.isAuthenticatorFlow());
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1317,7 +1317,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
entity.setPriority(model.getPriority());
|
entity.setPriority(model.getPriority());
|
||||||
entity.setRequirement(model.getRequirement());
|
entity.setRequirement(model.getRequirement());
|
||||||
entity.setUserSetupAllowed(model.isUserSetupAllowed());
|
entity.setUserSetupAllowed(model.isUserSetupAllowed());
|
||||||
entity.setAutheticatorFlow(model.isAutheticatorFlow());
|
entity.setAuthenticatorFlow(model.isAutheticatorFlow());
|
||||||
AuthenticationFlowEntity flow = getFlowEntity(model.getId());
|
AuthenticationFlowEntity flow = getFlowEntity(model.getId());
|
||||||
flow.getExecutions().add(entity);
|
flow.getExecutions().add(entity);
|
||||||
model.setId(entity.getId());
|
model.setId(entity.getId());
|
||||||
|
@ -1335,7 +1335,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
entity.setAutheticatorFlow(model.isAutheticatorFlow());
|
entity.setAuthenticatorFlow(model.isAutheticatorFlow());
|
||||||
entity.setAuthenticator(model.getAuthenticator());
|
entity.setAuthenticator(model.getAuthenticator());
|
||||||
entity.setPriority(model.getPriority());
|
entity.setPriority(model.getPriority());
|
||||||
entity.setRequirement(model.getRequirement());
|
entity.setRequirement(model.getRequirement());
|
||||||
|
|
|
@ -1236,7 +1236,6 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
@Override
|
@Override
|
||||||
public List<AuthenticationFlowModel> getAuthenticationFlows() {
|
public List<AuthenticationFlowModel> getAuthenticationFlows() {
|
||||||
List<AuthenticationFlowEntity> flows = getMongoEntity().getAuthenticationFlows();
|
List<AuthenticationFlowEntity> flows = getMongoEntity().getAuthenticationFlows();
|
||||||
if (flows.size() == 0) return Collections.EMPTY_LIST;
|
|
||||||
List<AuthenticationFlowModel> models = new LinkedList<>();
|
List<AuthenticationFlowModel> models = new LinkedList<>();
|
||||||
for (AuthenticationFlowEntity entity : flows) {
|
for (AuthenticationFlowEntity entity : flows) {
|
||||||
AuthenticationFlowModel model = entityToModel(entity);
|
AuthenticationFlowModel model = entityToModel(entity);
|
||||||
|
@ -1255,10 +1254,9 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthenticationFlowModel getAuthenticationFlowById(String id) {
|
public AuthenticationFlowModel getAuthenticationFlowById(String id) {
|
||||||
for (AuthenticationFlowModel model : getAuthenticationFlows()) {
|
AuthenticationFlowEntity entity = getFlowEntity(id);
|
||||||
if (model.getId().equals(id)) return model;
|
if (entity == null) return null;
|
||||||
}
|
return entityToModel(entity);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AuthenticationFlowEntity getFlowEntity(String id) {
|
protected AuthenticationFlowEntity getFlowEntity(String id) {
|
||||||
|
@ -1280,7 +1278,6 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAuthenticationFlow(AuthenticationFlowModel model) {
|
public void updateAuthenticationFlow(AuthenticationFlowModel model) {
|
||||||
List<AuthenticationFlowEntity> flows = getMongoEntity().getAuthenticationFlows();
|
|
||||||
AuthenticationFlowEntity toUpdate = getFlowEntity(model.getId());;
|
AuthenticationFlowEntity toUpdate = getFlowEntity(model.getId());;
|
||||||
if (toUpdate == null) return;
|
if (toUpdate == null) return;
|
||||||
toUpdate.setAlias(model.getAlias());
|
toUpdate.setAlias(model.getAlias());
|
||||||
|
@ -1322,7 +1319,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
model.setPriority(entity.getPriority());
|
model.setPriority(entity.getPriority());
|
||||||
model.setAuthenticator(entity.getAuthenticator());
|
model.setAuthenticator(entity.getAuthenticator());
|
||||||
model.setParentFlow(entity.getParentFlow());
|
model.setParentFlow(entity.getParentFlow());
|
||||||
model.setAutheticatorFlow(entity.isAutheticatorFlow());
|
model.setAutheticatorFlow(entity.isAuthenticatorFlow());
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1352,8 +1349,9 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
entity.setPriority(model.getPriority());
|
entity.setPriority(model.getPriority());
|
||||||
entity.setRequirement(model.getRequirement());
|
entity.setRequirement(model.getRequirement());
|
||||||
entity.setUserSetupAllowed(model.isUserSetupAllowed());
|
entity.setUserSetupAllowed(model.isUserSetupAllowed());
|
||||||
entity.setAutheticatorFlow(model.isAutheticatorFlow());
|
entity.setAuthenticatorFlow(model.isAutheticatorFlow());
|
||||||
AuthenticationFlowEntity flow = getFlowEntity(model.getId());
|
entity.setParentFlow(model.getParentFlow());
|
||||||
|
AuthenticationFlowEntity flow = getFlowEntity(model.getParentFlow());
|
||||||
flow.getExecutions().add(entity);
|
flow.getExecutions().add(entity);
|
||||||
updateMongoEntity();
|
updateMongoEntity();
|
||||||
model.setId(entity.getId());
|
model.setId(entity.getId());
|
||||||
|
@ -1371,7 +1369,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
entity.setAutheticatorFlow(model.isAutheticatorFlow());
|
entity.setAuthenticatorFlow(model.isAutheticatorFlow());
|
||||||
entity.setAuthenticator(model.getAuthenticator());
|
entity.setAuthenticator(model.getAuthenticator());
|
||||||
entity.setPriority(model.getPriority());
|
entity.setPriority(model.getPriority());
|
||||||
entity.setRequirement(model.getRequirement());
|
entity.setRequirement(model.getRequirement());
|
||||||
|
|
Loading…
Reference in a new issue