Skip to content

SimpleVM Services 0.1 - Forc#555

Open
milo39 wants to merge 43 commits intodevfrom
feat/auth_switch
Open

SimpleVM Services 0.1 - Forc#555
milo39 wants to merge 43 commits intodevfrom
feat/auth_switch

Conversation

@milo39
Copy link
Member

@milo39 milo39 commented Mar 5, 2026

Most of the logic of the feature happens here.
The important changes are in services/backend.py.

Because I introduced tests I had to refactor many of the existing functions in that file like create_backend.
The function of de/activating the authorization basically deletes previous backends with the same ID and uses create_backend to build a new one, which will keep the same ID and URL.

Ubuntu and others added 30 commits October 31, 2025 13:42
…refactors for readability, changes to upstream_url_regex
…lenames, minor changes in service/backend.py
…ackend and delete_backend functions for improved clarity and robustness.
@milo39 milo39 requested a review from dweinholz March 5, 2026 00:51
Copy link
Contributor

@dweinholz dweinholz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        {% if only_allow_owner %}

This part must be removed from all templates where we want to prevent the deactivation of the authorisation.

Also please change the permissions of the files again

return randint(range_start, range_end)


# TODO: unlikely but potential error cause, if two users have same randomly generated user_key_url!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part should avoid this (which could be refactored into an own method):

backends: List[BackendOut] = await get_backends()
same_name_backend_suffixes: List[int] = []
for backend in backends:
    if backend.location_url == location_url:
        suffix: int = int(backend.location_url.split("_")[1])
        same_name_backend_suffixes.append(suffix)
if not same_name_backend_suffixes:
    return 100

# return highest found suffix number + 1 to iterate
same_name_backend_suffixes.sort()
highest_id: int = same_name_backend_suffixes[-1]

async def backend_update_auth(backend_id: int, body: dict = Body(...), api_key: APIKey = Depends(get_api_key)):
# process inputs TODO: should we validate further?
backend_id = int(secure_filename(str(backend_id))) # TODO: are secure_filename and str necessary? validation?
assert backend_id is not None, "backend_id is required" # @reviewer: is this okay?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this raise an exception?

If no backend id is provided it should raise an exception

async def delete_backend(backend_id: int, api_key: APIKey = Depends(get_api_key)):
try:
backend_id = int(secure_filename(str(backend_id)))
assert backend_id is not None, "backend_id is required" # @reviewer: is this okay?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this raise an exception?

If no backend id is provided it should raise an exception

@dweinholz dweinholz self-requested a review March 5, 2026 13:37
Copy link
Contributor

@dweinholz dweinholz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    {% if only_allow_owner %}

This part must be removed from all templates where we want to prevent the deactivation of the authorisation.

Also please change the permissions of the files again


Currently the deactivaten of the auth is not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants