mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-07 12:50:54 +01:00
improve scm-pam-plugin
This commit is contained in:
@@ -131,12 +131,14 @@ public class PAMAuthenticationHandler implements AuthenticationHandler
|
||||
{
|
||||
try
|
||||
{
|
||||
UnixUser user = pam.authenticate(username, password);
|
||||
UnixUser unixUser = pam.authenticate(username, password);
|
||||
|
||||
if (user != null)
|
||||
if (unixUser != null)
|
||||
{
|
||||
result = new AuthenticationResult(new User(username, username,
|
||||
null));
|
||||
User user = new User(username, username, null);
|
||||
|
||||
user.setAdmin(isAdmin(unixUser));
|
||||
result = new AuthenticationResult(user);
|
||||
}
|
||||
}
|
||||
catch (PAMException ex)
|
||||
@@ -227,6 +229,40 @@ public class PAMAuthenticationHandler implements AuthenticationHandler
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param unixUser
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isAdmin(UnixUser unixUser)
|
||||
{
|
||||
boolean admin = false;
|
||||
|
||||
if (config.getAdminUserSet().contains(unixUser.getUserName()))
|
||||
{
|
||||
admin = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (String group : unixUser.getGroups())
|
||||
{
|
||||
if (config.getAdminGroupSet().contains(group))
|
||||
{
|
||||
admin = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return admin;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
Reference in New Issue
Block a user