<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Liferay 7.4 JAAS not working - returns to the login screen</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121448948" />
  <subtitle>Liferay 7.4 JAAS not working - returns to the login screen</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121448948</id>
  <updated>2026-04-06T05:34:16Z</updated>
  <dc:date>2026-04-06T05:34:16Z</dc:date>
  <entry>
    <title>RE: Liferay 7.4 JAAS not working - returns to the login screen</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121474408" />
    <author>
      <name>Alex Mirren</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121474408</id>
    <updated>2022-07-21T10:28:55Z</updated>
    <published>2022-07-20T19:16:40Z</published>
    <summary type="html">&lt;p&gt;and make sure portal-ext.properties file have jaas enabled&lt;/p&gt;
&lt;p&gt;portal.jaas.enable=true&lt;br /&gt; portal.jaas.auth.type=userId&lt;br /&gt;  &lt;/p&gt;</summary>
    <dc:creator>Alex Mirren</dc:creator>
    <dc:date>2022-07-20T19:16:40Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay 7.4 JAAS not working - returns to the login screen</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121474248" />
    <author>
      <name>Alex Mirren</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121474248</id>
    <updated>2022-07-20T19:14:30Z</updated>
    <published>2022-07-20T19:12:24Z</published>
    <summary type="html">&lt;p&gt;Then, in ROOT resin-web.xml - replace login-module class with your custom&lt;/p&gt;
&lt;pre&gt;
&lt;code class="language-html"&gt;&amp;lt;web-app xmlns=&amp;quot;http://caucho.com/ns/resin&amp;quot;&amp;gt;
	&amp;lt;authenticator type=&amp;quot;com.caucho.server.security.JaasAuthenticator&amp;quot;&amp;gt;
		&amp;lt;init&amp;gt;
			&amp;lt;login-module&amp;gt;com.liferay.portal.security.jaas.PortalLoginModule&amp;lt;/login-module&amp;gt;
			&amp;lt;password-digest&amp;gt;none&amp;lt;/password-digest&amp;gt;
		&amp;lt;/init&amp;gt;
	&amp;lt;/authenticator&amp;gt;
&amp;lt;/web-app&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;</summary>
    <dc:creator>Alex Mirren</dc:creator>
    <dc:date>2022-07-20T19:12:24Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay 7.4 JAAS not working - returns to the login screen</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121474232" />
    <author>
      <name>Alex Mirren</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121474232</id>
    <updated>2022-07-20T19:14:36Z</updated>
    <published>2022-07-20T19:06:04Z</published>
    <summary type="html">&lt;p&gt;Ok, your new .jar should land to&amp;lt;tomcat&amp;gt;\lib\ext\ folder.&lt;/p&gt;</summary>
    <dc:creator>Alex Mirren</dc:creator>
    <dc:date>2022-07-20T19:06:04Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay 7.4 JAAS not working - returns to the login screen</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121474214" />
    <author>
      <name>Alex Mirren</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121474214</id>
    <updated>2022-07-20T19:14:43Z</updated>
    <published>2022-07-20T18:56:21Z</published>
    <summary type="html">&lt;p&gt;1. This is were the module located in WildFly (JBoss). I have no idea
  about Tomcat, you have to locate the original place in LR 7.1 version.&lt;/p&gt;
&lt;p&gt;
  &lt;img alt="" src="/documents/14/0/module.png/d8fd1441-2c9d-670a-0442-09d273622a2b?t=1658342923081&amp;amp;imagePreview=1" /&gt;&lt;/p&gt;
&lt;p&gt;2. I am not sure about jboss-deployment file here, as you are working
  with Tomcat and the file might be differen. Try to locate traces in LR
  7.1 ROOT.war&lt;/p&gt;
&lt;p&gt;My file looks like &lt;/p&gt;
&lt;pre&gt;
&lt;code class="language-html"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;

&amp;lt;jboss-deployment-structure xmlns=&amp;quot;urn:jboss:deployment-structure:1.1&amp;quot;&amp;gt;
	&amp;lt;deployment&amp;gt;
		&amp;lt;exclusions&amp;gt;
			&amp;lt;module name=&amp;quot;org.apache.log4j&amp;quot; /&amp;gt;
			&amp;lt;module name=&amp;quot;org.hibernate&amp;quot; /&amp;gt;
			&amp;lt;module name=&amp;quot;org.slf4j&amp;quot; /&amp;gt;
		&amp;lt;/exclusions&amp;gt;
		&amp;lt;dependencies&amp;gt;
			&amp;lt;module meta-inf=&amp;quot;export&amp;quot; name=&amp;quot;uk.co.caci.portal.liferay&amp;quot;&amp;gt;
				&amp;lt;imports&amp;gt;
					&amp;lt;include path=&amp;quot;META-INF&amp;quot; /&amp;gt;
				&amp;lt;/imports&amp;gt;
			&amp;lt;/module&amp;gt;
			&amp;lt;module name=&amp;quot;javax.mail.api&amp;quot; /&amp;gt;
			&amp;lt;module name=&amp;quot;org.apache.xerces&amp;quot; /&amp;gt;
			&amp;lt;module name=&amp;quot;org.jboss.modules&amp;quot; /&amp;gt;
		&amp;lt;/dependencies&amp;gt;
	&amp;lt;/deployment&amp;gt;
&amp;lt;/jboss-deployment-structure&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The part - &amp;lt;module meta-inf=&amp;quot;export&amp;quot;
  name=&amp;quot;uk.co.caci.portal.liferay&amp;quot;&amp;gt; is reference to the
  WildFly modules. Again - might/should be different from tomcat&lt;/p&gt;
&lt;p&gt;3. WildFly config file contains &amp;lt;login-module
  code=&amp;quot;uk.co.caci.portal.liferay.CaciLoginModule&amp;quot;
  flag=&amp;quot;required&amp;quot;/&amp;gt; reference. Again, different from tomcat.&lt;/p&gt;
&lt;pre&gt;
&lt;code class="language-html"&gt;        &amp;lt;subsystem xmlns=&amp;quot;urn:jboss:domain:security:2.0&amp;quot;&amp;gt;
            &amp;lt;security-domains&amp;gt;
                &amp;lt;security-domain name=&amp;quot;PortalRealm&amp;quot;&amp;gt;
                    &amp;lt;authentication&amp;gt;
                        &amp;lt;login-module code=&amp;quot;uk.co.caci.portal.liferay.CaciLoginModule&amp;quot; flag=&amp;quot;required&amp;quot;/&amp;gt;
                    &amp;lt;/authentication&amp;gt;
                &amp;lt;/security-domain&amp;gt;
                &amp;lt;security-domain name=&amp;quot;other&amp;quot; cache-type=&amp;quot;default&amp;quot;&amp;gt;
                    &amp;lt;authentication&amp;gt;
                        &amp;lt;login-module code=&amp;quot;Remoting&amp;quot; flag=&amp;quot;optional&amp;quot;&amp;gt;
                            &amp;lt;module-option name=&amp;quot;password-stacking&amp;quot; value=&amp;quot;useFirstPass&amp;quot;/&amp;gt;
                        &amp;lt;/login-module&amp;gt;
                        &amp;lt;login-module code=&amp;quot;RealmDirect&amp;quot; flag=&amp;quot;required&amp;quot;&amp;gt;
                            &amp;lt;module-option name=&amp;quot;password-stacking&amp;quot; value=&amp;quot;useFirstPass&amp;quot;/&amp;gt;
                        &amp;lt;/login-module&amp;gt;
                    &amp;lt;/authentication&amp;gt;
                &amp;lt;/security-domain&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;</summary>
    <dc:creator>Alex Mirren</dc:creator>
    <dc:date>2022-07-20T18:56:21Z</dc:date>
  </entry>
  <entry>
    <title>RE: RE: Liferay 7.4 JAAS not working - returns to the login screen</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121474040" />
    <author>
      <name>Fayaj Shaikh</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121474040</id>
    <updated>2022-07-20T18:29:33Z</updated>
    <published>2022-07-20T17:18:46Z</published>
    <summary type="html">&lt;p&gt;Hi Alex,&lt;/p&gt;
&lt;p&gt;Thanks for the update. I have created a dummy module with above class
  also added missing files in dummy module like  PortalGroup,
  PortalPrincipal, PortalRole.&lt;/p&gt;
&lt;p&gt;Can you please elaborate more on below your mentioned points&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Then copied generated jar into wildfly server modules folder (no
    other dependencies required) - &lt;strong&gt;Do means to add created jar
      into tomcat lib folder?&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Then in the ROOT.war altered jboss-deployment - added reference to
    the new module. - &lt;strong&gt;Which file exactly i need to
      update jboss-deployment-structure file?&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;In the wildfly config replaced outdated module with my -
      &lt;strong&gt;Here config file - are you refering to jaas.config file?&lt;/strong&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Thanking you in advance.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Fayaj&lt;/p&gt;</summary>
    <dc:creator>Fayaj Shaikh</dc:creator>
    <dc:date>2022-07-20T17:18:46Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay 7.4 JAAS not working - returns to the login screen</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121473831" />
    <author>
      <name>Alex Mirren</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121473831</id>
    <updated>2022-07-20T13:26:16Z</updated>
    <published>2022-07-20T08:26:01Z</published>
    <summary type="html">&lt;p&gt;Ok, see dummy module I created just to maintain the session credentials&lt;/p&gt;
