openpubkey / openpubkey/openpubkey

The relationship between OPs and PK Tokens

Open
#109 1 comment 0 reactions 1 assignee View on GitHub

@EthanHeilman is already working on this.

Since Mar 2, 2024.

Dominant language
Go
Stars
909
Forks
74
Avg merge
12m
Merged PRs (30d)
1

Description

I wanted to write up an issue on this because while we in OpenPubkey have discussed the nature of the relationship between OP (OpenID Providers) and PK Tokens there isn't much written down.

PK Token Issuance/Validity and OpenID Providers/OIDC Clients

One can not meaningfully ask if a PK Token is valid by itself. The question validity must always been understood in reference to both a OpenID Provider and an OIDC Client.

Some examples:

  • With the Google OP, the PK Token is only valid if the OIDC Client ID specified in the aud (audience) claim in the ID Token matches the expected value. Additionally within the context of the Google OP we must check that the CIC is committed to in the nonce claim in the ID Token.
  • Contrast this with the Github OP where there is no set aud (audience) claim to match against in the ID Token as the CIC is committed to in the nonce, but Github PK Token must be GQ signatures.
  • The proposed Gitlab OP implementation has a set prefix in the aud claim which must match the expected value. Unlike GoogleOP or the Github OP, the CIC isn't committed to directly in the ID Token at all but committed to by the GQ Signature itself. https://github.com/openpubkey/openpubkey/issues/100

For things like zkLogin we can use the architectural existence of providers clients (OPs) provides an excellent point to transform SNARK based ID Tokens into PK Tokens. The makes expiration of the PK Token depend on the provider client implementation. https://github.com/openpubkey/openpubkey/issues/101

PK Token usage and OpenID Providers/OIDC Clients

Beyond just validity, using a PK Token depends on the OP.

  • GoogleOP always has an email claim.
  • AzureOP (currently not added) does not have an email claim (although it sometimes does). Instead the email can be looked up from Microsoft using the sub claim.
  • GithubOP doesn't always have an email claim.
  • zkLoginOP may or may not have an email claim but to read the email, the user must reveal a value opening the email commitment.

The following pattern fits this relationship well:

googlePkt, err := GoogleOP.Verify(pkt)
if googlePkt.email == "alice@gmail.com" {
...
}

Since we know that Google PK Tokens always have email addresses, if we cast PK Tokens to the subtypes of PK Tokens based on the OP we can let have compile time type checking of PK Token claims.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.