Skip to content

Instantly share code, notes, and snippets.

@akishin
Last active December 13, 2015 18:08
Show Gist options
  • Save akishin/4952544 to your computer and use it in GitHub Desktop.
Save akishin/4952544 to your computer and use it in GitHub Desktop.
restful-authentication で暗号化したパスワードに対応した sorcery 用 CryptoProvider。
# -*- 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