{"id":14956021,"url":"https://github.com/rnd-soft/warden_cookie_session","last_synced_at":"2025-10-17T12:45:31.874Z","repository":{"id":56897772,"uuid":"220401145","full_name":"RND-SOFT/warden_cookie_session","owner":"RND-SOFT","description":"[MIRROR] Warden Cookie Session is a warden strategy to store auth in custom encrypted cookie(instead of rack:session).","archived":false,"fork":false,"pushed_at":"2023-04-04T07:21:14.000Z","size":27,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T14:18:25.399Z","etag":null,"topics":["gem","rails","ruby","ruby-on-rails","warden"],"latest_commit_sha":null,"homepage":"https://br.rnds.pro/ruby/warden_cookie_session","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RND-SOFT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-08T06:26:02.000Z","updated_at":"2023-04-10T15:21:15.000Z","dependencies_parsed_at":"2024-09-02T15:33:55.844Z","dependency_job_id":"db9e76bf-0a7c-4b4a-8ff1-dc8f2ec313ac","html_url":"https://github.com/RND-SOFT/warden_cookie_session","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"7c3f05fb491f1098610d82b52c0b34e4f64965ee"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RND-SOFT%2Fwarden_cookie_session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RND-SOFT%2Fwarden_cookie_session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RND-SOFT%2Fwarden_cookie_session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RND-SOFT%2Fwarden_cookie_session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RND-SOFT","download_url":"https://codeload.github.com/RND-SOFT/warden_cookie_session/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237944057,"owners_count":19391588,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gem","rails","ruby","ruby-on-rails","warden"],"created_at":"2024-09-24T13:12:11.719Z","updated_at":"2025-10-17T12:45:26.823Z","avatar_url":"https://github.com/RND-SOFT.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Warden Cookie Session\n\n\n[![Gem Version](https://badge.fury.io/rb/warden_cookie_session.svg)](https://rubygems.org/gems/warden_cookie_session)\n[![Gem](https://img.shields.io/gem/dt/warden_cookie_session.svg)](https://rubygems.org/gems/warden_cookie_session/versions)\n[![YARD](https://badgen.net/badge/YARD/doc/blue)](http://www.rubydoc.info/gems/warden_cookie_session)\n\n\n[![Coverage](https://lysander.rnds.pro/api/v1/badges/cs_coverage.svg)](https://lysander.rnds.pro/api/v1/badges/cs_coverage.html)\n[![Quality](https://lysander.rnds.pro/api/v1/badges/cs_quality.svg)](https://lysander.rnds.pro/api/v1/badges/cs_quality.html)\n[![Outdated](https://lysander.rnds.pro/api/v1/badges/cs_outdated.svg)](https://lysander.rnds.pro/api/v1/badges/cs_outdated.html)\n[![Vulnerabilities](https://lysander.rnds.pro/api/v1/badges/cs_vulnerable.svg)](https://lysander.rnds.pro/api/v1/badges/cs_vulnerable.html)\n\n\n\nWarden Cookie Session is a warden strategy to store auth in custom encrypted cookie(instead of rack:session).\nThe main puprpose to allow store authorization between multiple rails applications, without sharing `secret_key_base`.  \n\n\n# Usage\n\nSetup `Warden::CookieSession` in initializer and provide wrapper.\n\n```ruby\n\nWarden::CookieSession.configure do |config|\n  config.cookie = Rails.application.secrets['shared_cookie']\n  config.secret = Rails.application.secrets['shared_secret']\n\n  config.wrapper = Warden::CookieSession::DefaultWrapper.new(User)\nend\n```\n\nDefault wrapper just fetch user from model:\n```ruby\nmodule Warden\n  module CookieSession\n    class DefaultWrapper\n\n      def initialize(klass = nil)\n        @klass = klass\n      end\n\n      def serialize_record(record)\n        # like in https://github.com/plataformatec/devise/blob/master/lib/devise/models/authenticatable.rb\n        [record.to_key, record.authenticatable_salt]\n      end\n\n      def fetch_record(key)\n        @klass.find(key.first)\n      end\n\n      def validate_record(record, salt)\n        # like in https://github.com/plataformatec/devise/blob/master/lib/devise/models/authenticatable.rb\n        record if record \u0026\u0026 record.authenticatable_salt == salt\n      end\n\n    end\n  end\nend\n```\n\n# Advansed Usage\n\nWith `Warden::CookieSession` we can fetch user data remotly ex. from API:\n\n```ruby\n\nWarden::CookieSession.configure do |config|\n  config.cookie = Rails.application.secrets['shared_cookie']\n  config.secret = Rails.application.secrets['shared_secret']\n\n    class RemoteWrapper\n      def serialize_record(record)\n        [record.to_key, record.authenticatable_salt]\n      end\n\n      def fetch_record(key)\n        FetchRemoteUserAndSalt.run!(key)\n      end\n\n      def validate_record(record, salt)\n        record if record \u0026\u0026 record.authenticatable_salt == salt\n      end\n\n    end\n\n  config.wrapper = Warden::CookieSession::DefaultWrapper.new(User)\nend\n```\n\n\n# Installation\n\nIt's a gem:\n```bash\n  gem install warden_cookie_session\n```\nThere's also the wonders of [the Gemfile](http://bundler.io):\n```ruby\n  gem 'warden_cookie_session'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frnd-soft%2Fwarden_cookie_session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frnd-soft%2Fwarden_cookie_session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frnd-soft%2Fwarden_cookie_session/lists"}