Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CMS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MO-P
CMS
Commits
8cdeecf0
Commit
8cdeecf0
authored
10 months ago
by
CMS
Browse files
Options
Downloads
Patches
Plain Diff
A hack for subnet-based authentication
parent
bc8a0700
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cms/server/contest/authentication.py
+7
-1
7 additions, 1 deletion
cms/server/contest/authentication.py
with
7 additions
and
1 deletion
cms/server/contest/authentication.py
+
7
−
1
View file @
8cdeecf0
...
@@ -30,6 +30,7 @@ import json
...
@@ -30,6 +30,7 @@ import json
import
logging
import
logging
from
datetime
import
timedelta
from
datetime
import
timedelta
from
sqlalchemy
import
or_
from
sqlalchemy.orm
import
contains_eager
,
joinedload
from
sqlalchemy.orm
import
contains_eager
,
joinedload
from
cms
import
config
from
cms
import
config
...
@@ -247,10 +248,15 @@ def _authenticate_request_by_ip_address(sql_session, contest, ip_address):
...
@@ -247,10 +248,15 @@ def _authenticate_request_by_ip_address(sql_session, contest, ip_address):
# since we're comparing it for equality with other networks.
# since we're comparing it for equality with other networks.
ip_network
=
ipaddress
.
ip_network
((
ip_address
,
ip_address
.
max_prefixlen
))
ip_network
=
ipaddress
.
ip_network
((
ip_address
,
ip_address
.
max_prefixlen
))
# FIXME: Subnet-based login for VPN users with dynamically allocated addresses
# Currently special-cased to /24.
ip_subnet
=
ipaddress
.
ip_network
((
ip_address
,
24
),
strict
=
False
)
participations
=
sql_session
.
query
(
Participation
)
\
participations
=
sql_session
.
query
(
Participation
)
\
.
options
(
joinedload
(
Participation
.
user
))
\
.
options
(
joinedload
(
Participation
.
user
))
\
.
filter
(
Participation
.
contest
==
contest
)
\
.
filter
(
Participation
.
contest
==
contest
)
\
.
filter
(
Participation
.
ip
.
any
(
ip_network
))
.
filter
(
or_
(
Participation
.
ip
.
any
(
ip_network
),
Participation
.
ip
.
any
(
ip_subnet
)))
# If hidden users are blocked we ignore them completely.
# If hidden users are blocked we ignore them completely.
if
contest
.
block_hidden_participations
:
if
contest
.
block_hidden_participations
:
...
...
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