Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
0aba3d36
Commit
0aba3d36
authored
6 years ago
by
Neil Johnson
Browse files
Options
Downloads
Patches
Plain Diff
count_monthly_users() async
parent
2c54f1c2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/handlers/auth.py
+7
-4
7 additions, 4 deletions
synapse/handlers/auth.py
with
7 additions
and
4 deletions
synapse/handlers/auth.py
+
7
−
4
View file @
0aba3d36
...
...
@@ -519,7 +519,7 @@ class AuthHandler(BaseHandler):
"""
logger
.
info
(
"
Logging in user %s on device %s
"
,
user_id
,
device_id
)
access_token
=
yield
self
.
issue_access_token
(
user_id
,
device_id
)
self
.
_check_mau_limits
()
yield
self
.
_check_mau_limits
()
# the device *should* have been registered before we got here; however,
# it's possible we raced against a DELETE operation. The thing we
...
...
@@ -729,16 +729,18 @@ class AuthHandler(BaseHandler):
device_id
)
defer
.
returnValue
(
access_token
)
@defer.inlineCallbacks
def
validate_short_term_login_token_and_get_user_id
(
self
,
login_token
):
self
.
_check_mau_limits
()
yield
self
.
_check_mau_limits
()
auth_api
=
self
.
hs
.
get_auth
()
user_id
=
None
try
:
macaroon
=
pymacaroons
.
Macaroon
.
deserialize
(
login_token
)
user_id
=
auth_api
.
get_user_id_from_macaroon
(
macaroon
)
auth_api
.
validate_macaroon
(
macaroon
,
"
login
"
,
True
,
user_id
)
return
user_id
except
Exception
:
raise
AuthError
(
403
,
"
Invalid token
"
,
errcode
=
Codes
.
FORBIDDEN
)
defer
.
returnValue
(
user_id
)
@defer.inlineCallbacks
def
delete_access_token
(
self
,
access_token
):
...
...
@@ -894,13 +896,14 @@ class AuthHandler(BaseHandler):
else
:
return
defer
.
succeed
(
False
)
@defer.inlineCallbacks
def
_check_mau_limits
(
self
):
"""
Ensure that if mau blocking is enabled that invalid users cannot
log in.
"""
if
self
.
hs
.
config
.
limit_usage_by_mau
is
True
:
current_mau
=
self
.
store
.
count_monthly_users
()
current_mau
=
yield
self
.
store
.
count_monthly_users
()
if
current_mau
>=
self
.
hs
.
config
.
max_mau_value
:
raise
AuthError
(
403
,
"
MAU Limit Exceeded
"
,
errcode
=
Codes
.
MAU_LIMIT_EXCEEDED
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment