Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7546719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:16:18+00:00 2026-05-30T09:16:18+00:00

I’m in the process of trying to setup database user authentication with Spring 3.

  • 0

I’m in the process of trying to setup database user authentication with Spring 3.
Now using the Spring included login form thing:

<form action="<c:url value="/j_spring_security_check" />" method="POST">
            <fieldset>
                <input name="j_username" type="text" placeholder="name" autofocus="autofocus" /><br/>
                <input name="j_password" type="password" placeholder="password" /><br/>
                <input type="submit" value="Login" />
            </fieldset>
        </form>

According to the logs (logging from my userService class that implements Spring UserDetailsService interface) this is resulting in a user being fetched from the database and roles assigned (using UserDetails.toString to view in logs).

When I hit an application URL I get sent to the login page correctly. I log in and regardless of URL I get redirected to my accessDenied page. Am I doing something wrong in my security config setup?

My security config follows:
(Removed refs to schema etc so I was allowed to post – they got picked up as URLs!)

    <global-method-security  pre-post-annotations="enabled"></global-method-security>
    <http auto-config="true" create-session="ifRequired" use-expressions="true" access-denied-page="/accessDenied">
        <logout invalidate-session="true" logout-success-url="/loggedOut" /> 
        <anonymous/>
        <form-login login-page="/login" authentication-failure-url="/login"/>

        <intercept-url pattern="/reports/**" access="hasRole('ROLE_REPORTS')" />
        <intercept-url pattern="/" access="hasRole('ROLE_REPORTS')" />

        <intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')" />

        <intercept-url pattern="/data/routes" method="GET" access="hasRole('ROLE_REPORTS')" />
        <intercept-url pattern="/data/routes" method="DELETE" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/routes" method="POST" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/routes" method="PUT" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/route/**" method="GET" access="hasRole('ROLE_REPORTS')" />
        <intercept-url pattern="/data/route/**" method="DELETE" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/route/**" method="POST" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/route/**" method="PUT" access="hasRole('ROLE_ADMIN')" />

        <intercept-url pattern="/data/patrolsummaries" method="GET" access="hasRole('ROLE_REPORTS')" />
        <intercept-url pattern="/data/patrolsummaries" method="DELETE" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/patrolsummaries" method="POST" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/patrolsummaries" method="PUT" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/patrolsummary/**" method="GET" access="hasRole('ROLE_REPORTS')" />
        <intercept-url pattern="/data/patrolsummary/**" method="DELETE" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/patrolsummary/**" method="POST" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/patrolsummary/**" method="PUT" access="hasRole('ROLE_ADMIN')" />

        <intercept-url pattern="/data/guards" method="GET" access="hasRole('ROLE_REPORTS')" />
        <intercept-url pattern="/data/guards" method="DELETE" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/guards" method="POST" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/guards" method="PUT" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/guard/**" method="GET" access="hasRole('ROLE_REPORTS')" />
        <intercept-url pattern="/data/guard/**" method="DELETE" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/guard/**" method="POST" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/data/guard/**" method="PUT" access="hasRole('ROLE_ADMIN')" />

        <intercept-url pattern="/include/js/pages/admin/**" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/include/js/pages/all.js" access="hasRole('ROLE_REPORTS')" />
        <intercept-url pattern="/include/js/pages/**" access="hasRole('ROLE_REPORTS')" />

        <intercept-url pattern="/include/js/**" access="hasRole('ROLE_ANONYMOUS')" />

        <intercept-url pattern="/public/**" filters="none"/>
        <intercept-url pattern="/login" filters="none"/>
        <intercept-url pattern="/loggedOut" filters="none"/>
        <intercept-url pattern="/include/css/**" filters="none"/>
        <intercept-url pattern="/include/img/**" filters="none"/>
        <intercept-url pattern="/include/**" access="hasRole('ROLE_REPORTS')" />
    </http>

    <beans:import resource="hibernate-context.xml" />
    <context:component-scan base-package="uk.co.romar.guardian.services" />

    <beans:bean id="userService" class="uk.co.romar.guardian.services.UserServiceImpl" />
    <beans:bean id="pwdEncoder" class="org.springframework.security.authentication.encoding.ShaPasswordEncoder" />
    <!-- <beans:bean id="saltSource" class="??"/>  -->
    <authentication-manager alias="authenticationManager">
        <authentication-provider user-service-ref="userService">  
        </authentication-provider>
    </authentication-manager>
</beans:beans>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:16:19+00:00Added an answer on May 30, 2026 at 9:16 am

    Thanks all for the input.

    The problem was in my own code where I copy role/authorisations from the database hibernate object to the UserDetails object that will be returned by the loadUserByUsername implementation.

    Spring was behaving, it just had incorrect roles assigned to the UserDetails object because of the mistake in my code.

    Spring / config was correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.