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

Audit trail for more owner actions #1548

Open
carols10cents opened this Issue Nov 1, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@carols10cents
Copy link
Member

carols10cents commented Nov 1, 2018

Further steps beyond #1478. These changes wouldn't be exposed in the UI but would be in the database for us to use in determining who took what actions when.

  • Add a column to the api_tokens table named revoked that's a BOOLEAN NOT NULL DEFAULT 'f'. Then instead of deleting tokens, mark them as revoked.

  • Create a migration (using diesel migration generate, as explained in this guide) that adds a new table named version_owner_actions with the following columns:

    • id SERIAL PRIMARY KEY
    • version_id FOREIGN KEY REFERENCES versions (id)
    • owner_id FOREIGN KEY REFERENCES users (id)
    • owner_token_id FOREIGN KEY REFERENCES api_tokens (id)
    • action INTEGER NOT NULL (that would map to a Rust enum with variants publish, yank, unyank)
    • time TIMESTAMP NOT NULL DEFAULT now()
  • Keep the headers[0] authorization header value accessible by holding onto it in the AuthenticationSource::ApiToken variant

  • Within the crate publish transaction, after the new version record is created, create a new version owner action record with action = "publish", version_id = version.id, owner_id = user.id, owner_token = req.authentication_source() (and then extract the
    token value)

  • Make similar changes to add records to the activity table in yank and unyank

  • Add a field to EncodableVersion that's a Vec of all the actions, owner ids, and times that this version has had an action taken on it so that this info, minus the api token value, is returned in the API response

  • Add a table crate_owners_actions that records who adds and removes other owners from a crate

  • Add tests that this information is being recorded and returned as expected

@hinchley2018

This comment has been minimized.

Copy link

hinchley2018 commented Dec 3, 2018

@carols10cents This sounds like a fun issue to sink my teeth into.
Would you mind if I pick this up?
Is there a deadline for completing this? (might take me a few weeks)

@carols10cents

This comment has been minimized.

Copy link
Member Author

carols10cents commented Dec 3, 2018

I don't mind at all, and no, there's no deadline!

bors-voyager bot added a commit that referenced this issue Dec 3, 2018

Merge #1567
1567: Mark API tokens as revoked r=carols10cents a=joshleeb

With this PR, when a user deletes an API token, rather than deleting it from the database, it will instead be marked as `revoked`.

That means that this PR also adds a migration to add the column `revoked` to the `api_tokens` table.

Ref. #1548 (Task 1)

Co-authored-by: Josh Leeb-du Toit <josh.leebdutoit@gmail.com>

@carols10cents carols10cents changed the title Audit trail for more actions Audit trail for more owner actions Feb 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.