Git Product home page Git Product logo

redbird's Introduction

CircleCI

Redbird

Redbird is part of the thoughtbot Elixir family of projects.

Redbird is a Redis session adapter for Plug.Session. It works great for Phoenix!

Installation

Add Redbird to your dependency list.

  def deps do
    [
      {:redbird, "~> 0.7.1"},
    ]
  end

Configure Plug

plug Plug.Session,
  store: :redis,
  key: "_app_key",
  expiration_in_seconds: 3000 # Optional - default is 30 days

Configure Redbird

All redbird created keys are automatically namespaced with redbird_session by default. If you'd like to set your own custom, per app, configuration you can set that in the config.

config :redbird, key_namespace: "my_app_"

Configure Redix

Redbird uses Redix to communicate with Redis. You can pass configuration options as redis_options:

config :redbird,
  redis_options: [
    host: System.get_env("REDIS_HOST"),
    port: System.get_env("REDIS_PORT"),
    password: System.get_env("REDIS_PASSWORD"),
    ssl: true
  ]

For a full list of configuration options, please see Redix's connection options.

Mix Tasks

This will give you access to the mix task mix redbird.delete_all_sessions, for clearing all Redbird created user sessions from Redis. If you have not set up a per app key_namespace in the config this will clear ALL Redbird sessions on your server. Otherwise it will only clear the sessions created by the specific app you're running it in.

Contributing

See the CONTRIBUTING document. Thank you, contributors!

License

Redbird is Copyright (c) 2017-2020 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the LICENSE file.

About

thoughtbot

Redbird is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.

We love open source software, Elixir, and Phoenix. See our other Elixir projects, or hire our Elixir Phoenix development team to design, develop, and grow your product.

redbird's People

Contributors

aellispierce avatar danadaldos avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar drapergeek avatar foxbenjaminfox avatar germsvel avatar kuiro5 avatar lancejjohnson avatar techgaun avatar tysongach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

redbird's Issues

Extra setup for distillery

I recently tried pulling this into my project and while I am able to use redbird when running mix phx.server or via iex -S mix, when I package up my application with distillery redbird seems to fail. Below is the error that I get:

[info] Application redbird exited: Redbird.start(:normal, []) returned an error: shutdown: failed to start child: Redbird.Redis
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, {:connection_error, {:connection_error, :econnrefused}}}
            (redbird) lib/redis.ex:3: Redbird.Redis.start_link/1
            (stdlib) supervisor.erl:365: :supervisor.do_start_child/2
            (stdlib) supervisor.erl:348: :supervisor.start_children/3
            (stdlib) supervisor.erl:314: :supervisor.init_children/2
            (stdlib) gen_server.erl:365: :gen_server.init_it/2
            (stdlib) gen_server.erl:333: :gen_server.init_it/6
            (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

I'll do some more digging around to see what's going on, but does this seem to be an issue with redbird or with distillery?

Session cookie Expires/Max-Age not in sync with expiration_in_seconds

I expected a problem where I did configure Plug.Session like this:

plug Plug.Session,
    store: :redis,
    key: "_session_key",
    expiration_in_seconds: 60

This did work as expected - user was logged out after 60 seconds. However, I also noticed that the cookie, which holds session id does not have Expires/Max-Age set, which means that this is essentially a Session cookie which might get deleted after browser restart.

This causes a problem where expiration_in_seconds is set to a longer period (months, for example), but user still needs to relogin after each browser restart.

That kind of a behavior was unexpected to me since I would have expected that the cookie expiration will be the same as expiration_in_seconds. I did not also find any mentions about this behavior in the README.

I managed to solve this problem with the following configuration:

plug Plug.Session,
    store: :redis,
    key: "_session_key",
    expiration_in_seconds: 60,
    max_age: 60

If this behavior is intentional then maybe at least mention it in the README?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.