sinatra-portier 1.4.0 → 1.5.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: fbc4d5679b36bfe8c83d6657e0835d7b4747f76b
4
- data.tar.gz: bbe2ce4265fc758c9206f4e7986876e2477f72a5
3
+ metadata.gz: 2ac31d78e15995c54caf11c46d44721dacf2cbf4
4
+ data.tar.gz: 261b939a507dcddd9e7636a622d7a3f7eb958d28
5
5
  SHA512:
6
- metadata.gz: cdc7a80021f5577be656d395f0a809e4f9e3e7b937545e295ec4e5cf98a881701266e0d504395855ae77815047ca0b53aea09d511ab22b921ffef3bf320f4352
7
- data.tar.gz: a55f87fec6301cc3d3fa1727bd66d3b2d96a062c7a7190082fe640c7352f2f6547b66b0481d91f945bd74a9332b106913c85800b1dc777385ec0683d7f3a2b94
6
+ metadata.gz: a170fb2cf045d6a5eb06d4dbe3570123ad46c2dea7331d449024d36dfb24f9899c52bb22144e3cbe225c29650b185ccdd00657a140746392c49de521d8db0213
7
+ data.tar.gz: b2f2c9c8d1e98daa41d7f2fdfcfea2886f8701ef0df1ebe59343c58218daf4a813283ae8c263feec771fe1198ec45cb898d29085a81542c4caf150c0ff84f626
@@ -4,6 +4,8 @@ require "open-uri"
4
4
  require 'json'
5
5
  require 'url_safe_base64'
6
6
  require 'jwt'
7
+ require 'simpleidn'
8
+ require 'ipaddr'
7
9
  require "sinatra/base"
8
10
  require 'sinatra/browserid/helpers'
9
11
  require 'sinatra/browserid/template'
@@ -44,7 +46,7 @@ module Sinatra
44
46
  id_token["exp"] > Time.now.to_i &&
45
47
  id_token["email_verified"] &&
46
48
  id_token["nonce"] == session[:nonce])
47
- session[:browserid_email] = id_token["email"]
49
+ session[:browserid_email] = id_token['sub']
48
50
  session.delete(:nonce)
49
51
  if session['redirect_url']
50
52
  redirect session['redirect_url']
@@ -28,6 +28,28 @@ module Sinatra
28
28
  session[:browserid_email]
29
29
  end
30
30
 
31
+ # Normalize the email like the broker will do it, see
32
+ # https://github.com/portier/portier.github.io/blob/master/specs/Email-Normalization.md
33
+ def normalize_email(email)
34
+ begin
35
+ user, domain = email.split("@")
36
+ if user == nil or user.empty?
37
+ raise ArgumentError.new('user part must not be empty')
38
+ end
39
+ user = user.downcase
40
+ domain = SimpleIDN.to_ascii(domain).downcase
41
+ begin
42
+ IPAddr.new(domain)
43
+ rescue
44
+ # if domain could not be parsed as IP we are good
45
+ return user + "@" + domain
46
+ end
47
+ raise ArgumentError.new('domain must not be an IP')
48
+ rescue Exception => e
49
+ raise ArgumentError, 'Not a valid email adress: ' + e.message
50
+ end
51
+ end
52
+
31
53
  # Returns the HTML to render the Persona login form.
32
54
  # Optionally takes a URL parameter for where the user should
33
55
  # be redirected to after the assert POST back.
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.0
4
+ version: 1.5.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-09-05 00:00:00.000000000 Z
12
+ date: 2018-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: 0.2.2
56
+ - !ruby/object:Gem::Dependency
57
+ name: simpleidn
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 0.0.9
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.0.9
56
70
  description:
57
71
  email:
58
72
  - malte@paskuda.biz
@@ -88,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
102
  version: '0'
89
103
  requirements: []
90
104
  rubyforge_project:
91
- rubygems_version: 2.6.13
105
+ rubygems_version: 2.6.14
92
106
  signing_key:
93
107
  specification_version: 4
94
108
  summary: Sinatra extension for user authentication with portier