browserid-provider 0.5.1 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
5
  <script type="text/javascript" src="https://<%= @vars[:browserid_url] %>/provisioning_api.js"></script>
6
- <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
6
+ <script type="text/javascript" src="<%= @vars[:jquery_path] %>"></script>
7
7
  <script type="text/javascript">
8
8
  // an alias
9
9
  var fail = navigator.id.raiseProvisioningFailure;
@@ -9,6 +9,8 @@ module BrowserID
9
9
  # defaults to: "/browserid/certify"
10
10
  # whoami_path What HTTP path to serve user credentials at
11
11
  # defaults to: "/browserid/whoami"
12
+ # jquery_path What HTTP path JQuery is served at
13
+ # defaults to: "/assets/jquery.js"
12
14
  #
13
15
  # whoami Name of the middleware to get the current user object from (:user must respond to :email method)
14
16
  # This middleware will be called as follows: env['warden'].user.email
@@ -20,9 +22,9 @@ module BrowserID
20
22
  # The "/.well-known/browserid" path is required from the BrowserID spec and used here.
21
23
  #
22
24
  # browserid_url Which BrowserID server to use, ca be one of the following:
23
- # * dev.diresworb.org for development (default)
24
- # * diresworb.org for beta
25
- # * browserid.org for production
25
+ # * login.dev.anosrep.org for development (default)
26
+ # * login.anosrep.org for beta
27
+ # * browserid.org for production
26
28
  #
27
29
  # server_name The domain name we are providing BrowserID for (default to example.org)
28
30
  #
@@ -66,9 +68,10 @@ module BrowserID
66
68
  self[:provision_path] ||= "/browserid/provision"
67
69
  self[:certify_path] ||= "/browserid/certify"
68
70
  self[:whoami_path] ||= "/browserid/whoami"
71
+ self[:jquery_path] ||= "/assets/jquery.js"
69
72
  self[:whoami] ||= "warden"
70
73
  self[:private_key_path] ||= "config/browserid_provider.pem"
71
- self[:browserid_url] ||= "dev.diresworb.org"
74
+ self[:browserid_url] ||= "login.dev.anosrep.org"
72
75
  self[:server_name] ||= "example.org"
73
76
  self[:delegates] ||= []
74
77
  end
@@ -72,15 +72,25 @@ module BrowserID
72
72
  return err "Missing a required parameter (duration, pubkey)" if params.keys.sort != ["duration", "pubkey"]
73
73
 
74
74
  expiration = (Time.now.strftime("%s").to_i + params["duration"].to_i) * 1000
75
- issue = { "iss" => issuer(email),
76
- "exp" => expiration,
77
- "public-key" => params["pubkey"],
78
- "principal" => { "email"=> email }
75
+
76
+ # Old certificate structure, changed to fit with https://github.com/mozilla/browserid-certifier/blob/master/bin/certifier#L51
77
+ # issue = {
78
+ # "principal" => { "email"=> email }
79
+ # "hostname" => issuer(email),
80
+ # "exp" => expiration,
81
+ # "public-key" => params["pubkey"],
82
+ # }
83
+ issue = {
84
+ "email"=> email,
85
+ "pubkey" => params["pubkey"],
86
+ "duration" => expiration,
87
+ "hostname" => issuer(email)
79
88
  }
89
+
80
90
  jwt = JSON::JWT.new(issue)
81
91
  jws = jwt.sign(@identity.private_key, :RS256)
82
92
 
83
- return [ 200, {"Content-Type" => "application/json"}, [{ "cert" => jws.to_s }.to_json] ]
93
+ return [ 200, {"Content-Type" => "application/json"}, [{"success" => true, "cert" => jws.to_s }.to_json] ]
84
94
  end
85
95
 
86
96
  # Something went wrong.
@@ -1,3 +1,3 @@
1
1
  module BrowserID
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -10,7 +10,23 @@ module BrowserId
10
10
 
11
11
  # JavaScript enable BrowserID authentication for the form with the given #id
12
12
  def enable_browserid_javascript_tag(id)
13
- raw "<script type='text/javascript'>$('form##{id}').bind('ajax:success', function(data, status, xhr) { navigator.id.completeAuthentication() })</script>"
13
+ raw <<EOF
14
+ <script type='text/javascript'>
15
+ (function() {
16
+ function fail() {
17
+ var msg = 'user is not authenticated as target user';
18
+ navigator.id.raiseAuthenticationFailure(msg);
19
+ };
20
+
21
+ $('form##{id}').bind('ajax:success', function(data, status, xhr) { navigator.id.completeAuthentication() })
22
+ $('form##{id}').bind('ajax:error', function(data, status, xhr) { fail(); })
23
+
24
+ navigator.id.beginAuthentication(function(email) {
25
+ $('form##{id} #user_email').val(email);
26
+ });
27
+ }());
28
+ </script>
29
+ EOF
14
30
  end
15
31
 
16
32
  # The URL to the BrowserID official JavaScript
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browserid-provider
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-21 00:00:00.000000000 Z
12
+ date: 2012-07-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json-jwt
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 1.8.22
125
+ rubygems_version: 1.8.23
126
126
  signing_key:
127
127
  specification_version: 3
128
128
  summary: Rails-enabled, Rack-based Mozilla BrowserID Primary Identity Provider