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

Authentication against JDBCRealm? #183

Open
alamakih opened this issue Nov 7, 2018 · 4 comments
Open

Authentication against JDBCRealm? #183

alamakih opened this issue Nov 7, 2018 · 4 comments
Labels

Comments

@alamakih
Copy link

alamakih commented Nov 7, 2018

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?

@bmuschko
Copy link
Owner

bmuschko commented Nov 7, 2018

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.

@alamakih
Copy link
Author

alamakih commented Nov 8, 2018

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".

@bmuschko
Copy link
Owner

bmuschko commented Nov 8, 2018

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

@nth347
Copy link

nth347 commented Feb 13, 2021

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

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

No branches or pull requests

3 participants