Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Emit ID for verification code #215

Merged
merged 8 commits into from
Aug 10, 2020
Merged

Conversation

whaught
Copy link
Contributor

@whaught whaught commented Aug 10, 2020

Issue #109

Proposed Changes

  • Include the Database ID for the issued verification code. This will be later used in a new API to check the claimed/unclaimed status of the code.

Open Question

  • Are there any security concerns with using this DB handle / do we need to create an artificial GUID key for this purpose. The DB key is an auto-increment uint which may allow for scraping or counting; However the user must be authenticated to retrieve code status.

Release Note

Include ID in the issue VerificationCode response

@googlebot googlebot added the cla: yes Auto: added by CLA bot when all committers have signed a CLA. label Aug 10, 2020
@whaught whaught changed the title Emit ID for verification code [WIP] Emit ID for verification code Aug 10, 2020
@icco
Copy link
Contributor

icco commented Aug 10, 2020

Google API best practices say that we should use a string for all publicly visible IDs. If it's not a significant amount of work, we should use a GUID instead of an incrementing int.

Copy link
Member

@sethvargo sethvargo left a comment

Choose a reason for hiding this comment

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

/lgtm

@sethvargo
Copy link
Member

Are there any security concerns with using this DB handle / do we need to create an artificial GUID key for this purpose. The DB key is an auto-increment uint which may allow for scraping or counting; However the user must be authenticated to retrieve code status.

I don't think this vector is a concern in this case. If we go with UUIDs, we'd want to do that at the database layer and use that as the primary key instead of having two primary keys (example).

@sethvargo
Copy link
Member

It's also worth noting that we already use IDs in the URLs for API keys. If we want to switch to UUIDs, we might consider doing that as a wholesale change across all models as a followup?

@whaught whaught changed the title [WIP] Emit ID for verification code Emit ID for verification code Aug 10, 2020
@@ -143,8 +145,13 @@ func (c *Controller) HandleIssue() http.Handler {
}
}

var intAsBytes []byte
binary.LittleEndian.PutUint64(intAsBytes, uint64(id))
idString := base64.StdEncoding.EncodeToString(intAsBytes)
Copy link
Member

Choose a reason for hiding this comment

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

You'll probably want URLEncoding here instead, since this will be used as part of a URL. However, it's probably better to use hex here (even though it's longer).

Copy link
Member

Choose a reason for hiding this comment

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

Also document this 😄

Copy link
Member

@sethvargo sethvargo left a comment

Choose a reason for hiding this comment

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

/lgtm

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sethvargo, whaught

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-robot google-oss-robot merged commit 63bc844 into google:main Aug 10, 2020
@whaught whaught deleted the track-expiry branch August 11, 2020 03:27
@google google locked and limited conversation to collaborators Oct 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Auto: added by CLA bot when all committers have signed a CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants