Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove all of the hacks and support infrastructure around Rack sessions. Rails provides this by default so we don't need it for 90% of users. The other 10% should know and provide a Rack session. This is a big change and has the potential to break many installs. It will be part of the 7.0 major version bump and require a lengthy beta period to ensure we document as many edge cases and solutions as possible. See also #4671, #4728 and many others.
- Loading branch information
Showing
5 changed files
with
93 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Welcome to Sidekiq 7.0 | ||
|
||
|
||
## Web UI Sessions | ||
|
||
One focus of this major version upgrade is a refactoring of the Web UI | ||
in order to simplify and integrate better with Rails and Rack sessions. | ||
The most frustrating support and user pain point has been debugging problems with | ||
the Web UI's use of Rack sessions. | ||
|
||
Previously Sidekiq::Web would provide a basic cookie session if not | ||
configured but this often collided with the Rails session. Starting in | ||
7.0, Sidekiq will not provide a session. The application developer must | ||
provide a session somehow. Here's the main ways: | ||
|
||
### Rails | ||
|
||
Mount Sidekiq::Web within the application's routes in `config/routes.rb`. | ||
Rails already provides a session to anything mounted within it. | ||
|
||
```ruby | ||
Rails.application.routes.draw do | ||
mount Sidekiq::Web => "/sidekiq" | ||
.... | ||
end | ||
``` | ||
|
||
### Rack | ||
|
||
If you are not running Rails but mounting Sidekiq::Web as a basic Rack | ||
app, first create a shared secret key in IRB: | ||
|
||
```ruby | ||
require 'securerandom' | ||
secret_key = SecureRandom.hex(32) | ||
File.open(".secret.key", "w") {|f| f.write(secret_key) } | ||
``` | ||
|
||
And then configure your session middleware to use that secret: | ||
|
||
```ruby | ||
use Rack::Session::Cookie, secret: File.read(".secret.key") | ||
run Sidekiq::Web | ||
``` | ||
|
||
This is similar to how Rails puts its secret_key in `config/initializers/secret_token.rb` | ||
so all Rails processes can share the same key. The session cookies will | ||
be encrypted with that secret so no one can read them but your app code. | ||
See the [Rack::Session::Cookie RDoc](https://www.rubydoc.info/gems/rack/Rack/Session/Cookie) for more options. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters