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

Login page without UI enabled #1039

Merged
merged 5 commits into from
Jan 14, 2025
Merged

Conversation

soapy1
Copy link
Contributor

@soapy1 soapy1 commented Jan 7, 2025

Fixes #1034

Description

This PR updates the auth module to be agnostic to the admin ui. It does this by:

  • separating the login page from the base.html template
  • removing references to admin ui endpoints from the auth module

Pull request checklist

  • Did you test this change locally?
  • Did you update the documentation (if required)?
  • Did you add/update relevant tests for this change (if required)?

Copy link

netlify bot commented Jan 7, 2025

Deploy Preview for conda-store canceled.

Name Link
🔨 Latest commit 1344ce2
🔍 Latest deploy log https://app.netlify.com/sites/conda-store/deploys/677cc674ac6e370008e68eef

Copy link

netlify bot commented Jan 7, 2025

Deploy Preview for conda-store canceled.

Name Link
🔨 Latest commit 3a997ad
🔍 Latest deploy log https://app.netlify.com/sites/conda-store/deploys/6786d4f06275f00008d1e597

@soapy1 soapy1 changed the title Auth without UI Login page without UI Jan 7, 2025
@soapy1 soapy1 changed the title Login page without UI Login page without UI enabled Jan 7, 2025
@soapy1 soapy1 marked this pull request as ready for review January 7, 2025 18:30
@soapy1 soapy1 marked this pull request as draft January 7, 2025 18:57
@soapy1 soapy1 marked this pull request as ready for review January 7, 2025 21:41
@soapy1 soapy1 requested a review from peytondmurray January 7, 2025 21:51
soapy1 added 3 commits January 9, 2025 14:13
After setting the default `next` route to be the base url (when
none is provided), the default route to be loaded is no longer
the `environments` admin page. This change updates the playwright
tests to navigate to the `environments` admin page after logging
in.
@peytondmurray
Copy link
Contributor

I tried testing this by editing the default conda_store_config.py and instead of the error I was getting on main no exception is raised when I navigate to localhost:8080, I just get a 404, as intended:

image

So this seems like a good start. But it sounds like there's other functionality here which I should be testing too? From the issue

trying to login to conda store will produce a 500 error. The full error from the logs is shown below. Relevant part of the error

When you say login, you mean login to the admin UI?


Should there be a test for this? Something like:

  1. Use the existing conda-store testclient
  2. Set these settings on the testclient:
c.CondaStoreServer.enable_ui = False
c.CondaStoreServer.enable_api = True
c.CondaStoreServer.enable_registry = False
c.CondaStoreServer.enable_metrics = False
  1. Send a request to the testclient to login URL (check that there's no UI returned)
  2. Send requests or call functions from conda_store_server.server.auth to make sure they work

@soapy1
Copy link
Contributor Author

soapy1 commented Jan 13, 2025

When you say login, you mean login to the admin UI?

Yep. Sorry, I could have been more clear in the issue. Will update that now.
To see the issue, you'll need to navigate to localhost:8080/ui and then click on the Login button. Instead of getting to the login screen, there will be an error page.

Should there be a test for this? Something like:

Do you mean like an integration test to ensure that loging in works when the ui is disabled?

@peytondmurray
Copy link
Contributor

Actually I can't get to the login screen at all. When I get when I open up localhost:8080/ or localhost:8080/ui is this:

image

Which I think is expected; there's no UI at all with the options set to the above ☝️. The REST API appears to work as intended though.

Do you mean like an integration test to ensure that loging in works when the ui is disabled?

What I mean is that the only way that I know whether this PR fixes #1034 or not is by manually editing my conda_store_config.py, running docker compose up --build, then checking via the browser that the UI doesn't work. Then I use curl to probe the REST API. I feel like there might be a simpler way of checking this; I don't think a full blown integration test is necessary, is it? Maybe if we just use the testclient fixture?

@soapy1
Copy link
Contributor Author

soapy1 commented Jan 14, 2025

Ah, that's my bad again, you need to go to localhost:8000, not localhost:8080. It's important to update your docker compose to include the conda-store-ui

conda-store-ui:
    image:  ghcr.io/conda-incubator/conda-store-ui:sha-2469531
    command: "yarn run start:ui"
    profiles:
      - local-dev
    ports:
      - "8000:8000"
    depends_on:
      conda-store-server:
        condition: service_healthy
    platform: linux/amd64
    volumes:
      - ./src:/usr/src/app/src
      - ./style:/usr/src/app/style
      - ./.env:/usr/src/app/.env
    healthcheck:
      test:
        ["CMD", "curl", "--fail", "http://localhost:8000"]
      interval: 20s
      timeout: 10s
      retries: 8

This way you have a separate service providing the ui functionality.

@soapy1
Copy link
Contributor Author

soapy1 commented Jan 14, 2025

I feel like there might be a simpler way of checking this; I don't think a full blown integration test is necessary, is it? Maybe if we just use the testclient fixture?

Ah, I see what you mean. Great idea! Added 🦩

Copy link
Contributor

@peytondmurray peytondmurray left a comment

Choose a reason for hiding this comment

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

Thank you for adding the extra test. Looks good!

Comment on lines +54 to +57
sys.path is manipulated so that only the name of the called program
(e.g. `pytest`) is present. This prevents traitlets from parsing any
additional pytest args as configuration settings to be applied to
the conda-store-server.
Copy link
Contributor

Choose a reason for hiding this comment

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

😢 traitlets...

@soapy1 soapy1 merged commit 0fc39be into conda-incubator:main Jan 14, 2025
30 checks passed
@soapy1 soapy1 deleted the auth-without-ui branch January 14, 2025 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done 💪🏾
Development

Successfully merging this pull request may close these issues.

[BUG] - conda-store requires UI to be enabled in order to use auth functionality
2 participants