iconnect / rails-session

Decrypt Ruby on Rails sessions in Haskell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rails-session

Build Status

Haskell library to decrypt Ruby on Rails sessions in order to allow you to share them between Ruby on Rails and Haskell web applications.

Usage

-- | Read session id from encrypted Rails cookie on the filesystem.
example :: FilePath -> IO (Maybe ByteString)
example path = do
  rawCookie <- BS.readFile path
  let appSecret = mkSecretKeyBase "development_secret_token"
  let cookie = mkCookie rawCookie
  case decodeEither Nothing appSecret cookie of
    Left _ ->
      pure Nothing
    Right rubyObject ->
      pure $ sessionId rubyObject

See more in Spec.hs.

Contributing

  1. Fork it.
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Add some feature').
  4. Push to the branch (git push origin my-new-feature).
  5. Create new Pull Request.

Contributors

Similar Libraries

About

Decrypt Ruby on Rails sessions in Haskell

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Haskell 91.3%Language:Shell 6.1%Language:Makefile 2.6%