gradle-tomcat-plugin icon indicating copy to clipboard operation
gradle-tomcat-plugin copied to clipboard

Authentication against JDBCRealm?

Open alamakih opened this issue 6 years ago • 4 comments

I have a webapp that does form based authentication against JDBCRealm, which is normally configured in server.xml. Is there some way to get the authentication working in tomcat-plugin?

alamakih avatar Nov 07 '18 14:11 alamakih

I am not fully sure if it works for JDBCRealm as well but have a look at this example. You can define users with roles.

bmuschko avatar Nov 07 '18 16:11 bmuschko

Figured it out. Realm configuration can be done in [webapp]/META-INF/context.xml, so no need for server.xml. Now if I'd just get webapp dir working from "foo/WebContent" instead of "src/main/webapp".

alamakih avatar Nov 08 '18 14:11 alamakih

The configuration of foo/WebContent is specific to the war plugin so you'll need to check its documentation.

bmuschko avatar Nov 08 '18 14:11 bmuschko

Hello, project's maintainer! Thank you for your great work. I am setting up authentication using Basic authentication, servlet, and the Gradle Tomcat Plugin. But it does not work. I defined user roles in web.xml, and here is my tomcat section in build.gradle:

tomcat {
    httpProtocol = 'org.apache.coyote.http11.Http11Nio2Protocol'
    ajpProtocol  = 'org.apache.coyote.ajp.AjpNio2Protocol'

    contextPath = '/'
    
    users {
        user {
            username = 'user1'
            password = '123456'
            roles = ['admin']
        }

        user {
            username = 'user2'
            password = 'abcdef'
            roles = ['user']
        }
    }
}

When I entering the correct credential in the pop-up asking for login and password, the site still doesn't let me log in, the pop-up will raise again. Please help me get it to work correctly. Thank you

nth347 avatar Feb 13 '21 09:02 nth347