Following is configuration in my security-config file:
<security:http use-expressions="true">
<security:intercept-url pattern="/adminarea"
access="hasRole('admin')" />
<security:intercept-url pattern="/logincheck"
access="permitAll" />
<security:intercept-url pattern="/newaccount"
access="permitAll" />
<security:intercept-url pattern="/createnewaccount"
access="permitAll" />
<security:intercept-url pattern="/home"
access="isAuthenticated()" />
<security:intercept-url pattern="/static/**"
access="permitAll" />
<security:intercept-url pattern="/" access="permitAll" />
<security:intercept-url pattern="/**" access="denyAll" />
<security:form-login login-page="/"
authentication-failure-url="/?error=true" default-target-url="/home" />
</security:http>
I am using spring default login which is working fine. But when I try to aceess /adminarea
I get an Http Status 403 - Access is denied
error. Any help.
Edited: AuthenticationManager
<security:authentication-manager>
<security:authentication-provider>
<security:jdbc-user-service
data-source-ref="dataSource" />
</security:authentication-provider>
</security:authentication-manager>
code on JSP:
<sec:authentication property="principal"/>
<sec:authorize access="hasRole('admin')">
<a href="${pageContext.request.contextPath}/adminarea">Admin Area</a>
</sec:authorize>
first tag outputs following
rg.springframework.security.core.userdetails.User@6d8e08d5: Username: [email protected]; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: admin
second tag outputs nothing.
<security:intercept-url pattern="/**" access="denyAll" />
this code is causing error. – Amit singh