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

Move the token column from the APIKEY table to the SERVICE table #33

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

gridhead
Copy link
Member

Nuke the columns name and expiry_date as they would no longer be needed

@brngylni, a couple of points

  1. Whilst verifying the API key associated with a certain service, please ensure that you also check if the API key is enabled (using the disabled column).
  2. Once this is merged, please update the diagram in the ARC investigation documentation with this change in the database schema.

@gridhead gridhead added the bug Something isn't working label Jul 12, 2024
@gridhead gridhead requested a review from abompard July 12, 2024 08:53
@gridhead gridhead self-assigned this Jul 12, 2024
@abompard
Copy link
Member

Do we need the disabled field ? Because if we don't, we can just add the token column to the services table and drop this table.

@gridhead
Copy link
Member Author

If the APIKEYS and SERVICES tables have a 1:1 relationship, then having a disabled column in both places would mean the same. I think I can move the token to the SERVICES table and get rid of the APIKEYS table entirely.

@gridhead gridhead changed the title Set a 1:1 relations b/w APIKEYS and SERVICES table Move the token column from the APIKEY table to the SERVICE table Jul 12, 2024

class Service(Base, UUIDCreatableMixin, CreatableMixin):
__tablename__ = "services"

id = Column(Integer, primary_key=True, nullable=False)
user_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), unique=False, nullable=False)
token = Column(UnicodeText, unique=True, nullable=False, default=uuid4().hex)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that's really necessary to make this token column unique, because services are identified by their uuid column. That said, it's not a blocker.

Copy link
Member Author

Choose a reason for hiding this comment

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

The likeliness of us getting a collision on the server side is small but never zero. So that is indeed a valid point that keeps us from getting errors due to weird conditions introduced for the token column. I added the suggested change.

Remove the APIKEY table from the entire database schema

Signed-off-by: Akashdeep Dhar <[email protected]>
@gridhead gridhead requested a review from abompard July 12, 2024 09:15
@abompard abompard merged commit 64e63a8 into main Jul 12, 2024
1 of 7 checks passed
@abompard abompard deleted the as11 branch July 12, 2024 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants