mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-11 12:03:09 +00:00
85276: Store and retrieve the Authentication method in the JWT
This commit is contained in:
@@ -83,6 +83,9 @@ public class LDAPAuthentication
|
||||
protected ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
private static final String LDAP_AUTHENTICATED = "ldap.authenticated";
|
||||
|
||||
|
||||
/**
|
||||
* Let a real auth method return true if it wants.
|
||||
*
|
||||
@@ -261,6 +264,7 @@ public class LDAPAuthentication
|
||||
|
||||
if (ldap.ldapAuthenticate(dn, password, context)) {
|
||||
context.setCurrentUser(eperson);
|
||||
request.getSession().setAttribute(LDAP_AUTHENTICATED, true);
|
||||
|
||||
// assign user to groups based on ldap dn
|
||||
assignGroups(dn, ldap.ldapGroup, context);
|
||||
@@ -311,6 +315,8 @@ public class LDAPAuthentication
|
||||
context.dispatchEvents();
|
||||
context.restoreAuthSystemState();
|
||||
context.setCurrentUser(eperson);
|
||||
request.getSession().setAttribute(LDAP_AUTHENTICATED, true);
|
||||
|
||||
|
||||
// assign user to groups based on ldap dn
|
||||
assignGroups(dn, ldap.ldapGroup, context);
|
||||
@@ -341,6 +347,8 @@ public class LDAPAuthentication
|
||||
ePersonService.update(context, eperson);
|
||||
context.dispatchEvents();
|
||||
context.setCurrentUser(eperson);
|
||||
request.getSession().setAttribute(LDAP_AUTHENTICATED, true);
|
||||
|
||||
|
||||
// assign user to groups based on ldap dn
|
||||
assignGroups(dn, ldap.ldapGroup, context);
|
||||
@@ -734,4 +742,14 @@ public class LDAPAuthentication
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsed(final Context context, final HttpServletRequest request) {
|
||||
if (request != null &&
|
||||
context.getCurrentUser() != null &&
|
||||
request.getSession().getAttribute(LDAP_AUTHENTICATED) != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user