Skip to content

Commit 41ac445

Browse files
refactor!: Rename the 'require_expiracy' option to 'require_expiry'
1 parent 5fbf3c5 commit 41ac445

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ keyfile: path to asymetrical keyfile
3333
#algorithm: HS512
3434
# Allow registration of new users using these tokens, defaults to false
3535
#allow_registration: false
36-
# Require tokens to have an expiracy set, defaults to true
37-
#require_expiracy: true
36+
# Require tokens to have an expiry set, defaults to true
37+
#require_expiry: true
3838
```
39-
It is recommended to have `require_expiracy` set to `true` (default). As for `allow_registration`, it depends on usecase: If you only want to be able to log in *existing* users, leave it at `false` (default). If nonexistant users should be simply registered upon hitting the login endpoint, set it to `true`.
39+
It is recommended to have `require_expiry` set to `true` (default). As for `allow_registration`, it depends on usecase: If you only want to be able to log in *existing* users, leave it at `false` (default). If nonexistant users should be simply registered upon hitting the login endpoint, set it to `true`.
4040

4141
## Usage
4242
First you have to generate a JWT with the correct claims. The `sub` claim is the localpart or full mxid of the user you want to log in as. Be sure that the algorithm and secret match those of the configuration. An example of the claims is as follows:

synapse_token_authenticator/token_authenticator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def check_auth(
7171
token = login_dict["token"]
7272

7373
check_claims = {}
74-
if self.config.require_expiracy:
74+
if self.config.require_expiry:
7575
check_claims["exp"] = None
7676
try:
7777
# OK, let's verify the token
@@ -177,5 +177,5 @@ class _TokenAuthenticatorConfig(object):
177177
raise Exception("Unknown algorithm " + _config.algorithm)
178178

179179
_config.allow_registration = config.get("allow_registration", False)
180-
_config.require_expiracy = config.get("require_expiracy", True)
180+
_config.require_expiry = config.get("require_expiry", True)
181181
return _config

tests/test_simple.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,19 @@ async def test_token_expired(self):
6161
)
6262
self.assertEqual(result, None)
6363

64-
async def test_token_no_expiracy(self):
64+
async def test_token_no_expiry(self):
6565
auth_provider = get_auth_provider()
6666
token = get_token("alice", exp_in=-1)
6767
result = await auth_provider.check_auth(
6868
"alice", "com.famedly.login.token", {"token": token}
6969
)
7070
self.assertEqual(result, None)
7171

72-
async def test_token_no_expiracy_with_config(self):
72+
async def test_token_no_expiry_with_config(self):
7373
auth_provider = get_auth_provider(
7474
config={
7575
"secret": "foxies",
76-
"require_expiracy": False,
76+
"require_expiry": False,
7777
}
7878
)
7979
token = get_token("alice", exp_in=-1)

0 commit comments

Comments
 (0)