2011-10-28 52 views
2

我開始在grails中使用spring-security-core-1.1.3插件。 我的身份驗證的應用程序發送請求到服務器:grails和spring security core插件 - 來自客戶端的authenticateion

def authSomeAction = { 
    def req = ...//http requet here 
    if(req.contains("yes")){ 
     render "There is such user" 
    }else{ 
     render "There is no such user" 
    } 
} 

我可以成功地進行身份驗證使用SpringSecurityUtils.reauthenticate(用戶名,密碼)方法只有當我已在客戶端創建的用戶

可有人請詳細幫助我瞭解我如何實施 插件在客戶端工作(沒有數據庫)......?

回答

0

我對Grails非常陌生,所以我可以清楚地知道基礎,但我懷疑您的問題可能與您在創建用戶時編碼密碼的方式有關。你是否在使用「客戶端」創建用戶時使用相同的方法,而不是使用其他方法?

例如,當我第一次使用spring-security-ui插件時,我使用捆綁的實用程序創建了用戶,並且它們都未能登錄。如果我理解正確,則會更新spring-security-core因爲spring-security-ui已經將需要將控制器中的密碼編碼到用戶本身內部。例如,在春季安全的UI UserController.save()隨該插件,發生這種情況:

if (params.password) { 
    String salt = saltSource instanceof NullSaltSource ? null : params.username 
    user.password = springSecurityService.encodePassword(params.password, salt) 
} 

但後來我的User類有這個(直接從S2插件的例子)

def beforeInsert() { 
    encodePassword() 
} 

def beforeUpdate() { 
    if (isDirty('password')) { 
     encodePassword() 
    } 
} 

protected void encodePassword() { 
    password = springSecurityService.encodePassword(password) 
} 

由於我的User類自己管理編碼,所以出現了一個雙重編碼,導致用它創建的登錄失敗。在你的應用程序中是否會出現類似的情況?當你從客戶端以外創建用戶時,你的編碼方式是否一樣?

+0

Dave Shuck謝謝你的回覆...是的,我在「客戶端」編碼密碼 我沒有編碼密碼的問題,我只想着如何組織客戶端的插件工作。 – user1017778

相關問題