sinatra-portier 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +31 -20
- data/lib/sinatra/browserid/helpers.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b69ad3706ecd35b13c72a3466113634f0a8aa89c
|
4
|
+
data.tar.gz: 7a91809bbc697a7d09a240bdfbbaab7ad7545773
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
23
|
+
require 'sinatra'
|
15
24
|
require 'sinatra/browserid'
|
16
25
|
|
17
|
-
module MyApp < Sinatra::Base
|
18
|
-
register Sinatra::BrowserID
|
19
26
|
|
20
|
-
|
27
|
+
register Sinatra::BrowserID
|
21
28
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
31
|
-
|
41
|
+
get '/secure' do
|
42
|
+
authorize! # require a user be logged in
|
32
43
|
|
33
|
-
|
34
|
-
|
35
|
-
end
|
44
|
+
authorized_email # browserid email
|
45
|
+
end
|
36
46
|
|
37
|
-
|
38
|
-
|
47
|
+
get '/logout' do
|
48
|
+
logout!
|
39
49
|
|
40
|
-
|
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.
|
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
|
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.
|
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
|