Skip to content

Instantly share code, notes, and snippets.

@epochwolf
Created May 27, 2010 16:42
Show Gist options
  • Save epochwolf/416030 to your computer and use it in GitHub Desktop.
Save epochwolf/416030 to your computer and use it in GitHub Desktop.
def create_wiki_token(user, expires)
doku_data = {
:user => user.name,
:email => user.email,
:groups => user.wiki_groups,
:expires => expires.to_i
}
doku_data = Base64.encode64(doku_data.to_json)
secret = Rails.application.config.cookie_secret
doku_digest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.const_get("SHA1").new, secret, doku_data)
cookies[:wiki] = {
:value => "#{doku_data}--#{doku_digest}",
:expires => expires
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment