Skip to content

Commit

Permalink
Allow /branch/{dbname} in extension routes (#6979)
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttrinh authored and msullivan committed Mar 7, 2024
1 parent aad4f37 commit 194f5e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions edb/server/protocol/protocol.pyx
Expand Up @@ -496,7 +496,7 @@ cdef class HttpProtocol:
path_parts_len = len(path_parts)
route = path_parts[0]

if self.tenant is None and route in ['db', 'auth']:
if self.tenant is None and route in ['db', 'auth', 'branch']:
self.tenant = self.server.get_default_tenant()
self.check_readiness()
if self.tenant.is_accepting_connections():
Expand All @@ -510,7 +510,7 @@ cdef class HttpProtocol:
b'The server is closing.',
)

if route == 'db':
if route in ['db', 'branch']:
if path_parts_len < 2:
return self._not_found(request, response)

Expand Down Expand Up @@ -635,7 +635,7 @@ cdef class HttpProtocol:
else request_url.host.decode()
)
extension_base_path = f"{request_url.schema.decode()}://" \
f"{netloc}/db/{dbname}/ext/auth"
f"{netloc}/{route}/{dbname}/ext/auth"
handler = auth_ext.http.Router(
db=db,
base_path=extension_base_path,
Expand Down Expand Up @@ -738,7 +738,7 @@ cdef class HttpProtocol:
bint allow_credentials = False
):
db = self.tenant.maybe_get_db(dbname=dbname) if dbname else None

config = None
if db is not None:
if db.db_config is None:
Expand Down Expand Up @@ -774,7 +774,7 @@ cdef class HttpProtocol:
if allow_credentials:
response.custom_headers['Access-Control-Allow-Credentials'] = (
'true')

return True

return False
Expand Down
2 changes: 1 addition & 1 deletion edb/testbase/http.py
Expand Up @@ -44,7 +44,7 @@ def get_extension_path(cls):
def get_api_prefix(cls):
extpath = cls.get_extension_path()
dbname = cls.get_database_name()
return f'/db/{dbname}/{extpath}'
return f'/branch/{dbname}/{extpath}'

@classmethod
def tearDownClass(cls):
Expand Down

0 comments on commit 194f5e4

Please sign in to comment.