Last active
December 13, 2015 18:08
-
-
Save akishin/4952544 to your computer and use it in GitHub Desktop.
restful-authentication で暗号化したパスワードに対応した sorcery 用 CryptoProvider。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
require "digest/sha1" | |
# restful-authentication の config/initializers/site_keys.rb に設定されている | |
# REST_AUTH_SITE_KEY の値を持ってきて設定 | |
REST_AUTH_SITE_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
module Sorcery | |
module CryptoProviders | |
class RestfulAuthentication < SHA1 | |
class << self | |
def encrypt(*tokens) | |
password, salt = tokens.flatten | |
digest = REST_AUTH_SITE_KEY | |
stretches.times { | |
digest = secure_digest([digest, salt, password, REST_AUTH_SITE_KEY].join(join_token)) | |
} | |
digest | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment