keratin-authn 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -1
- data/lib/keratin/authn.rb +2 -2
- data/lib/keratin/authn/id_token_verifier.rb +3 -2
- data/lib/keratin/authn/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad2249f2cb34275c7f28c5f0bb163f62a2c7140e
|
4
|
+
data.tar.gz: 74d562ac45f801426514cff133ca41ec5cb33a35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01476b8e1ce1b963665aae57c308fe2035a87ce51b681f2eb5f7143f874965efcd349bb60000692749769fc9884f819670a270f4cac1d9349706810f86f9541c
|
7
|
+
data.tar.gz: 0532c690abb32c73675a60ab6418d831d7360378ecb690c585bbe0e373d03f3ca53ce75160beea130130b69347e387d2197ffdba9d62639ff63fb656bd6485bf
|
data/README.md
CHANGED
@@ -109,6 +109,25 @@ class SessionsController
|
|
109
109
|
end
|
110
110
|
```
|
111
111
|
|
112
|
+
### Example: Multiple Domains
|
113
|
+
|
114
|
+
When working with multiple frontend domains it may be beneficial to use a referrer header as your audience instead of a static configuration. You can do this by providing an additional parameter to the `subject_from` method.
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
class ApplicationController
|
118
|
+
private
|
119
|
+
|
120
|
+
def current_user
|
121
|
+
return @current_user if defined? @current_user
|
122
|
+
@current_user = User.find_by_account_id(current_account_id)
|
123
|
+
end
|
124
|
+
|
125
|
+
def current_account_id
|
126
|
+
Keratin::AuthN.subject_from(cookies[:authn], audience: URI.parse(request.referer).host)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
```
|
130
|
+
|
112
131
|
## Testing Your App
|
113
132
|
|
114
133
|
AuthN provides helpers for working with tokens in your application's controller and integration tests.
|
@@ -138,4 +157,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
138
157
|
## Contributing
|
139
158
|
|
140
159
|
Bug reports and pull requests are welcome on GitHub at https://github.com/keratin/authn-rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
141
|
-
|
data/lib/keratin/authn.rb
CHANGED
@@ -73,8 +73,8 @@ module Keratin
|
|
73
73
|
class << self
|
74
74
|
# safely fetches a subject from the id token after checking relevant claims and
|
75
75
|
# verifying the signature.
|
76
|
-
def subject_from(id_token)
|
77
|
-
verifier = IDTokenVerifier.new(id_token, signature_verifier)
|
76
|
+
def subject_from(id_token, audience: Keratin::AuthN.config.audience)
|
77
|
+
verifier = IDTokenVerifier.new(id_token, signature_verifier, audience)
|
78
78
|
verifier.subject if verifier.verified?
|
79
79
|
end
|
80
80
|
|
@@ -2,9 +2,10 @@ require 'uri'
|
|
2
2
|
|
3
3
|
module Keratin::AuthN
|
4
4
|
class IDTokenVerifier
|
5
|
-
def initialize(str, signature_verifier)
|
5
|
+
def initialize(str, signature_verifier, audience)
|
6
6
|
@id_token = str
|
7
7
|
@signature_verifier = signature_verifier
|
8
|
+
@audience = audience
|
8
9
|
@time = Time.now.to_i
|
9
10
|
end
|
10
11
|
|
@@ -42,7 +43,7 @@ module Keratin::AuthN
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def token_for_us?
|
45
|
-
jwt[:aud] ==
|
46
|
+
jwt[:aud] == @audience
|
46
47
|
end
|
47
48
|
|
48
49
|
def token_fresh?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keratin-authn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lance Ivy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-jwt
|