Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow /branch/{dbname} in extension routes #6979

Merged
merged 2 commits into from Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -631,7 +631,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 @@ -734,7 +734,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 @@ -770,7 +770,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