Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Issues getting users working #120

Open
aleclerc opened this issue Apr 10, 2015 · 1 comment
Open

Issues getting users working #120

aleclerc opened this issue Apr 10, 2015 · 1 comment

Comments

@aleclerc
Copy link

Trying to get users running on a simple Tomcat 6.0.43 application.

I made a really basic application to try and test the user stuff
build.gradle:

plugins {
    id "com.bmuschko.tomcat" version "2.1"
}
repositories {
    jcenter()
}
war{
    webXml = file('src/web.xml')
}
dependencies {
    def tomcatVersion = '6.0.43'
    tomcat "org.apache.tomcat:catalina:${tomcatVersion}",
    "org.apache.tomcat:coyote:${tomcatVersion}",
    "org.apache.tomcat:jasper:${tomcatVersion}"
}
tomcat {
    users {
        user {
            username = 'user1'
            password = '123456'
            roles = ['developers', 'admin', 'AuthenticatedUser']
        }
    }
}

web.xml:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <security-constraint>
        <display-name>Entire Application</display-name>
        <web-resource-collection>
            <web-resource-name>Entire Application</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
             <role-name>AuthenticatedUser</role-name>
        </auth-constraint>
    </security-constraint>
    <security-role>
        <role-name>AuthenticatedUser</role-name>
    </security-role>
    <login-config>
        <auth-method>BASIC</auth-method>
    </login-config>
</web-app>

Everytime I hit a url, I get the basic auth popup, as expected. When I try to enter a user this shows up in my gradle output:

The Server is running at http://localhost:8080/RunSimpleWebApp
Unexpected error
javax.security.auth.login.LoginException: No LoginModules configured for localEngine
        at javax.security.auth.login.LoginContext.init(LoginContext.java:282)
        at javax.security.auth.login.LoginContext.<init>(LoginContext.java:427)
        at org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:393)
        at org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:334)
        at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:181)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:528)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:853)

From what I can see in the plugin code, it should be setting the Realm of my webapp to use org.apache.catalina.realm.UserDatabaseRealm
Fairly notice tomcat user here, so bare with me if this is something obvious

@bmuschko
Copy link
Owner

Not quite sure why it isn't working. This might be an issue with the default web.xml setup which is missing some configuration. My guess is that you can fix it by providing a proper web.xml via the property webDefaultXml.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants