sinatra-portier 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c94129062c52333ea72bf2365641641dfa2f86c
4
- data.tar.gz: ff07e3938417a2264a7ec21cd02796e7f276dd8c
3
+ metadata.gz: b69ad3706ecd35b13c72a3466113634f0a8aa89c
4
+ data.tar.gz: 7a91809bbc697a7d09a240bdfbbaab7ad7545773
5
5
  SHA512:
6
- metadata.gz: 81aff93f4d05484565968f9a953098e3fbfc9417f961fcac2f64be0af5dd359eb761b7ae06c033b88c322e1dc0f061a0dc369e11b7105b12d6cc57693f621a4c
7
- data.tar.gz: 8ea25ca20b8b54a4184ef409115d03d1037ea2a4caa619323b63490ed43c45cf3ebaabc7fe06ac2eaa938624fd83692a0377f52a44a49a644d2a1983855c0446
6
+ metadata.gz: 11f3a230f0f3a9a9d861ffa1cd4651cb0193154df0e343f234e2711be6b6d4c217ad7a63efae308c264d7d70c89e15415fb354c0332e6a005a2a5a85f6022a65
7
+ data.tar.gz: 9a6a524ce59d2d2a4b4e493b156f9f27d6cb778bd91608a385b6d1a1f3fee2c8f45a3e652e16276f9aa41137e64cca0456633a8ea747702d2c386879623d101a
data/README.md CHANGED
@@ -8,38 +8,48 @@ To learn more, [read about portier](https://portier.github.io/).
8
8
 
9
9
  Note that logins are not done from within a form on your site -- you provide a login form, and that will start up the login flow and redirect back to your main page.
10
10
 
11
- How to get started:
11
+ ## How to get started
12
+
13
+ Install the gem **sinatra-portier**"
14
+
15
+ ```
16
+ gem install sinatra-portier
17
+ ```
18
+
19
+ Then use it in your code:
20
+
12
21
 
13
22
  ```ruby
14
- require 'sinatra/base'
23
+ require 'sinatra'
15
24
  require 'sinatra/browserid'
16
25
 
17
- module MyApp < Sinatra::Base
18
- register Sinatra::BrowserID
19
26
 
20
- set :sessions, true
27
+ register Sinatra::BrowserID
21
28
 
22
- get '/'
23
- if authorized?
24
- "Welcome, #{authorized_email}"
25
- else
26
- render_login_button
27
- end
29
+ set :sessions, true
30
+ # Disabling origin-chek is needed to make webkit-browsers like Chrome work.
31
+ # Behind a proxy you will also need to disable :remote_token, regardless for which browser.
32
+ set :protection, except: [:http_origin]
33
+ get '/' do
34
+ if authorized?
35
+ "Welcome, #{authorized_email}"
36
+ else
37
+ render_login_button
28
38
  end
39
+ end
29
40
 
30
- get '/secure'
31
- authorize! # require a user be logged in
41
+ get '/secure' do
42
+ authorize! # require a user be logged in
32
43
 
33
- email = authorized_email # browserid email
34
- ...
35
- end
44
+ authorized_email # browserid email
45
+ end
36
46
 
37
- get '/logout'
38
- logout!
47
+ get '/logout' do
48
+ logout!
39
49
 
40
- redirect '/'
41
- end
50
+ redirect '/'
42
51
  end
52
+
43
53
  ```
44
54
 
45
55
  See the rdoc for more details on the helper functions. For a functioning
@@ -51,3 +61,4 @@ Available sinatra settings:
51
61
  other than https://broker.portier.io
52
62
  * <tt>:browserid_login_url</tt>: URL users get redirected to when the
53
63
  <tt>authorize!</tt> helper is called and a user is not logged in
64
+ * <tt>:browserid_button_class</tt> css class of the login button
@@ -10,8 +10,9 @@ module Sinatra
10
10
  # If the current user is not logged in, redirects to a login
11
11
  # page. Override the login page by setting the Sinatra
12
12
  # option <tt>:browserid_login_url</tt>.
13
- def authorize!
13
+ def authorize!(redirect: nil)
14
14
  session[:authorize_redirect_url] = request.url
15
+ session[:authorize_redirect_url] = redirect if redirect
15
16
  login_url = settings.browserid_login_url
16
17
  redirect login_url unless authorized?
17
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-portier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Fritchman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-17 00:00:00.000000000 Z
12
+ date: 2017-09-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements: []
90
90
  rubyforge_project:
91
- rubygems_version: 2.6.8
91
+ rubygems_version: 2.6.13
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Sinatra extension for user authentication with portier