&lt;pre&gt;
&lt;code class="language-java"&gt;package uk.co.caci.portal.liferay;


import java.io.IOException;

import java.security.Principal;

import java.util.Map;
import java.util.Set;

import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author amirren - JAAS implementation to keep EJB context separated for each logged user
 */
public class CaciLoginModule implements LoginModule {

    @Override
    public boolean abort() {
        return true;
    }

    public boolean preCommit() throws LoginException {
        Principal principal = getPrincipal();

        if (principal != null) {
            Subject subject = getSubject();

            Set&amp;lt;Principal&amp;gt; principals = subject.getPrincipals();

            principals.add(getPrincipal());

            return true;
        }

        return false;
    }

    @Override
    public boolean commit() throws LoginException {
        //_log.info(&amp;quot;commit&amp;quot;);
        boolean commitValue = preCommit();

        if (commitValue) {
            PortalGroup rolesPortalGroup = new PortalGroup(&amp;quot;Roles&amp;quot;);

            rolesPortalGroup.addMember(new PortalPrincipal(&amp;quot;users&amp;quot;));

            Subject subject = getSubject();

            Set&amp;lt;Principal&amp;gt; principals = subject.getPrincipals();

            principals.add(rolesPortalGroup);

            PortalGroup callerPrincipalGroup = new PortalGroup(
                    &amp;quot;CallerPrincipal&amp;quot;);

            callerPrincipalGroup.addMember(getPrincipal());

            principals.add(callerPrincipalGroup);
        }

        return commitValue;
    }

    @Override
    public void initialize(
            Subject subject, CallbackHandler callbackHandler,
            Map&amp;lt;String, ?&amp;gt; sharedState, Map&amp;lt;String, ?&amp;gt; options) {

        //_log.info(&amp;quot;initialize&amp;quot;);
        _subject = subject;
        _callbackHandler = callbackHandler;

    }

    @Override
    public boolean login() throws LoginException {
        String[] credentials = null;
        //_log.info(&amp;quot;login&amp;quot;);
        try {
            credentials = authenticate();
        } catch (Exception e) {
            _log.error(e.getMessage());

            throw new LoginException();
        }

        if ((credentials != null) &amp;amp;&amp;amp; (credentials.length == 2)) {
            setPrincipal(getPortalPrincipal(credentials[0]));
            setPassword(credentials[1]);

            return true;
        }

        throw new LoginException();
    }

    @Override
    public boolean logout() {
        Subject subject = getSubject();

        Set&amp;lt;Principal&amp;gt; principals = subject.getPrincipals();

        principals.clear();

        return true;
    }

    // already authenticated in LR hooks - just build a context
    protected String[] authenticate()
            throws IOException, UnsupportedCallbackException {

        //_log.info(&amp;quot;authenticate&amp;quot;);
        NameCallback nameCallback = new NameCallback(&amp;quot;name: &amp;quot;);
        PasswordCallback passwordCallback = new PasswordCallback(
                &amp;quot;password: &amp;quot;, false);

        _callbackHandler.handle(
                new Callback[]{nameCallback, passwordCallback});

        String name = nameCallback.getName();

        String password = null;
        char[] passwordChar = passwordCallback.getPassword();

        if (passwordChar != null) {
            password = new String(passwordChar);
        }

        if (name == null) {
            return new String[]{&amp;quot;&amp;quot;, &amp;quot;&amp;quot;};
        }

        //_log.info(&amp;quot;simple names&amp;quot;);
        return new String[]{name, password};
    }

    protected String getPassword() {
        return _password;
    }

    protected Principal getPortalPrincipal(String name) throws LoginException {
        return new PortalPrincipal(name);
    }

    protected Principal getPrincipal() {
        return _principal;
    }

    protected Subject getSubject() {
        return _subject;
    }

    protected void setPassword(String password) {
        _password = password;
    }

    protected void setPrincipal(Principal principal) {
        _principal = principal;
    }

    private final static Logger _log = LoggerFactory.getLogger(CaciLoginModule.class);

