Skip to content

feat: add AccessContext types#6413

Open
BSFishy wants to merge 2 commits intocloudflare:mainfrom
BSFishy:add-access-types
Open

feat: add AccessContext types#6413
BSFishy wants to merge 2 commits intocloudflare:mainfrom
BSFishy:add-access-types

Conversation

@BSFishy
Copy link
Copy Markdown

@BSFishy BSFishy commented Mar 25, 2026

Adds types for Cloudflare Access integration into Workers

@BSFishy BSFishy requested review from a team as code owners March 25, 2026 16:21
@BSFishy BSFishy requested a review from ascorbic March 25, 2026 16:21
* Represents the identity of a user authenticated via Cloudflare Access.
* This matches the result of calling /cdn-cgi/access/get-identity.
*/
type Identity = object;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Would like to get the team's thoughts on this name. I am unfamiliar with how these types get injected into user's projects (afaiu, Env gets added globally automatically), so maybe a more descriptive name works better than Identity? Perhaps something like CfAccessIdentity?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah a more specific name would be appropriate but we should also actually give it a type that represents what it can contain

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

A specific type here is difficult because this type is mostly what the customer sends us from their identity provider. A full type would likely look something like

type CloudflareAccessIdentity = {
  email?: string;
  [key: string]: unknown;
}

At which point I feel like typing it gives no real benefit over object

Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

AccessContext and Identity are quite general types being defined as top level ambient types. This could cause conflicts in the future: I could imagine Identity could be used in a number of scenarios.
Perhaps prefix them with something like CloudflareAccessContext, etc?

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

BSFishy added 2 commits March 31, 2026 21:49
Signed-off-by: Matt Provost <mprovost@cloudflare.com>
Signed-off-by: Matt Provost <mprovost@cloudflare.com>
@BSFishy
Copy link
Copy Markdown
Author

BSFishy commented Mar 31, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants