Golang复制Rails Devise gem的密码加密

huangapple go评论73阅读模式
英文:

Golang duplicate rails Devise gem password encryption

问题

我必须在一个使用Beego框架和Golang的新应用中对用户进行身份验证,问题是数据库来自使用gem Devise实现身份验证的Rails应用程序。
我已经查看了gem Bcrypt的实现,但是不太明白如何复制encrypted_password以验证用户...
你能帮我吗?

更新1
使用bcrypt没有帮助

b_password := []byte(password)
hashedPassword, err := bcrypt.GenerateFromPassword(b_password, bcrypt.DefaultCost)

我得到了不同的密码。

英文:

I have to authenticate user in a new app which uses Beego framework for Golang, twist is that DB is from Rails application where authentication is implemented using gem Devise .
I've looked at gem Bcrypt implementation
https://github.com/codahale/bcrypt-ruby/blob/master/lib/bcrypt/password.rb
But can't quite grasp how to replicate encrypted_password to validate user...
Can you please help me ?

UPDATE1
using bcrypt didn't help

> b_password := []byte(password)
> hashedPassword, err := bcrypt.GenerateFromPassword(b_password, bcrypt.DefaultCost)

I get different passwords.

答案1

得分: 1

我找到了 https://github.com/consyse/go-devise-encryptor 这个项目,正好可以完成这个任务。

英文:

I found out https://github.com/consyse/go-devise-encryptor exactly for doing this task

答案2

得分: 0

这个设备加密器和golang中的bcrypt身份验证做着相同的事情,而且我没有看到Rails Devise哈希和go-devise-encryptor密码哈希相等。

英文:

This devise encryptor doing same thing as bcrypt auth in golang, also i dont see Rails Devise hash and go-devise-encryptor password hash equal.

huangapple
  • 本文由 发表于 2017年2月7日 21:10:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/42090742.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定