Announcement Announcement Module
No announcement yet.
Skip login with RequestMethod.GET Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Skip login with RequestMethod.GET

    Hi all.

    I have a serious problem with my security settings.

    My application has a security module which consists of 5 tables:

    - User: Users of the application
    - Role: application profiles
    - MenuOption: Options menu of the application
    - UserRole: the profiles assigned to application users
    - RoleMenuOption: menu options assigned to the application profiles

    As you can see, the module can even create new roles which may have the permissions that you want to assign.

    My problem is this:

    1. I start my application, it show me the login page. OK.
    2. In my login page, I write a URL in address toolbar of my browser. OK.
    3. If this request is served with a GET method in my @Controller, the application dont asked me user and password. Just putting the url from your browser toolbar. Skip the login! ERROR.

    For example:

    @RequestMapping(value = "/productForm.html", method = RequestMethod.GET)
    public @ModelAttribute("bean") MyBean viewProduct(Model model) {


    If I put in my address toolbar of my browser the address "http://hostort/myapp/product/productForm.html?id=282312" without having logged in, allows me to enter to productForm page.

    This is wrong. I searched several resources, sites, etc for a solution, and yet not find it.

    My file security-roles.xml

    PHP Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="" 

            <http auto-config="true" access-denied-page="/error.jsp">
                <intercept-url pattern="/images/**" filters="none" />
                <intercept-url pattern="/scripts/**" filters="none" />
                <intercept-url pattern="/styles/**" filters="none" />
                <form-login login-page="/login.jsp" 
                    authentication-failure-url="/login.jsp?error=true" />    
                <custom-filter ref="myFilter" before="FILTER_SECURITY_INTERCEPTOR" />
             <authentication-manager alias="authenticationManager">
                <authentication-provider ref="daoAuthenticationProvider">
                    <password-encoder ref="passwordEncoder"/>
             <beans:bean id="daoAuthenticationProvider" class="">
                <beans:property name="userDao" ref="userDao"/>
                <beans:property name="roleDao" ref="roleDao"/>
                <beans:property name="parametroDao" ref="parametroDao"/>
            <beans:bean id="anonymousAuthenticationProvider" class="">
                <beans:property name="key" value="anonymous"/>
            <beans:bean id="myFilter" class="">
                <beans:property name="securityMetadataSource" ref="securityMetadataSource" />
                <beans:property name="authenticationManager" ref="authenticationManager" />
                <beans:property name="accessDecisionManager" ref="accessDecisionManager" />

            <beans:bean  class="">
                    <beans:property name="allowIfAllAbstainDecisions" value="true" />
                    <beans:property name="decisionVoters">
                           <beans:bean class="" />
                           <beans:bean class="" />

            <beans:bean id="accessDecisionManager"
                class="" />

            <beans:bean id="securityMetadataSource" class="" 
                  init-method="initilize" >          
                  <beans:property name="opcionMenuDao" ref="opcionMenuDao" />  

    What happend? What am I doing wrong?

    I understand that the bean "myFilter" should prevent that anyone enter to some page in the application, if this person not logged in. But they are entering.

    Thanks in advance for any help regarding this issue.


  • #2
    <http auto-config="true" access-denied-page="/error.jsp">
    <intercept-url pattern="/images/**" access="permitAll()" />
    <intercept-url pattern="/scripts/**" access="permitAll()" />
    <intercept-url pattern="/styles/**"  access="permitAll()" /> 
    <intercept-url pattern="/yourloginPage/**"  access="permitAll()" />
    <intercept-url pattern="/**" access="isAuthenticated()"/>
    If you want a given url to require that the user be authenticated - you need to say so. Or a better practice would be to deny access to everything and then explicitly allow acces to unauthenticated users where appropriate.


    • #3
      Thanks arthomps.

      Some time ago, I tried the following:

      <intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY" />

      The results were the same: I can enter to page with GET method without login.

      When I tried with your indication, I'm getting the following error:

      GRAVE: Excepción enviando evento inicializado de contexto a instancia de escuchador de clase
      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name ' .FilterSecurityInterceptor#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [permitAll(), isAuthenticated()]

      Any ideas?



      • #4
        Your version of spring is different then mine. My comment is based off 3.1. Consult the docs for the version you're using. At a high level, you just need to tell spring security that it needs to require that the user be authenticated before they access a page.