From: Olivier Lamy Date: Tue, 8 Jan 2013 22:47:13 +0000 (+0000) Subject: [MRM-1736] map roles to ldap groups X-Git-Tag: archiva-1.4-M4~307 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3b024df4b945a1911cbdaec9915d550b985f438f;p=archiva.git [MRM-1736] map roles to ldap groups git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1430606 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java index b81d65c83..1951f7ad7 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java @@ -30,6 +30,8 @@ import org.apache.archiva.maven2.model.Artifact; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.repository.RepositorySessionFactory; import org.apache.archiva.redback.components.taskqueue.TaskQueueException; +import org.apache.archiva.redback.configuration.UserConfiguration; +import org.apache.archiva.redback.configuration.UserConfigurationKeys; import org.apache.archiva.redback.rest.services.RedbackAuthenticationThreadLocal; import org.apache.archiva.redback.rest.services.RedbackRequestInformation; import org.apache.archiva.redback.users.User; @@ -95,6 +97,11 @@ public abstract class AbstractRestService @Named(value = "archivaTaskScheduler#repository") protected DefaultRepositoryArchivaTaskScheduler repositoryTaskScheduler; + + @Inject + @Named( value = "userConfiguration#default" ) + protected UserConfiguration config; + @Context protected HttpServletRequest httpServletRequest; @@ -143,9 +150,9 @@ public abstract class AbstractRestService RedbackRequestInformation redbackRequestInformation = RedbackAuthenticationThreadLocal.get(); return redbackRequestInformation == null - ? UserManager.GUEST_USERNAME + ? config.getString( UserConfigurationKeys.DEFAULT_GUEST ) : ( redbackRequestInformation.getUser() == null - ? UserManager.GUEST_USERNAME + ? config.getString( UserConfigurationKeys.DEFAULT_GUEST ) : redbackRequestInformation.getUser().getUsername() ); } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaAuthorizer.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaAuthorizer.java index 3ea5acd94..d5f6c9eed 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaAuthorizer.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaAuthorizer.java @@ -43,6 +43,11 @@ public class ArchivaAuthorizer @Named( value = "authorizer#rbac" ) private Authorizer rbacAuthorizer; + + @Inject + @Named( value = "authorizer#ldap" ) + private Authorizer ldapAuthorizer; + public String getId() { return "archiva"; @@ -52,6 +57,11 @@ public class ArchivaAuthorizer throws AuthorizationException { log.debug( "isAuthorized source: {}", source ); + + AuthorizationResult result = ldapAuthorizer.isAuthorized( source ); + + + return rbacAuthorizer.isAuthorized( source ); } diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml index 6344b9c51..9cea0581e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -462,6 +462,33 @@ + + org.apache.archiva.redback.components.registry + spring-registry-api + + + org.apache.archiva.redback.components.registry + spring-registry-commons + + + ant + ant-optional + + + jdom + jdom + + + commons-logging + commons-logging-api + + + commons-logging + commons-logging + + + + org.apache.archiva archiva-rest-api @@ -643,6 +670,16 @@ org.apache.archiva.redback redback-integrations-security + + org.apache.archiva.redback + redback-authorization-ldap + + + commons-logging + commons-logging + + + org.slf4j jcl-over-slf4j diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml index b55090452..23d2b58ac 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml @@ -56,7 +56,8 @@ - + + + diff --git a/pom.xml b/pom.xml index 9c6a9d264..b0da17108 100644 --- a/pom.xml +++ b/pom.xml @@ -927,6 +927,17 @@ + + org.apache.archiva.redback + redback-authorization-ldap + ${redback.version} + + + commons-logging + commons-logging + + + org.apache.archiva.redback redback-users-memory