Announcement Announcement Module
No announcement yet.
Accessing SPRING_SECURITY_LAST_USERNAME in the view Page Title Module
Move Remove Collapse
This topic is closed
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Accessing SPRING_SECURITY_LAST_USERNAME in the view

    I got a little familiar with Acegi for a side project and took some time off from the project. Now Spring Security is out and I'm trying to move to the simpler configuration.

    However, I'm having trouble accessing SPRING_SECURITY_LAST_USERNAME in the AuthenticationProcessingFilter. How do I add AuthenticationProcessingFilter to my configuration and get access to it within my Freemarker templates?

    I'm relatively new to Freemarker, Spring, and Spring Security in general so I could be missing something obvious. Complicating matters is that I switched from Acegi & Velocity to Spring Security and Freemarker at the same time.

    Somehow, I need to expose ionProcessingFilter in the Freemarker template. Is there something I can do in the XML configuration?

    This is my current config:

    <?xml version="1.0" encoding="UTF-8"?>
    <b:beans xmlns=""
      <!--  Authentication/Authorization -->
      <http auto-config='true'>
        <intercept-url pattern="/admin" access="ROLE_ADMIN"/>
        <intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
        <form-login login-page="/login.htm" authentication-failure-url="/login.htm?login_failed=1"/>
        <logout logout-success-url="/"/>
        <jdbc-user-service data-source-ref="dataSource"  
        users-by-username-query="SELECT username, pass, enabled FROM account WHERE username=?"  
        authorities-by-username-query="SELECT a.username, r.role AS authority FROM account a INNER JOIN account_roles ar ON = ar.account_id INNER JOIN role r ON ar.role_id = WHERE a.username = ?    
      <b:bean id="authenticationProcessingFilter" class="">
        <custom-filter position="AUTHENTICATION_PROCESSING_FILTER"/>
        <b:property name="defaultTargetUrl" value="/"/>
        <b:property name="authenticationManager" ref="authenticationManager"/>
      <authentication-manager alias="authenticationManager"/>
      <!-- This bean is optional; it isn't used by any other bean as it only listens and logs -->
      <b:bean id="loggerListener" class=""/>

  • #2
    Spring Security doesn't know anything about how your login page is rendered, so you can't set anything freemarker related in your security config. Why can't you just store the value in the model you are passing to freemarker?