sinatra-portier 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/example/app.rb +23 -22
- data/example/config.ru +8 -2
- data/lib/sinatra/browserid.rb +3 -1
- metadata +21 -9
- data/example/views/index.erb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbb567b7fdc34ac49a53113b97b08a27b52c2fd1e85552c2ea44eb7cabfc9666
|
4
|
+
data.tar.gz: 3528e61f4a6fdc75ed3d2aee2bb80235a139860ca079b63d6ee3cfac487adbf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce0b199ca249d27d1cefc7db7c25f6bb5595165d7076843a190c448e61b596fcd2b0e3c362ddaf155ca6f7fb3002a73511b0ba4a8f111a5ffc1f5b1bc7b8e15c
|
7
|
+
data.tar.gz: 5c6e1b3cc2890c87f32bda865530accd31ff97df69c5977d1c1de5009337cda8f38447756da9ca202cfae8d34859c8f9d98a6a606efc4d76120ec5587dedceba
|
data/README.md
CHANGED
@@ -53,7 +53,13 @@ end
|
|
53
53
|
```
|
54
54
|
|
55
55
|
See the rdoc for more details on the helper functions. For a functioning
|
56
|
-
example app,
|
56
|
+
example app, start the app in the example directory:
|
57
|
+
|
58
|
+
```
|
59
|
+
bundle install
|
60
|
+
bundle exec rackup -p PORT
|
61
|
+
|
62
|
+
```
|
57
63
|
|
58
64
|
Available sinatra settings:
|
59
65
|
|
data/example/app.rb
CHANGED
@@ -1,28 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
require 'sinatra'
|
2
|
+
require 'sinatra/browserid'
|
3
|
+
|
4
|
+
|
5
|
+
register Sinatra::BrowserID
|
6
|
+
|
7
|
+
set :sessions, true
|
8
|
+
# Disabling origin-check is needed to make webkit-browsers like Chrome work.
|
9
|
+
# Behind a proxy you will also need to disable :remote_token, regardless for which browser.
|
10
|
+
set :protection, except: [:http_origin]
|
11
|
+
get '/' do
|
12
|
+
if authorized?
|
13
|
+
"Welcome, #{authorized_email}"
|
14
|
+
else
|
15
|
+
render_login_button
|
16
|
+
end
|
17
|
+
end
|
10
18
|
|
11
|
-
|
19
|
+
get '/secure' do
|
20
|
+
authorize! # require a user be logged in
|
12
21
|
|
13
|
-
|
14
|
-
|
15
|
-
end
|
22
|
+
authorized_email # browserid email
|
23
|
+
end
|
16
24
|
|
17
|
-
|
25
|
+
get '/logout' do
|
18
26
|
logout!
|
19
27
|
|
20
28
|
redirect '/'
|
21
|
-
|
22
|
-
|
23
|
-
get '/confidential' do
|
24
|
-
authorize!
|
25
|
-
|
26
|
-
"Hey #{authorized_email}, you're authorized!"
|
27
|
-
end
|
28
|
-
end
|
29
|
+
end
|
data/example/config.ru
CHANGED
data/lib/sinatra/browserid.rb
CHANGED
@@ -9,6 +9,7 @@ require 'ipaddr'
|
|
9
9
|
require "sinatra/base"
|
10
10
|
require 'sinatra/browserid/helpers'
|
11
11
|
require 'sinatra/browserid/template'
|
12
|
+
require 'addressable/uri'
|
12
13
|
|
13
14
|
# This module provides an interface to verify a users email address
|
14
15
|
# with browserid.org.
|
@@ -33,7 +34,8 @@ module Sinatra
|
|
33
34
|
begin
|
34
35
|
# 3. Server checks signature
|
35
36
|
# for that, fetch the public key from the LA instance (TODO: Do that beforehand for trusted instances, and generally cache the key)
|
36
|
-
|
37
|
+
public_key_jwks_uri = Addressable::URI.parse(settings.browserid_url + '/keys.json')
|
38
|
+
public_key_jwks = ::JSON.parse(URI.parse(public_key_jwks_uri).read)
|
37
39
|
public_key = OpenSSL::PKey::RSA.new
|
38
40
|
if public_key.respond_to? :set_key
|
39
41
|
# set n and d via the new set_key function, as direct access to n and e is blocked for some ruby and openssl versions.
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-portier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Fritchman
|
8
8
|
- Malte Paskuda
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -67,7 +67,21 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 0.0.9
|
70
|
-
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: addressable
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.8'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '2.8'
|
84
|
+
description:
|
71
85
|
email:
|
72
86
|
- malte@paskuda.biz
|
73
87
|
executables: []
|
@@ -77,7 +91,6 @@ files:
|
|
77
91
|
- README.md
|
78
92
|
- example/app.rb
|
79
93
|
- example/config.ru
|
80
|
-
- example/views/index.erb
|
81
94
|
- lib/sinatra/browserid.rb
|
82
95
|
- lib/sinatra/browserid/helpers.rb
|
83
96
|
- lib/sinatra/browserid/template.rb
|
@@ -85,7 +98,7 @@ files:
|
|
85
98
|
homepage: https://github.com/onli/sinatra-portier
|
86
99
|
licenses: []
|
87
100
|
metadata: {}
|
88
|
-
post_install_message:
|
101
|
+
post_install_message:
|
89
102
|
rdoc_options:
|
90
103
|
- "--inline-source"
|
91
104
|
require_paths:
|
@@ -101,9 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
114
|
- !ruby/object:Gem::Version
|
102
115
|
version: '0'
|
103
116
|
requirements: []
|
104
|
-
|
105
|
-
|
106
|
-
signing_key:
|
117
|
+
rubygems_version: 3.2.22
|
118
|
+
signing_key:
|
107
119
|
specification_version: 4
|
108
120
|
summary: Sinatra extension for user authentication with portier
|
109
121
|
test_files: []
|
data/example/views/index.erb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
</head>
|
4
|
-
<body>
|
5
|
-
|
6
|
-
<h1>Test App</h1>
|
7
|
-
|
8
|
-
<p>
|
9
|
-
<% if authorized? %>
|
10
|
-
Hello, <%= authorized_email %> <a href="/logout">(logout)</a>
|
11
|
-
<% else %>
|
12
|
-
<%= render_login_button %>
|
13
|
-
<% end %>
|
14
|
-
</p>
|
15
|
-
|
16
|
-
<p>
|
17
|
-
see a <a href="/confidential">page that requires a login</a>.
|
18
|
-
</p>
|
19
|
-
|
20
|
-
</body>
|
21
|
-
</html>
|