knock 1.4.2 → 1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/app/controllers/knock/application_controller.rb +1 -1
- data/app/controllers/knock/auth_token_controller.rb +32 -7
- data/app/model/knock/auth_token.rb +31 -7
- data/lib/generators/knock/token_controller_generator.rb +25 -0
- data/lib/generators/templates/entity_token_controller.rb.erb +2 -0
- data/lib/generators/templates/knock.rb +25 -3
- data/lib/knock.rb +7 -0
- data/lib/knock/authenticable.rb +45 -6
- data/lib/knock/version.rb +1 -1
- data/test/controllers/knock/auth_token_controller_test.rb +11 -0
- data/test/dummy/app/controllers/admin_protected_controller.rb +7 -0
- data/test/dummy/app/controllers/admin_token_controller.rb +2 -0
- data/test/dummy/app/controllers/composite_name_entity_protected_controller.rb +7 -0
- data/test/dummy/app/controllers/vendor_protected_controller.rb +11 -0
- data/test/dummy/app/controllers/vendor_token_controller.rb +2 -0
- data/test/dummy/app/models/admin.rb +16 -0
- data/test/dummy/app/models/composite_name_entity.rb +3 -0
- data/test/dummy/app/models/vendor.rb +3 -0
- data/test/dummy/config/initializers/knock.rb +10 -0
- data/test/dummy/config/routes.rb +8 -0
- data/test/dummy/db/migrate/20160519075733_create_admins.rb +10 -0
- data/test/dummy/db/migrate/20160522051816_create_vendors.rb +10 -0
- data/test/dummy/db/migrate/20160522181712_create_composite_name_entities.rb +10 -0
- data/test/dummy/db/schema.rb +22 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +333 -91
- data/test/dummy/test/controllers/admin_protected_controller_test.rb +49 -0
- data/test/dummy/test/controllers/admin_token_controller_test.rb +22 -0
- data/test/dummy/test/controllers/composite_name_entity_protected_controller_test.rb +49 -0
- data/test/dummy/test/controllers/vendor_protected_controller_test.rb +55 -0
- data/test/dummy/test/controllers/vendor_token_controller_test.rb +22 -0
- data/test/dummy/test/models/admin_test.rb +7 -0
- data/test/dummy/test/models/vendor_test.rb +7 -0
- data/test/{dummy/test/fixtures/users.yml → fixtures/admins.yml} +1 -5
- data/test/fixtures/composite_name_entities.yml +5 -0
- data/test/fixtures/vendors.yml +5 -0
- data/test/generators/token_controller_generator_test.rb +31 -0
- data/test/model/knock/auth_token_test.rb +33 -9
- data/test/support/generators_test_helper.rb +9 -0
- data/test/test_helper.rb +9 -0
- data/test/tmp/app/controllers/admin_token_controller.rb +2 -0
- data/test/tmp/app/controllers/admin_user_token_controller.rb +2 -0
- data/test/tmp/app/controllers/user_admin_token_controller.rb +2 -0
- data/test/tmp/app/controllers/user_token_controller.rb +2 -0
- data/test/tmp/config/routes.rb +17 -0
- metadata +76 -6
- data/test/tmp/config/initializers/knock.rb +0 -86
@@ -1,86 +0,0 @@
|
|
1
|
-
Knock.setup do |config|
|
2
|
-
|
3
|
-
## User handle attribute
|
4
|
-
## ---------------------
|
5
|
-
##
|
6
|
-
## The attribute used to uniquely identify a user.
|
7
|
-
##
|
8
|
-
## Default:
|
9
|
-
# config.handle_attr = :email
|
10
|
-
|
11
|
-
## Current user retrieval from handle when signing in
|
12
|
-
## --------------------------------------------------
|
13
|
-
##
|
14
|
-
## This is where you can configure how to retrieve the current user when
|
15
|
-
## signing in.
|
16
|
-
##
|
17
|
-
## Knock uses the `handle_attr` variable to retrieve the handle from the
|
18
|
-
## AuthTokenController parameters. It also uses the same variable to enforce
|
19
|
-
## permitted values in the controller.
|
20
|
-
##
|
21
|
-
## You must raise ActiveRecord::RecordNotFound if the resource cannot be retrieved.
|
22
|
-
##
|
23
|
-
## Default:
|
24
|
-
# config.current_user_from_handle = -> (handle) { User.find_by! Knock.handle_attr => handle }
|
25
|
-
|
26
|
-
## Current user retrieval when validating token
|
27
|
-
## --------------------------------------------
|
28
|
-
##
|
29
|
-
## This is how you can tell Knock how to retrieve the current_user.
|
30
|
-
## By default, it assumes you have a model called `User` and that
|
31
|
-
## the user_id is stored in the 'sub' claim.
|
32
|
-
##
|
33
|
-
## You must raise ActiveRecord::RecordNotFound if the resource cannot be retrieved.
|
34
|
-
##
|
35
|
-
## Default:
|
36
|
-
# config.current_user_from_token = -> (claims) { User.find claims['sub'] }
|
37
|
-
|
38
|
-
|
39
|
-
## Expiration claim
|
40
|
-
## ----------------
|
41
|
-
##
|
42
|
-
## How long before a token is expired.
|
43
|
-
##
|
44
|
-
## Default:
|
45
|
-
# config.token_lifetime = 1.day
|
46
|
-
|
47
|
-
|
48
|
-
## Audience claim
|
49
|
-
## --------------
|
50
|
-
##
|
51
|
-
## Configure the audience claim to identify the recipients that the token
|
52
|
-
## is intended for.
|
53
|
-
##
|
54
|
-
## Default:
|
55
|
-
# config.token_audience = nil
|
56
|
-
|
57
|
-
## If using Auth0, uncomment the line below
|
58
|
-
# config.token_audience = -> { Rails.application.secrets.auth0_client_id }
|
59
|
-
|
60
|
-
## Signature algorithm
|
61
|
-
## -------------------
|
62
|
-
##
|
63
|
-
## Configure the algorithm used to encode the token
|
64
|
-
##
|
65
|
-
## Default:
|
66
|
-
# config.token_signature_algorithm = 'HS256'
|
67
|
-
|
68
|
-
## Signature key
|
69
|
-
## -------------
|
70
|
-
##
|
71
|
-
## Configure the key used to sign tokens.
|
72
|
-
##
|
73
|
-
## Default:
|
74
|
-
# config.token_secret_signature_key = -> { Rails.application.secrets.secret_key_base }
|
75
|
-
|
76
|
-
## If using Auth0, uncomment the line below
|
77
|
-
# config.token_secret_signature_key = -> { JWT.base64url_decode Rails.application.secrets.auth0_client_secret }
|
78
|
-
|
79
|
-
## Public key
|
80
|
-
## ----------
|
81
|
-
##
|
82
|
-
## Configure the public key used to decode tokens, if required.
|
83
|
-
##
|
84
|
-
## Default:
|
85
|
-
# config.token_public_key = nil
|
86
|
-
end
|