Skip to content

Conversation

@SyntaxColoring
Copy link
Contributor

@SyntaxColoring SyntaxColoring commented Jan 14, 2026

Overview

This creates a skeleton project for the auth server. It currently does nothing except serve a dummy "hello world" HTTP endpoint.

Closes EXEC-2258.

Corresponding oe-core PR: Opentrons/oe-core#263

Test Plan and Hands on Testing

  • Flex boots, shows nothing failed in systemctl, and responds to an HTTP GET /auth/hello request
  • make -C auth-server push-ot3 works
  • make -C auth-server lint and make -C auth-server test work locally, and also run in CI

Review requests

This copy-pastes a lot of boilerplate, so let's make sure I'm not copying anything that doesn't make sense for auth-server.

See the comments below for additional specific things.

Risk assessment

Low. Nothing uses any of this yet.

12 (twelve) is the natural number following 11 and preceding 13.

Twelve is the 3rd superior highly composite number, the 3rd colossally abundant number, the 5th highly composite number, and is divisible by the numbers from 1 to 4, and 6, a large number of divisors comparatively.

It is central to many systems of timekeeping, including the Western calendar and units of time of day, and frequently appears in the world's major religions.
We need this even though we only indirectly depend on systemd-python (through server-utils), for the same reason robot-server does.
@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.85%. Comparing base (a59c60f) to head (90c6ba2).
⚠️ Report is 47 commits behind head on edge.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #20583      +/-   ##
==========================================
- Coverage   56.93%   56.85%   -0.08%     
==========================================
  Files        3911     3911              
  Lines      322818   323376     +558     
  Branches    45736    46060     +324     
==========================================
+ Hits       183803   183871      +68     
- Misses     138792   139282     +490     
  Partials      223      223              
Flag Coverage Δ
app 46.25% <ø> (-0.02%) ⬇️
shared-data 72.13% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
robot-server/robot_server/hardware.py 66.01% <ø> (+0.10%) ⬆️
system-server/system_server/__main__.py 100.00% <ø> (ø)
system-server/system_server/systemd.py 71.42% <ø> (+1.42%) ⬆️

... and 183 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


# Default command
CMD ["sh", "-c", "python -m pipenv run uvicorn robot_server.app:app --host 0.0.0.0 --port ${PORT} --ws wsproto --lifespan on"]
CMD ["sh", "-c", "python -m pipenv run uvicorn robot_server.app:app --host 0.0.0.0 --port ${PORT} --ws wsproto"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

--lifespan on was an old workaround that's not necessary anymore. Removing it from robot-server just for the sake of keeping its uvicorn invocation matching up with auth-server's.

Comment on lines -3 to -4
NOTE: This file must be python2.7 compatible
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Surely this doesn't actually still need to be python2.7 compatible, right?

Copy link
Contributor Author

@SyntaxColoring SyntaxColoring Jan 20, 2026

Choose a reason for hiding this comment

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

Copypasta'd from system-server, with minor security improvements suggested by zizmor:

  • permissions: {}
  • persist-credentials: false

Also, fixing up the **/* wildcards to **.

Comment on lines +66 to +69
if args.uds is not None:
_log.info(f"Starting auth server on {args.uds}.")
else:
_log.info(f"Starting auth server on {args.host}:{args.port}.")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

None of the logging in this project really works yet. I initially adapted the boilerplate from system-server, but I think it's broken in system-server. EXEC-2290

else:
_log.info(f"Starting auth server on {args.host}:{args.port}.")

uvicorn.run(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like our other servers, this is an ASGI server, which means we can launch it in two ways:

  • By running uvicorn on the command line, pointing it to our global app object, like uvicorn auth_server:app --port 1234. This is how robot-server does it.
  • By defining our own CLI, like python -m auth_server --port 1234, and calling uvicorn.run() internally. This is how system-server does it.

I'm unsure which is better.

  • Invoking uvicorn on the command line seems to be the option softly preferred by documentation and tutorials, including tutorials for other ASGI servers, like Hypercorn.

  • Neither option lets us define custom launch arguments like --persistence-directory. We gotta use environment variables instead. You'd think that uvicorn.run() would have a mechanism to pass custom data to our code, but apparently no.

  • Using uvicorn.run() means we need to write a little bit more boilerplate code to pass along standard arguments like --port and --reload.

  • Using uvicorn.run() gives us a little more flexibility in how we configure logging. It can be more dynamic. For example, we could do different things depending on whether a RUNNING_ON_ROBOT environment variable is present.

    With uvicorn's built-in CLI, the only way to correctly configure the early log messages (like "waiting for application startup," "application startup complete", ...) is by a static file, which seems unpleasant.

I've gone with the uvicorn.run() way, basically because of the logging thing.

@SyntaxColoring SyntaxColoring requested review from a team and TamarZanzouri January 21, 2026 17:56
@SyntaxColoring SyntaxColoring marked this pull request as ready for review January 21, 2026 18:03
Copy link
Contributor

@TamarZanzouri TamarZanzouri left a comment

Choose a reason for hiding this comment

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

Its alive!!! was able to ping the server and get a response back! code changes looks good (as much as i know about) thank you for explaining the reasoning for your changes it helped!

SyntaxColoring added a commit to Opentrons/oe-core that referenced this pull request Jan 22, 2026
… proxy for it (#263)

The monorepo PR Opentrons/opentrons#20583 adds an `auth-server` project. This PR:

* Includes `auth-server` in the build
* Runs `auth-server` as a systemd service
* Exposes `auth-server`'s HTTP API to the network, under an `/auth` route prefix, behind our nginx reverse proxy.

Closes EXEC-2259.
@SyntaxColoring SyntaxColoring merged commit 25e6422 into edge Jan 22, 2026
125 checks passed
@SyntaxColoring SyntaxColoring deleted the auth_server branch January 22, 2026 16:42
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.

4 participants