This repository has been archived by the owner on Mar 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 256
/
knock.rb
86 lines (74 loc) · 2.38 KB
/
knock.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Knock.setup do |config|
## User handle attribute
## ---------------------
##
## The attribute used to uniquely identify a user.
##
## Default:
# config.handle_attr = :email
## Current user retrieval from handle when signing in
## --------------------------------------------------
##
## This is where you can configure how to retrieve the current user when
## signing in.
##
## Knock uses the `handle_attr` variable to retrieve the handle from the
## AuthTokenController parameters. It also uses the same variable to enforce
## permitted values in the controller.
##
## You must raise ActiveRecord::RecordNotFound if the resource cannot be retrieved.
##
## Default:
# config.current_user_from_handle = -> (handle) { User.find_by! Knock.handle_attr => handle }
## Current user retrieval when validating token
## --------------------------------------------
##
## This is how you can tell Knock how to retrieve the current_user.
## By default, it assumes you have a model called `User` and that
## the user_id is stored in the 'sub' claim.
##
## You must raise ActiveRecord::RecordNotFound if the resource cannot be retrieved.
##
## Default:
# config.current_user_from_token = -> (claims) { User.find claims['sub'] }
## Expiration claim
## ----------------
##
## How long before a token is expired.
##
## Default:
# config.token_lifetime = 1.day
## Audience claim
## --------------
##
## Configure the audience claim to identify the recipients that the token
## is intended for.
##
## Default:
# config.token_audience = nil
## If using Auth0, uncomment the line below
# config.token_audience = -> { Rails.application.secrets.auth0_client_id }
## Signature algorithm
## -------------------
##
## Configure the algorithm used to encode the token
##
## Default:
# config.token_signature_algorithm = 'HS256'
## Signature key
## -------------
##
## Configure the key used to sign tokens.
##
## Default:
# config.token_secret_signature_key = -> { Rails.application.secrets.secret_key_base }
## If using Auth0, uncomment the line below
# config.token_secret_signature_key = -> { JWT.base64url_decode Rails.application.secrets.auth0_client_secret }
## Public key
## ----------
##
## Configure the public key used to decode tokens, if required.
##
## Default:
# config.token_public_key = nil
end