Fix anonymous login
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 5 Jun 2022 07:36:43 +0000 (09:36 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 5 Jun 2022 07:36:43 +0000 (09:36 +0200)
org.argeo.cms/src/org/argeo/cms/auth/CmsAuthUtils.java
org.argeo.cms/src/org/argeo/cms/internal/runtime/DeployedContentRepository.java
rap/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebEntryPoint.java

index 4998c89ff818fea5beb1877f583ebf87b6c9f4a9..928afc0d54960b102ac05b1b35388e00e0a1d6ad 100644 (file)
@@ -142,6 +142,7 @@ class CmsAuthUtils {
                                                currentLocalSession.close();
                                                // new CMS session
                                                cmsSession = new WebCmsSessionImpl(subject, authorization, locale, request);
+                                               CmsContextImpl.getCmsContext().registerCmsSession(cmsSession);
                                        } else if (!authorization.getName().equals(currentLocalSession.getAuthorization().getName())) {
                                                throw new IllegalStateException("Inconsistent user " + authorization.getName()
                                                                + " for existing CMS session " + currentLocalSession);
index 4fee406886e23d4186a8cfaafcfeb97a7ef607e6..7d3eb283bf2e2b54b698ecf6df33b63a64cf25cd 100644 (file)
@@ -17,11 +17,11 @@ public class DeployedContentRepository extends CmsContentRepository {
        public void start() {
                super.start();
                Path rootXml = KernelUtils.getOsgiInstancePath(ROOT_XML);
-               initRootContentProvider(rootXml);
+               initRootContentProvider(null);
 
-               Path srvPath = KernelUtils.getOsgiInstancePath(CmsConstants.SRV_WORKSPACE);
-               FsContentProvider srvContentProvider = new FsContentProvider("/" + CmsConstants.SRV_WORKSPACE, srvPath, false);
-               addProvider(srvContentProvider);
+//             Path srvPath = KernelUtils.getOsgiInstancePath(CmsConstants.SRV_WORKSPACE);
+//             FsContentProvider srvContentProvider = new FsContentProvider("/" + CmsConstants.SRV_WORKSPACE, srvPath, false);
+//             addProvider(srvContentProvider);
        }
 
        @Override
index c82aca7285d21c24d6ccec080ee84119440d469a..2eb783527f790b8cac6802e58ccb1ac94f8c4db2 100644 (file)
@@ -89,7 +89,9 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL
                        lc.login();
                } catch (LoginException e) {
                        try {
-                               lc = new LoginContext(CmsAuth.LOGIN_CONTEXT_ANONYMOUS);
+                               lc = new LoginContext(CmsAuth.LOGIN_CONTEXT_ANONYMOUS,
+                                               new RemoteAuthCallbackHandler(new ServletHttpRequest(UiContext.getHttpRequest()),
+                                                               new ServletHttpResponse(UiContext.getHttpResponse())));
                                lc.login();
                        } catch (LoginException e1) {
                                throw new IllegalStateException("Cannot log in as anonymous", e1);
@@ -154,7 +156,9 @@ public class CmsWebEntryPoint implements EntryPoint, CmsView, BrowserNavigationL
                try {
                        CurrentUser.logoutCmsSession(loginContext.getSubject());
                        loginContext.logout();
-                       LoginContext anonymousLc = new LoginContext(CmsAuth.LOGIN_CONTEXT_ANONYMOUS);
+                       LoginContext anonymousLc = new LoginContext(CmsAuth.LOGIN_CONTEXT_ANONYMOUS,
+                                       new RemoteAuthCallbackHandler(new ServletHttpRequest(UiContext.getHttpRequest()),
+                                                       new ServletHttpResponse(UiContext.getHttpResponse())));
                        anonymousLc.login();
                        authChange(anonymousLc);
                } catch (LoginException e) {