keratin-authn 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -9
- data/lib/keratin/authn/mock_keychain.rb +13 -2
- data/lib/keratin/authn/test/helpers.rb +1 -8
- 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: 6da81c6e1e1cfff24bdf967c5c639bf965a6bd36
|
4
|
+
data.tar.gz: 16b387f8a34beb746cd96c5bcecbc6a0e2df3578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04788a20f670dd537bc463b1d818b7b39626c6745750f3ea3e70b481b8f04f1b3e6215c064165face2508e0d40a967c5ed98507807cb05cff98d20e9d5781f58
|
7
|
+
data.tar.gz: b7c68b8969f1bbbc3f4b00df843245c66ef4620a42c748082bb5a6c8edcd8ff18094dc942bd78a3f5a308f24887c0d91b508f8d1127ee39d87e6c2381be7db92
|
data/README.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
Keratin AuthN is an authentication service that keeps you in control of the experience without forcing you to be an expert in web security.
|
4
4
|
|
5
|
-
This gem provides utilities to help integrate with a Ruby application. You
|
5
|
+
This gem provides utilities to help integrate with the backend of a Ruby application. You will also
|
6
|
+
need a client for your frontend, such as [keratin/authn-js](https://github.com/keratin/authn-js).
|
6
7
|
|
7
8
|
[![Gem Version](https://badge.fury.io/rb/keratin-authn.svg)](http://badge.fury.io/rb/keratin-authn) [![Build Status](https://travis-ci.org/keratin/authn-rb.svg?branch=master)](https://travis-ci.org/keratin/authn-rb) [![Coverage Status](https://coveralls.io/repos/github/keratin/authn/badge.svg?branch=master)](https://coveralls.io/github/keratin/authn?branch=master)
|
8
9
|
|
@@ -20,21 +21,27 @@ Configure your integration from a file such as `config/initializers/keratin.rb`:
|
|
20
21
|
|
21
22
|
```ruby
|
22
23
|
Keratin::AuthN.config.tap do |config|
|
23
|
-
# The
|
24
|
+
# The AUTHN_URL of your Keratin AuthN server. This will be used to verify tokens created by AuthN,
|
25
|
+
# and will also be used for API calls unless `config.authn_url` is also set (see below).
|
24
26
|
config.issuer = 'https://authn.myapp.com'
|
25
27
|
|
26
|
-
# The domain of your application (no protocol)
|
28
|
+
# The domain of your application (no protocol). This domain should be listed in the APP_DOMAINS of
|
29
|
+
# your Keratin AuthN server.
|
27
30
|
config.audience = 'myapp.com'
|
28
31
|
|
29
|
-
#
|
32
|
+
# Credentials for AuthN's private endpoints. These will be used to execute admin actions using the
|
33
|
+
# `Keratin.authn` client provided by this library.
|
34
|
+
#
|
35
|
+
# TIP: make them extra secure in production!
|
30
36
|
config.username = 'secret'
|
31
37
|
config.password = 'secret'
|
32
38
|
|
33
39
|
# OPTIONAL: enables debugging for the JWT verification process
|
34
|
-
config.logger = Rails.logger
|
40
|
+
# config.logger = Rails.logger
|
35
41
|
|
36
|
-
# OPTIONAL:
|
37
|
-
|
42
|
+
# OPTIONAL: Send private API calls to AuthN using private network routing. This can be necessary
|
43
|
+
# if your environment has a firewall to limit public endpoints.
|
44
|
+
# config.authn_url = 'https://authn.internal.dns/
|
38
45
|
end
|
39
46
|
```
|
40
47
|
|
@@ -144,8 +151,8 @@ In your `test/test_helper.rb` or equivalent:
|
|
144
151
|
|
145
152
|
```ruby
|
146
153
|
# Configuring AuthN to use the MockKeychain will stop your tests from attempting to connect to the
|
147
|
-
# remote issuer during tests.
|
148
|
-
Keratin::AuthN.
|
154
|
+
# remote issuer during tests. The MockKeychain creates a single weak key, for speedy tests.
|
155
|
+
Keratin::AuthN.keychain = Keratin::AuthN::MockKeychain.new
|
149
156
|
|
150
157
|
# Including the Test::Helpers module grants access to `id_token_for(user.account_id)`, so that you
|
151
158
|
# can test your system with real tokens.
|
@@ -1,7 +1,18 @@
|
|
1
1
|
module Keratin::AuthN
|
2
2
|
class MockKeychain
|
3
|
-
|
4
|
-
|
3
|
+
# a temporary RSA key for the test suite.
|
4
|
+
#
|
5
|
+
# generates the smallest (fastest) key possible for RS256
|
6
|
+
def initialize
|
7
|
+
@keypair ||= OpenSSL::PKey::RSA.new(512).to_jwk
|
8
|
+
end
|
9
|
+
|
10
|
+
def key
|
11
|
+
@keypair
|
12
|
+
end
|
13
|
+
|
14
|
+
def [](_)
|
15
|
+
key
|
5
16
|
end
|
6
17
|
end
|
7
18
|
end
|
@@ -10,14 +10,7 @@ module Keratin::AuthN::Test
|
|
10
10
|
sub: subject,
|
11
11
|
iat: 10.seconds.ago,
|
12
12
|
exp: 1.hour.from_now
|
13
|
-
).sign(
|
14
|
-
end
|
15
|
-
|
16
|
-
# a temporary RSA key for the test suite.
|
17
|
-
#
|
18
|
-
# generates the smallest (fastest) key possible for RS256
|
19
|
-
private def jws_keypair
|
20
|
-
@keypair ||= OpenSSL::PKey::RSA.new(512)
|
13
|
+
).sign(Keratin::AuthN.keychain.key, JWS_ALGORITHM).to_s
|
21
14
|
end
|
22
15
|
end
|
23
16
|
end
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
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-12-
|
11
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-jwt
|