Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
authserv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ai
authserv
Commits
023dd3b7
Commit
023dd3b7
authored
10 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
resolve shard names to IPs
parent
a31232ac
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
authserv/app_nginx.py
+13
-1
13 additions, 1 deletion
authserv/app_nginx.py
with
13 additions
and
1 deletion
authserv/app_nginx.py
+
13
−
1
View file @
023dd3b7
import
socket
import
threading
from
flask
import
Flask
,
request
,
abort
,
make_response
from
flask
import
Flask
,
request
,
abort
,
make_response
from
authserv.app_common
import
do_auth
from
authserv.app_common
import
do_auth
...
@@ -5,6 +7,16 @@ app = Flask(__name__)
...
@@ -5,6 +7,16 @@ app = Flask(__name__)
_default_port_map
=
{
'
imap
'
:
143
,
'
pop3
'
:
110
}
_default_port_map
=
{
'
imap
'
:
143
,
'
pop3
'
:
110
}
_dns_cache
=
{}
_dns_cache_lock
=
threading
.
Lock
()
def
_shard_to_ip
(
shard
):
hostname
=
'
%s-vpn
'
%
shard
with
_dns_cache_lock
:
if
hostname
not
in
_dns_cache
:
_dns_cache
[
hostname
]
=
socket
.
gethostbyname
(
hostname
)
return
_dns_cache
[
hostname
]
@app.route
(
'
/
'
,
methods
=
(
'
GET
'
,))
@app.route
(
'
/
'
,
methods
=
(
'
GET
'
,))
def
do_nginx_http_auth
():
def
do_nginx_http_auth
():
...
@@ -32,7 +44,7 @@ def do_nginx_http_auth():
...
@@ -32,7 +44,7 @@ def do_nginx_http_auth():
response
=
make_response
(
''
)
response
=
make_response
(
''
)
if
auth_status
==
'
OK
'
:
if
auth_status
==
'
OK
'
:
response
.
headers
[
'
Auth-Status
'
]
=
'
OK
'
response
.
headers
[
'
Auth-Status
'
]
=
'
OK
'
response
.
headers
[
'
Auth-Server
'
]
=
shard
response
.
headers
[
'
Auth-Server
'
]
=
_
shard
_to_ip
(
shard
)
response
.
headers
[
'
Auth-Port
'
]
=
str
(
response
.
headers
[
'
Auth-Port
'
]
=
str
(
app
.
config
.
get
(
'
NGINX_AUTH_PORT_MAP
'
,
_default_port_map
)[
protocol
])
app
.
config
.
get
(
'
NGINX_AUTH_PORT_MAP
'
,
_default_port_map
)[
protocol
])
else
:
else
:
...
...
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