-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support Super Gluu one step authentication to Fido2 server #3593 (
#3599) * feat: Support Super Gluu one step authentication to Fido2 server #3593 * feat: add sample request/response for one/two steps * feat: enrollment proxy for Super Gluu * chore: allow to process Super Gluu auth request * feat: add super gluu authentication flow support * feat: update to conform Jans * feat: update SG script and services to conform Fido2 server * feat: add fido2 device registration services to jans-auth-server * feat: full 2 step Super Gluu support * feat: user filter to search user's devices for specifc domain * fix: super_gluu_script * fix: super Gluu script * feat: support one_step Super Gluu enrollment * feat: clean up jans-auth-server static config * Revert "fix: super_gluu_script" This reverts commit f0e1713. * Revert "fix: super Gluu script" This reverts commit 20512c4. * feat: super Gluu uses applicationId isntead of applicationId domain * feat: support Super Gluu one_step authentication * feat: add separate base DN for one step auth requests * feat: add super Fluu config option and disable it's API by default * feat: fixes in two step flow to conform katest API * feat move generic attributes to base bean * feat: remove unused services * chore: review script * chore: code review * chore: fix formatting * feat: add missing base fido2 branch * chore: code review * chore: review validators * feat: move Super Gluu adaptors code to separate services * chore: optimizations * chore: remove unused methods * feat: remove U2F clean up jobs * feat: more input parameters validations * feat: final optimizations and fixes Co-authored-by: Madhumita <madhu@gluu.org>
- Loading branch information
Showing
58 changed files
with
2,434 additions
and
454 deletions.
There are no files selected for viewing
283 changes: 158 additions & 125 deletions
283
...person_authentication/super-gluu-external-authenticator/SuperGluuExternalAuthenticator.py
Large diffs are not rendered by default.
Oops, something went wrong.
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
200 changes: 200 additions & 0 deletions
200
.../src/main/java/io/jans/as/common/service/common/fido2/RegistrationPersistenceService.java
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,200 @@ | ||
/* | ||
* Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. | ||
* | ||
* Copyright (c) 2020, Janssen Project | ||
*/ | ||
|
||
package io.jans.as.common.service.common.fido2; | ||
|
||
import java.util.Collections; | ||
import java.util.Date; | ||
import java.util.GregorianCalendar; | ||
import java.util.List; | ||
import java.util.TimeZone; | ||
import java.util.UUID; | ||
|
||
import org.slf4j.Logger; | ||
|
||
import io.jans.as.common.model.common.User; | ||
import io.jans.as.common.service.common.UserService; | ||
import io.jans.as.model.config.StaticConfiguration; | ||
import io.jans.orm.PersistenceEntryManager; | ||
import io.jans.orm.model.base.SimpleBranch; | ||
import io.jans.orm.model.fido2.Fido2RegistrationData; | ||
import io.jans.orm.model.fido2.Fido2RegistrationEntry; | ||
import io.jans.orm.model.fido2.Fido2RegistrationStatus; | ||
import io.jans.orm.search.filter.Filter; | ||
import io.jans.util.StringHelper; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
|
||
/** | ||
* Every registration is persisted under Person Entry | ||
* @author Yuriy Movchan | ||
* @version May 08, 2020 | ||
*/ | ||
@ApplicationScoped | ||
public class RegistrationPersistenceService { | ||
|
||
@Inject | ||
private Logger log; | ||
|
||
@Inject | ||
private PersistenceEntryManager persistenceEntryManager; | ||
|
||
@Inject | ||
private UserService userService; | ||
|
||
@Inject | ||
private StaticConfiguration staticConfiguration; | ||
|
||
public void save(Fido2RegistrationEntry registrationEntry) { | ||
prepareBranch(registrationEntry.getUserInum()); | ||
|
||
persistenceEntryManager.persist(registrationEntry); | ||
} | ||
|
||
public void update(Fido2RegistrationEntry registrationEntry) { | ||
prepareBranch(registrationEntry.getUserInum()); | ||
|
||
Date now = new GregorianCalendar(TimeZone.getTimeZone("UTC")).getTime(); | ||
|
||
Fido2RegistrationData registrationData = registrationEntry.getRegistrationData(); | ||
registrationData.setUpdatedDate(now); | ||
registrationData.setUpdatedBy(registrationData.getUsername()); | ||
|
||
registrationEntry.setRegistrationStatus(registrationData.getStatus()); | ||
|
||
persistenceEntryManager.merge(registrationEntry); | ||
} | ||
|
||
public void addBranch(final String baseDn) { | ||
SimpleBranch branch = new SimpleBranch(); | ||
branch.setOrganizationalUnitName("fido2_register"); | ||
branch.setDn(baseDn); | ||
|
||
persistenceEntryManager.persist(branch); | ||
} | ||
|
||
public boolean containsBranch(final String baseDn) { | ||
return persistenceEntryManager.contains(baseDn, SimpleBranch.class); | ||
} | ||
|
||
public String prepareBranch(final String userInum) { | ||
String baseDn = getBaseDnForFido2RegistrationEntries(userInum); | ||
if (!persistenceEntryManager.hasBranchesSupport(baseDn)) { | ||
return baseDn; | ||
} | ||
|
||
// Create Fido2 base branch for registration entries if needed | ||
if (!containsBranch(baseDn)) { | ||
addBranch(baseDn); | ||
} | ||
|
||
return baseDn; | ||
} | ||
|
||
public Fido2RegistrationEntry findRegisteredUserDevice(String userInum, String deviceId, String... returnAttributes) { | ||
String baseDn = getBaseDnForFido2RegistrationEntries(userInum); | ||
if (persistenceEntryManager.hasBranchesSupport(baseDn)) { | ||
if (!containsBranch(baseDn)) { | ||
return null; | ||
} | ||
} | ||
|
||
String deviceDn = getDnForRegistrationEntry(userInum, deviceId); | ||
|
||
return persistenceEntryManager.find(deviceDn, Fido2RegistrationEntry.class, returnAttributes); | ||
} | ||
|
||
public List<Fido2RegistrationEntry> findByRpRegisteredUserDevices(String userName, String rpId, String ... returnAttributes) { | ||
String userInum = userService.getUserInum(userName); | ||
if (userInum == null) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
String baseDn = getBaseDnForFido2RegistrationEntries(userInum); | ||
if (persistenceEntryManager.hasBranchesSupport(baseDn)) { | ||
if (!containsBranch(baseDn)) { | ||
return Collections.emptyList(); | ||
} | ||
} | ||
|
||
Filter userInumFilter = Filter.createEqualityFilter("personInum", userInum); | ||
Filter registeredFilter = Filter.createEqualityFilter("jansStatus", Fido2RegistrationStatus.registered.getValue()); | ||
Filter appIdFilter = Filter.createEqualityFilter("jansApp", rpId); | ||
Filter filter = Filter.createANDFilter(userInumFilter, registeredFilter, appIdFilter); | ||
|
||
List<Fido2RegistrationEntry> fido2RegistrationnEntries = persistenceEntryManager.findEntries(baseDn, Fido2RegistrationEntry.class, filter, returnAttributes); | ||
|
||
return fido2RegistrationnEntries; | ||
} | ||
|
||
|
||
public boolean attachDeviceRegistrationToUser(String userInum, String deviceDn) { | ||
Fido2RegistrationEntry registrationEntry = persistenceEntryManager.find(Fido2RegistrationEntry.class, deviceDn); | ||
if (registrationEntry == null) { | ||
return false; | ||
} | ||
|
||
User user = userService.getUserByInum(userInum, "uid"); | ||
if (user == null) { | ||
return false; | ||
} | ||
|
||
persistenceEntryManager.remove(deviceDn, Fido2RegistrationEntry.class); | ||
|
||
final String id = UUID.randomUUID().toString(); | ||
|
||
String userAttestationDn = getDnForRegistrationEntry(userInum, id); | ||
registrationEntry.setId(id); | ||
registrationEntry.setDn(userAttestationDn); | ||
registrationEntry.setUserInum(userInum); | ||
|
||
Fido2RegistrationData registrationData = registrationEntry.getRegistrationData(); | ||
registrationData.setUsername(user.getUserId()); | ||
registrationEntry.clearExpiration(); | ||
|
||
save(registrationEntry); | ||
|
||
return true; | ||
} | ||
|
||
public Fido2RegistrationEntry findOneStepUserDeviceRegistration(String deviceDn) { | ||
Fido2RegistrationEntry registrationEntry = persistenceEntryManager.find(Fido2RegistrationEntry.class, deviceDn); | ||
|
||
return registrationEntry; | ||
} | ||
|
||
public String getDnForRegistrationEntry(String userInum, String jsId) { | ||
// Build DN string for Fido2 registration entry | ||
String baseDn = getBaseDnForFido2RegistrationEntries(userInum); | ||
if (StringHelper.isEmpty(jsId)) { | ||
return baseDn; | ||
} | ||
return String.format("jansId=%s,%s", jsId, baseDn); | ||
} | ||
|
||
public String getBaseDnForFido2RegistrationEntries(String userInum) { | ||
final String userBaseDn = getDnForUser(userInum); // "ou=fido2_register,inum=1234,ou=people,o=jans" | ||
if (StringHelper.isEmpty(userInum)) { | ||
return userBaseDn; | ||
} | ||
|
||
return String.format("ou=fido2_register,%s", userBaseDn); | ||
} | ||
|
||
public String getDnForUser(String userInum) { | ||
String peopleDn = getBasedPeopleDn(); | ||
if (StringHelper.isEmpty(userInum)) { | ||
return peopleDn; | ||
} | ||
|
||
return String.format("inum=%s,%s", userInum, peopleDn); | ||
} | ||
|
||
public String getBasedPeopleDn() { | ||
return staticConfiguration.getBaseDn().getPeople(); | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.