2011-05-24 147 views
2

我目前使用Grails和Spring安全插件工作,努力實現一個密碼過期的工作流程。我已經配置了插件如預期:Grails的春季安全插件 - 用戶名逃避問題

grails.plugins.springsecurity.failureHandler.exceptionMappings = [ 
    'org.springframework.security.authentication.CredentialsExpiredException': '/login/passwordExpired' 
] 

,在我passwordExpired行動,如果我稱之爲:

def username = session['SPRING_SECURITY_LAST_USERNAME'] 

然後在用戶名中的HTML特殊字符會被轉義像

my_user => my_user 
my-user => my-user 

是否有可能把這個逃跑了嗎?

Ritesh在這裏提到spring_security_last_username SPRING_SECURITY_LAST_USERNAME已棄用,那我還能用什麼?

任何幫助,在此先感謝!

回答

5

絃樂'SPRING_SECURITY_LAST_USERNAME'不會被棄用 - 老常與價值,並已移到一個新的名稱,但相同的值。所以你的代碼將繼續有效。

而不是改變的東西無法逃避,你可以很容易地取消逃脫

import org.apache.commons.lang.StringEscapeUtils 
... 
String username = StringEscapeUtils.unescapeHtml(session['SPRING_SECURITY_LAST_USERNAME']) 
+0

我正在尋找一個無縫工具一段時間,但...是啊Apache Commons ...謝謝! – Aston 2011-05-24 15:47:25

+0

FYI在2.0+版本的插件,該值現在沒有逃脫,所以你必須顯示 – 2013-10-16 20:44:56

1

你並不需要使用的工具。使用Grails HTML編解碼器:

username = session['SPRING_SECURITY_LAST_USERNAME']?.decodeHTML() 
+0

之前逃吧但選擇Spring Security中存儲這些逃脫是非常值得懷疑的。 – 2012-07-25 12:59:45