[JBoss] How to migrate PicketBox custom login module to Elytron?

Discussão em 'StackOverflow' iniciado por Stack, Agosto 4, 2021.

  1. Stack

    Stack Membro Participativo

    I have an application that deploys on Wildfly and in the standalone there is this entry:

    <subsystem xmlns="urn:jboss:domain:security:2.0">
    <security-domains>
    <security-domain name="customLoginModule" cache-type="default">
    <authentication>
    <login-module code="com.mypackage.MyLoginModule flag="required"/>
    </authentication>
    </security-domain>
    ...


    There is also this class:

    public class MyLoginModule extends UsernamePasswordLoginModule {

    public static void authenticateUser(HttpServletRequest request, String principalName) {
    try {
    request.login(principalName, "PasswordKey");
    } catch (ServletException ex) {
    throw new RuntimeException("...");
    }
    }

    public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {

    super.iniitalize(subject, callbackHandler, sharedState, options);
    }

    private static Group[] createUserGroup() {

    SimpleGroup group = new SimpleGroup("Roles");

    group.addMember(new SimplePrincipal("MyUser"));

    return new Group[]{group};
    }

    @Override
    protected String getUsersPassword() {
    return "PasswordKey";
    }

    @Override
    protected boolean validatePassword(String input, String expected) {
    return input.equals(expected);
    }

    @Override
    protected Group[] getRoleSets() {
    return createUserGroup();
    }
    }


    Inside our login servlet, the static method authenticateUser() is called.

    I do not understand exactly what is the point of this class and how security is working. The need is to remove the PicketBox dependency that provides UsernamePasswordLoginModule because it uses this deprecated Group class. How can I modify the above logic and security-domain in the standalone.xml to work with Elyton security? I read this migration guide but I am not able to understand how it could be applied in my case. Please help, thanks in advance

    Continue reading...

Compartilhe esta Página