Skip to content

Audit trail for more owner actions #1548

Open
@carols10cents

Description

@carols10cents

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

Activity

hinchley2018

hinchley2018 commented on Dec 3, 2018

@hinchley2018

@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

carols10cents commented on Dec 3, 2018

@carols10cents
MemberAuthor

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

added a commit that references this issue on Dec 3, 2018
changed the title [-]Audit trail for more actions[/-] [+]Audit trail for more owner actions[/+] on Feb 14, 2019

21 remaining items

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Turbo87@carols10cents@hinchley2018

        Issue actions

          Audit trail for more owner actions · Issue #1548 · rust-lang/crates.io