-
Notifications
You must be signed in to change notification settings - Fork 0
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
Restrict CORS for Builder Secret Keys #31
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* eslint-disable */ | ||
// authcontrol v0.9.1 809804f85757ee407e93c191d6d5bfb75b82cb56 | ||
// authcontrol v0.9.1 6d8f688a98165b12e0ddfa4ecbaeb8bd7d7f92ac | ||
// -- | ||
// Code generated by [email protected] with typescript generator. DO NOT EDIT. | ||
// | ||
|
@@ -16,7 +16,7 @@ export const WebRPCVersion = "v1" | |
export const WebRPCSchemaVersion = "v0.9.1" | ||
|
||
// Schema hash generated from your RIDL schema | ||
export const WebRPCSchemaHash = "809804f85757ee407e93c191d6d5bfb75b82cb56" | ||
export const WebRPCSchemaHash = "6d8f688a98165b12e0ddfa4ecbaeb8bd7d7f92ac" | ||
|
||
type WebrpcGenVersions = { | ||
webrpcGenVersion: string; | ||
|
@@ -413,6 +413,19 @@ export class ProjectNotFoundError extends WebrpcError { | |
} | ||
} | ||
|
||
export class SecretKeyCorsDisallowedError extends WebrpcError { | ||
constructor( | ||
name: string = 'SecretKeyCorsDisallowed', | ||
code: number = 1009, | ||
message: string = `CORS disallowed. Admin API Secret Key can't be used from a web app.`, | ||
status: number = 0, | ||
cause?: string | ||
) { | ||
super(name, code, message, status, cause) | ||
Object.setPrototypeOf(this, SecretKeyCorsDisallowedError.prototype) | ||
} | ||
} | ||
|
||
|
||
export enum errors { | ||
WebrpcEndpoint = 'WebrpcEndpoint', | ||
|
@@ -435,6 +448,7 @@ export enum errors { | |
Geoblocked = 'Geoblocked', | ||
RateLimited = 'RateLimited', | ||
ProjectNotFound = 'ProjectNotFound', | ||
SecretKeyCorsDisallowed = 'SecretKeyCorsDisallowed', | ||
} | ||
|
||
export enum WebrpcErrorCodes { | ||
|
@@ -458,6 +472,7 @@ export enum WebrpcErrorCodes { | |
Geoblocked = 1006, | ||
RateLimited = 1007, | ||
ProjectNotFound = 1008, | ||
SecretKeyCorsDisallowed = 1009, | ||
} | ||
|
||
export const webrpcErrorByCode: { [code: number]: any } = { | ||
|
@@ -481,6 +496,7 @@ export const webrpcErrorByCode: { [code: number]: any } = { | |
[1006]: GeoblockedError, | ||
[1007]: RateLimitedError, | ||
[1008]: ProjectNotFoundError, | ||
[1009]: SecretKeyCorsDisallowedError, | ||
} | ||
|
||
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, this will only log error with
origin
andproject_id
fields, if we encounter a Secret Key misused from a web app.Eventually, we will error out instead, once we're confident it won't disrupt major customers.