    private CallbackHandler _callbackHandler;
    private String _password;
    private Principal _principal;
    private Subject _subject;

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then copied generated jar into wildfly server modules folder (no
  other dependencies required)&lt;/p&gt;
&lt;p&gt;Then in the ROOT.war altered jboss-deployment - added reference to
  the new module.&lt;/p&gt;
&lt;p&gt;In the wildfly config replaced outdated module with my&lt;/p&gt;
&lt;p&gt;All works. You have to do the similar for Tomcat&lt;/p&gt;</summary>
    <dc:creator>Alex Mirren</dc:creator>
    <dc:date>2022-07-20T08:26:01Z</dc:date>
  </entry>
  <entry>
    <title>RE: RE: Liferay 7.4 JAAS not working - returns to the login screen</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121473530" />
    <author>
      <name>Fayaj Shaikh</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121473530</id>
    <updated>2022-07-19T17:05:02Z</updated>
    <published>2022-07-19T15:44:02Z</published>
    <summary type="html">&lt;p&gt;Hi Alex, &lt;/p&gt;
&lt;p&gt;Thanks for the update.&lt;/p&gt;
&lt;p&gt;Can you please let me know/any pointers which you followed to create
  own JAAS module? How to create custom/own JAAS module?&lt;/p&gt;
&lt;p&gt;Are you using liferay's login portlet in your application or custom
  one? Have you added missing classes to Portal-kernel or Portal-impl? &lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Fayaj&lt;/p&gt;</summary>
    <dc:creator>Fayaj Shaikh</dc:creator>
    <dc:date>2022-07-19T15:44:02Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay 7.4 JAAS not working - returns to the login screen</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121473448" />
    <author>
      <name>Alex Mirren</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121473448</id>
    <updated>2022-07-19T15:30:50Z</updated>
    <published>2022-07-19T15:25:15Z</published>
    <summary type="html">&lt;p&gt;I had to create own JAAS module (copied from 7.1 sources). Now
  everything is ok, but left me puzzled why that was removed in 7.4&lt;/p&gt;</summary>
    <dc:creator>Alex Mirren</dc:creator>
    <dc:date>2022-07-19T15:25:15Z</dc:date>
  </entry>
  <entry>
    <title>RE: RE: Liferay 7.4 JAAS not working - returns to the login screen</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121473005" />
    <author>
      <name>Fayaj Shaikh</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121473005</id>
    <updated>2022-07-19T15:18:45Z</updated>
    <published>2022-07-19T04:43:05Z</published>
    <summary type="html">&lt;p&gt;Hi Alex,&lt;/p&gt;
&lt;p&gt;Is it wokring for you? We are also facing the same issue JAAS not
  working with Liferay 7.4 and tomcat.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Fayaj&lt;/p&gt;</summary>
    <dc:creator>Fayaj Shaikh</dc:creator>
    <dc:date>2022-07-19T04:43:05Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay 7.4 JAAS not working - returns to the login screen</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121453234" />
    <author>
      <name>Alex Mirren</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121453234</id>
    <updated>2022-06-26T09:57:46Z</updated>
    <published>2022-06-25T18:08:40Z</published>
    <summary type="html">&lt;p&gt;Some details - LR7.4, WildFly 22.0.0.&lt;/p&gt;
&lt;p&gt;When JAAS enabled:&lt;/p&gt;
&lt;p&gt;&amp;quot;Logon as user1&amp;quot; ---&amp;gt; WAR ---&amp;gt; ejb call ---&amp;gt; EAR
  bean method. In the EAR bean I have @SessionContext resource and
  getPrincipal gave me &amp;quot;user1&amp;quot;.&lt;/p&gt;
&lt;p&gt;&amp;quot;Logon as user2&amp;quot; ---&amp;gt; WAR ---&amp;gt; ejb call ---&amp;gt; EAR
  bean method. In the EAR bean I have @SessionContext resource and
  getPrincipal gave me &amp;quot;user2&amp;quot;.&lt;/p&gt;
&lt;p&gt;But in 7.4 JAAS is deprecated and I have to switch it off and
  getPrincipal returns &amp;quot;anonymus&amp;quot; for all logged users, which
  is wrong.&lt;/p&gt;
&lt;p&gt;Please help&lt;/p&gt;</summary>
    <dc:creator>Alex Mirren</dc:creator>
    <dc:date>2022-06-25T18:08:40Z</dc:date>
  </entry>
  <entry>
    <title>Liferay 7.4 JAAS not working - returns to the login screen</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121448947" />
    <author>
      <name>Alex Mirren</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121448947</id>
    <updated>2022-06-24T13:23:12Z</updated>
    <published>2022-06-23T10:09:50Z</published>
    <summary type="html">&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I successfully upgraded LR 7.1 to 7.4 (latest) but it seems like JAAS
  stopped working there and I able to login only
  with portal.jaas.enable=false now.&lt;/p&gt;
&lt;p&gt;portal-ext.properties:&lt;/p&gt;
&lt;p&gt;portal.jaas.enable=true&lt;br /&gt; portal.jaas.auth.type=screenName&lt;/p&gt;
&lt;p&gt;Are there any hidden changes I missed between 7.1 and 7.4?&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;
&lt;p&gt;
  &lt;br /&gt;  &lt;/p&gt;</summary>
    <dc:creator>Alex Mirren</dc:creator>
    <dc:date>2022-06-23T10:09:50Z</dc:date>
  </entry>
</feed>
