knock 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzVhZjdkMGZhZTMxMWVmYTU1MTRiMTU1OWM4ZTdhZTAyYmEzZWZiNw==
4
+ Y2JmMzAwNjRhMDNiZTQ4ZWQwYzRjNDlhNzhjMzA1YzZmY2QzMTY2Yw==
5
5
  data.tar.gz: !binary |-
6
- YWYwZTAzM2EwY2MxMzU4Nzg3N2ZmNzkwY2Y5NzhlOWZiOTFiMzVlMg==
6
+ ZDMyNWRkNDA4NGI3NTk0MDBmNmI4ZGJlZmUzNDgyNTc0MmEyNGNhOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjhlOTdhZTBkNTE0NjQzMjBjYWE4M2JlMDA1YjI3ODgyZjFkYzhhYThjOWQ3
10
- NGQ1ZjllMzBmZjUzZTdmYjRhYTcyYzQ3MDM4YzAxODNlNzkxMzg2MDlkZGVl
11
- ODI4ZTE2N2YwMDE1OWViMGIzOGI0ZDQ5ODU5YzU3ODc1ZTc2NWU=
9
+ YmIwZjc3Njc5NzdjMmMyMGM1NzlhNmY5Y2EyNWNiNzFhZDA2MWJkOWNhNjQ4
10
+ NTZlNWQwOTdlM2ZiZmY5OGZhY2Y3YjVjNDIzYThlZjJkZDcxNThiYmNlMDEw
11
+ MTJiMTllMGVmOTE5MjhiYTlkNTgzYjI2YzIxZGQwZGM1M2ZiNGM=
12
12
  data.tar.gz: !binary |-
13
- MGJjNjQyOWQ3YzA2ZTU0MzY4ZTI3MGFlY2E0ZDdkMjZhNDJjNmI1YTEzMmZi
14
- ZDQ3NDA2NGM2YzA1MTc1M2I4MmI2MThjMzc4MTYzZTQwNzA3MGJkYTJkNWFl
15
- ZjBjZDk3OGRmMWFkNWY5OTA0NWRlYzhmY2EzM2YxMjdmY2I2YzM=
13
+ YjNiMWJmODQwNWI4MThlODBjYzVjNjBjY2ZhODU2YmRiNDNkMGM4NjllM2Q2
14
+ MTQyYjlhYTMwOGM3MzYyMDM1YWQwY2M0NjUwYWUwMTEwNjc5YjkyODVlOTFh
15
+ NDk3ODJkZjU3OTQyZDU2MTY2MzEzOGE5NTA0YTBmMGQzYmU1OGQ=
@@ -38,14 +38,22 @@ module Knock
38
38
  def claims
39
39
  {
40
40
  exp: Knock.token_lifetime.from_now.to_i,
41
- aud: Knock.token_audience
41
+ aud: token_audience
42
42
  }
43
43
  end
44
44
 
45
45
  def verify_claims
46
46
  {
47
- aud: Knock.token_audience, verify_aud: Knock.token_audience.present?
47
+ aud: token_audience, verify_aud: verify_audience?
48
48
  }
49
49
  end
50
+
51
+ def token_audience
52
+ verify_audience? && Knock.token_audience.call
53
+ end
54
+
55
+ def verify_audience?
56
+ Knock.token_audience.present?
57
+ end
50
58
  end
51
59
  end
@@ -1,3 +1,3 @@
1
1
  module Knock
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.1"
3
3
  end
Binary file
@@ -1,36 +1,49 @@
1
-  (4.5ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar NOT NULL, "password_digest" varchar NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
2
-  (1.6ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
1
+  (3.7ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar NOT NULL, "password_digest" varchar NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
2
+  (1.4ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
3
3
   (0.1ms) select sqlite_version(*)
4
-  (1.6ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
4
+  (1.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
5
5
   (0.1ms) SELECT version FROM "schema_migrations"
6
-  (1.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20150713101607')
6
+  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20150713101607')
7
7
  ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
8
8
   (0.1ms) begin transaction
9
9
  Fixture Delete (0.2ms) DELETE FROM "users"
10
- Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$8Yam9pqovA3weu3n/l1Z4eJ7SP/xFw2yESJoXUcpqk89Fqn3mpY7C', '2016-01-02 04:04:33', '2016-01-02 04:04:33', 980190962)
11
- Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$pPSRVhAc5Awe4myXaw6EF.Xn.hJ/mWlUGSUA5UfiGbmm4l6O5QJ9u', '2016-01-02 04:04:33', '2016-01-02 04:04:33', 298486374)
12
-  (1.7ms) commit transaction
10
+ Fixture Insert (0.2ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('one@example.net', '$2a$04$p5uJvjODelWvUMamobUYm.l7v1cL4QMmQQsFmdlQpZWa4xyWD6Zsa', '2016-01-08 12:37:37', '2016-01-08 12:37:37', 980190962)
11
+ Fixture Insert (0.1ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at", "id") VALUES ('two@example.net', '$2a$04$2hM6WVXy88h9vqb31eD4l.6jkUb6ppqstn5w.ixGo9hN3Sb76n5Ei', '2016-01-08 12:37:37', '2016-01-08 12:37:37', 298486374)
12
+  (1.4ms) commit transaction
13
+  (0.0ms) begin transaction
14
+ ---------------------------------------
15
+ KnockTest: test_setup_block_yields_self
16
+ ---------------------------------------
17
+  (0.0ms) rollback transaction
13
18
   (0.1ms) begin transaction
19
+ --------------------------------------------------
20
+ CurrentUsersControllerTest: test_responds_with_200
21
+ --------------------------------------------------
22
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
23
+ Processing by CurrentUsersController#show as HTML
24
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
25
+ Completed 200 OK in 2ms (ActiveRecord: 0.1ms)
26
+  (0.1ms) rollback transaction
27
+  (0.0ms) begin transaction
28
+ ---------------------------------------------------------------------------
29
+ CurrentUsersControllerTest: test_responds_with_404_if_user_is_not_logged_in
30
+ ---------------------------------------------------------------------------
31
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
32
+ Processing by CurrentUsersController#show as HTML
33
+ Completed 404 Not Found in 0ms (ActiveRecord: 0.0ms)
34
+  (0.1ms) rollback transaction
35
+  (0.1ms) begin transaction
14
36
  ------------------------------------------------------
15
37
  Knock::AuthTokenControllerTest: test_responds_with_201
16
38
  ------------------------------------------------------
17
- User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
39
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
18
40
  Processing by Knock::AuthTokenController#create as HTML
19
41
  Parameters: {"auth"=>{"email"=>"one@example.net", "password"=>"[FILTERED]"}}
20
- User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
21
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
22
- Completed 201 Created in 7ms (Views: 0.3ms | ActiveRecord: 0.3ms)
23
-  (0.1ms) rollback transaction
24
-  (0.1ms) begin transaction
25
- -----------------------------------------------------------------------------
26
- Knock::AuthTokenControllerTest: test_responds_with_404_if_user_does_not_exist
27
- -----------------------------------------------------------------------------
28
- Processing by Knock::AuthTokenController#create as HTML
29
- Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
30
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "wrong@example.net"]]
31
- Completed 404 Not Found in 1ms (ActiveRecord: 0.1ms)
42
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
43
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "one@example.net"]]
44
+ Completed 201 Created in 3ms (Views: 0.2ms | ActiveRecord: 0.2ms)
32
45
   (0.1ms) rollback transaction
33
-  (0.1ms) begin transaction
46
+  (0.0ms) begin transaction
34
47
  -----------------------------------------------------------------------------
35
48
  Knock::AuthTokenControllerTest: test_responds_with_404_if_password_is_invalid
36
49
  -----------------------------------------------------------------------------
@@ -41,46 +54,52 @@ Processing by Knock::AuthTokenController#create as HTML
41
54
  Completed 404 Not Found in 2ms (ActiveRecord: 0.1ms)
42
55
   (0.1ms) rollback transaction
43
56
   (0.1ms) begin transaction
44
- -------------------------------------------------------------------------
45
- Knock::AuthTokenTest: test_verify_audience_when_token_audience_is_present
46
- -------------------------------------------------------------------------
47
-  (0.1ms) rollback transaction
48
-  (0.1ms) begin transaction
49
- -------------------------------------------------
50
- Knock::AuthTokenTest: test_encode_tokens_with_RSA
51
- -------------------------------------------------
52
-  (0.1ms) rollback transaction
53
-  (0.1ms) begin transaction
54
- -------------------------------------------
55
- Knock::AuthTokenTest: test_verify_algorithm
56
- -------------------------------------------
57
-  (0.1ms) rollback transaction
58
-  (0.1ms) begin transaction
59
- ----------------------------------------------------
60
- Knock::AuthTokenTest: test_decode_RSA_encoded_tokens
61
- ----------------------------------------------------
62
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
57
+ -----------------------------------------------------------------------------
58
+ Knock::AuthTokenControllerTest: test_responds_with_404_if_user_does_not_exist
59
+ -----------------------------------------------------------------------------
60
+ Processing by Knock::AuthTokenController#create as HTML
61
+ Parameters: {"auth"=>{"email"=>"wrong@example.net", "password"=>"[FILTERED]"}}
62
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT 1 [["email", "wrong@example.net"]]
63
+ Completed 404 Not Found in 1ms (ActiveRecord: 0.1ms)
63
64
   (0.1ms) rollback transaction
64
65
   (0.1ms) begin transaction
65
- -------------------------------------------------------------------------------------------
66
- ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_url
67
- -------------------------------------------------------------------------------------------
66
+ -----------------------------------------------------------------
67
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized
68
+ -----------------------------------------------------------------
68
69
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
69
70
  Processing by ProtectedResourcesController#index as HTML
70
- Parameters: {"token"=>"invalid"}
71
71
  Filter chain halted as :authenticate rendered or redirected
72
72
  Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
73
73
   (0.1ms) rollback transaction
74
-  (0.1ms) begin transaction
75
- -----------------------------------------------------------------
76
- ProtectedResourcesControllerTest: test_responds_with_unauthorized
77
- -----------------------------------------------------------------
74
+  (0.0ms) begin transaction
75
+ ---------------------------------------------------------------------------------------
76
+ ProtectedResourcesControllerTest: test_responds_with_success_with_valid_token_in_header
77
+ ---------------------------------------------------------------------------------------
78
78
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
79
79
  Processing by ProtectedResourcesController#index as HTML
80
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
81
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
82
+  (0.1ms) rollback transaction
83
+  (0.0ms) begin transaction
84
+ -------------------------------------------------------------------------------------------
85
+ ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_url
86
+ -------------------------------------------------------------------------------------------
87
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
88
+ Processing by ProtectedResourcesController#index as HTML
89
+ Parameters: {"token"=>"invalid"}
80
90
  Filter chain halted as :authenticate rendered or redirected
81
91
  Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
82
92
   (0.1ms) rollback transaction
83
-  (0.1ms) begin transaction
93
+  (0.0ms) begin transaction
94
+ ------------------------------------------------------------------------------
95
+ ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
96
+ ------------------------------------------------------------------------------
97
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
98
+ Processing by ProtectedResourcesController#index as HTML
99
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
100
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
101
+  (0.1ms) rollback transaction
102
+  (0.0ms) begin transaction
84
103
  ----------------------------------------------------------------------------------------------
85
104
  ProtectedResourcesControllerTest: test_responds_with_unauthorized_with_invalid_token_in_header
86
105
  ----------------------------------------------------------------------------------------------
@@ -89,58 +108,39 @@ Processing by ProtectedResourcesController#index as HTML
89
108
  Filter chain halted as :authenticate rendered or redirected
90
109
  Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
91
110
   (0.1ms) rollback transaction
92
-  (0.1ms) begin transaction
111
+  (0.0ms) begin transaction
93
112
  ------------------------------------------------------------------------------
94
113
  ProtectedResourcesControllerTest: test_responds_with_success_with_token_in_url
95
114
  ------------------------------------------------------------------------------
96
115
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
97
116
  Processing by ProtectedResourcesController#index as HTML
98
- Parameters: {"token"=>"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NTE3OTM4NzQsImF1ZCI6bnVsbCwic3ViIjo5ODAxOTA5NjJ9.o7HWlffQZN6ss8gZk4Nyl70T8TXpNFoVhr3lBZ5Jvnc"}
99
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
100
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
101
-  (0.1ms) rollback transaction
102
-  (0.1ms) begin transaction
103
- ------------------------------------------------------------------------------
104
- ProtectedResourcesControllerTest: test_has_a_current_user_after_authentication
105
- ------------------------------------------------------------------------------
106
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
107
- Processing by ProtectedResourcesController#index as HTML
108
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
109
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
110
-  (0.1ms) rollback transaction
111
-  (0.1ms) begin transaction
112
- ---------------------------------------------------------------------------------------
113
- ProtectedResourcesControllerTest: test_responds_with_success_with_valid_token_in_header
114
- ---------------------------------------------------------------------------------------
115
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
116
- Processing by ProtectedResourcesController#index as HTML
117
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
118
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
117
+ Parameters: {"token"=>"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NTIzNDMwNTcsImF1ZCI6ZmFsc2UsInN1YiI6OTgwMTkwOTYyfQ._LmEq4p__HN1QJJugtREjx2fhFHfDM64ZZ3DYp8E17k"}
118
+ User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
119
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
119
120
   (0.1ms) rollback transaction
120
121
   (0.1ms) begin transaction
121
- --------------------------------------------------
122
- CurrentUsersControllerTest: test_responds_with_200
123
- --------------------------------------------------
124
- User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
125
- Processing by CurrentUsersController#show as HTML
126
- User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
127
- Completed 200 OK in 1ms (ActiveRecord: 0.1ms)
122
+ ----------------------------------------------------------------
123
+ InstallGeneratorTest: test_Assert_all_files_are_properly_created
124
+ ----------------------------------------------------------------
128
125
   (0.1ms) rollback transaction
129
126
   (0.1ms) begin transaction
130
- ---------------------------------------------------------------------------
131
- CurrentUsersControllerTest: test_responds_with_404_if_user_is_not_logged_in
132
- ---------------------------------------------------------------------------
127
+ ----------------------------------------------------
128
+ Knock::AuthTokenTest: test_decode_RSA_encoded_tokens
129
+ ----------------------------------------------------
133
130
  User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
134
- Processing by CurrentUsersController#show as HTML
135
- Completed 404 Not Found in 0ms (ActiveRecord: 0.0ms)
136
131
   (0.1ms) rollback transaction
137
132
   (0.1ms) begin transaction
138
- ----------------------------------------------------------------
139
- InstallGeneratorTest: test_Assert_all_files_are_properly_created
140
- ----------------------------------------------------------------
133
+ -------------------------------------------------
134
+ Knock::AuthTokenTest: test_encode_tokens_with_RSA
135
+ -------------------------------------------------
141
136
   (0.1ms) rollback transaction
142
137
   (0.1ms) begin transaction
143
- ---------------------------------------
144
- KnockTest: test_setup_block_yields_self
145
- ---------------------------------------
138
+ -------------------------------------------------------------------------
139
+ Knock::AuthTokenTest: test_verify_audience_when_token_audience_is_present
140
+ -------------------------------------------------------------------------
141
+  (0.1ms) rollback transaction
142
+  (0.0ms) begin transaction
143
+ -------------------------------------------
144
+ Knock::AuthTokenTest: test_verify_algorithm
145
+ -------------------------------------------
146
146
   (0.1ms) rollback transaction
@@ -38,7 +38,7 @@ module Knock
38
38
  end
39
39
 
40
40
  test "verify audience when token_audience is present" do
41
- Knock.token_audience = 'bar'
41
+ Knock.token_audience = -> { 'bar' }
42
42
  key = Knock.token_secret_signature_key.call
43
43
 
44
44
  token = JWT.encode({sub: 'foo'}, key, 'HS256')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud MESUREUR
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-02 00:00:00.000000000 Z
12
+ date: 2016-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails