mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 14:35:45 +01:00
Support groups from external authentication resources
This commit is contained in:
@@ -8,6 +8,7 @@ import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.group.GroupNames;
|
||||
import sonia.scm.security.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -91,6 +92,11 @@ public class AuthenticationResource {
|
||||
tokenBuilder.scope(Scope.valueOf(authentication.getScope()));
|
||||
}
|
||||
|
||||
GroupNames groupNames = subject.getPrincipals().oneByType(GroupNames.class);
|
||||
if (groupNames != null && groupNames.isExternal()) {
|
||||
tokenBuilder.groups(groupNames.getCollection().toArray(new String[]{}));
|
||||
}
|
||||
|
||||
AccessToken token = tokenBuilder.build();
|
||||
|
||||
if (authentication.isCookie()) {
|
||||
|
||||
Reference in New Issue
Block a user