oxidecomputer / oxidecomputer/omicron

Want DB constraints preventing bad combination of silo settings (e.g., local + saml)

Open
#9,503 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
572
Forks
97
Avg merge
2d 12h
Merged PRs (30d)
96

Description

A low priority correctness improvement I noticed while reviewing something else.

In the silo create request body, the user can specify an identity mode — LocalOnly, SamlJit, or SamlScim — and that mode is then translated into two other properties corresponding to DB columns: authentication mode and user provision type. Because the identity mode can only be passed at silo create time and cannot be updated, this is more or less guaranteed to be correct because the only way that these database columns can be set is by being processed through the below code.

https://github.com/oxidecomputer/omicron/blob/5d08d2fdec25807e367ff6cab043a0b27b30228e/nexus/types/src/external_api/shared.rs?plain=1#L195-L236

However, it would be an easy extra layer of safety to put in constraints in the DB that guarantee you can't accidentally mess up that code.

https://github.com/oxidecomputer/omicron/blob/1c69391b81db0eb1dd787931154753e94a74e1f8/schema/crdb/dbinit.sql#L864-L883

We do similar things elsewhere.

https://github.com/oxidecomputer/omicron/blob/1c69391b81db0eb1dd787931154753e94a74e1f8/schema/crdb/dbinit.sql#L914-L930

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the identity-mode mapping in nexus/types/src/external_api/shared.rs, then inspect the related table definitions in schema/crdb/dbinit.sql, including the nearby examples of existing constraints. Add database constraints that enforce the valid authentication-mode and user-provision-type combinations, and verify that schema initialization accepts the valid combinations while rejecting invalid ones.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.