-
Notifications
You must be signed in to change notification settings - Fork 59
Adding support for EU region #137
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bea8829
Adding support for EU region
EliMoshkovich 857b0a3
fix eu login bug
EliMoshkovich e586087
Tests added
EliMoshkovich f12e43c
Fix OAuth Login Bug, API Key Validation Bug, Terraform Export Bug, In…
EliMoshkovich a906a90
default roles added for exporter
EliMoshkovich 51a2298
Fix README.md - Prettier
EliMoshkovich 8cdcf51
Fix some tests
EliMoshkovich 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,21 +1,93 @@ | ||
| export const KEY_FILE_PATH = './permit.key'; | ||
| export const KEYSTORE_PERMIT_SERVICE_NAME = 'Permit.io'; | ||
| export const DEFAULT_PERMIT_KEYSTORE_ACCOUNT = 'PERMIT_DEFAULT_ENV'; | ||
| export const CLOUD_PDP_URL = 'https://cloudpdp.api.permit.io'; | ||
| export const PERMIT_API_URL = 'https://api.permit.io'; | ||
| export const PERMIT_API_STATISTICS_URL = | ||
| 'https://pdp-statistics.api.permit.io/v2/stats'; | ||
| export const API_URL = 'https://api.permit.io/v2/'; | ||
| export const FACTS_API_URL = `${API_URL}facts/`; | ||
| export const API_PDPS_CONFIG_URL = `${API_URL}pdps/me/config`; | ||
| export const PERMIT_ORIGIN_URL = 'https://app.permit.io'; | ||
| export const REGION_KEYSTORE_ACCOUNT = 'PERMIT_REGION'; | ||
|
|
||
| // Region type | ||
| export type PermitRegion = 'us' | 'eu'; | ||
|
|
||
| // Get region from environment variable or default to 'us' | ||
| let currentRegion: PermitRegion = | ||
| (process.env['PERMIT_REGION'] as PermitRegion) || 'us'; | ||
|
|
||
| // Function to set the current region | ||
| export const setRegion = (region: PermitRegion) => { | ||
| currentRegion = region; | ||
| }; | ||
|
|
||
| // Function to get the current region | ||
| export const getRegion = (): PermitRegion => { | ||
| return currentRegion; | ||
| }; | ||
|
|
||
| // Function to get region-specific subdomain | ||
| const getRegionSubdomain = (region: PermitRegion): string => { | ||
| return region === 'eu' ? 'eu.' : ''; | ||
| }; | ||
|
|
||
| // Region-aware URL getters | ||
| export const getPermitApiUrl = (): string => { | ||
| const subdomain = getRegionSubdomain(currentRegion); | ||
| return `https://api.${subdomain}permit.io`; | ||
| }; | ||
|
|
||
| export const getPermitOriginUrl = (): string => { | ||
| const subdomain = getRegionSubdomain(currentRegion); | ||
| return `https://app.${subdomain}permit.io`; | ||
| }; | ||
|
|
||
| export const getAuthPermitDomain = (): string => { | ||
| const subdomain = getRegionSubdomain(currentRegion); | ||
| return `app.${subdomain}permit.io`; | ||
| }; | ||
|
|
||
| export const getCloudPdpUrl = (): string => { | ||
| if (currentRegion === 'eu') { | ||
| return 'https://cloudpdp.api.eu-central-1.permit.io'; | ||
| } | ||
| return 'https://cloudpdp.api.permit.io'; | ||
| }; | ||
|
|
||
| export const getPermitApiStatisticsUrl = (): string => { | ||
| if (currentRegion === 'eu') { | ||
| return 'https://pdp-statistics.api.eu-central-1.permit.io/v2/stats'; | ||
| } | ||
| return 'https://pdp-statistics.api.permit.io/v2/stats'; | ||
| }; | ||
|
|
||
| export const getApiUrl = (): string => { | ||
| return `${getPermitApiUrl()}/v2/`; | ||
| }; | ||
|
|
||
| export const getFactsApiUrl = (): string => { | ||
| return `${getApiUrl()}facts/`; | ||
| }; | ||
|
|
||
| export const getApiPdpsConfigUrl = (): string => { | ||
| return `${getApiUrl()}pdps/me/config`; | ||
| }; | ||
|
|
||
| export const getAuthApiUrl = (): string => { | ||
| return `${getPermitApiUrl()}/v1/`; | ||
| }; | ||
|
|
||
| // Legacy exports (maintain backwards compatibility) | ||
| export const CLOUD_PDP_URL = getCloudPdpUrl(); | ||
| export const PERMIT_API_URL = getPermitApiUrl(); | ||
| export const PERMIT_API_STATISTICS_URL = getPermitApiStatisticsUrl(); | ||
| export const API_URL = getApiUrl(); | ||
| export const FACTS_API_URL = getFactsApiUrl(); | ||
| export const API_PDPS_CONFIG_URL = getApiPdpsConfigUrl(); | ||
| export const PERMIT_ORIGIN_URL = getPermitOriginUrl(); | ||
| export const AUTH_PERMIT_DOMAIN = getAuthPermitDomain(); | ||
| export const AUTH_API_URL = getAuthApiUrl(); | ||
|
|
||
| export const AUTH_REDIRECT_HOST = 'localhost'; | ||
| export const AUTH_REDIRECT_PORT = 62419; | ||
| export const AUTH_REDIRECT_URI = `http://${AUTH_REDIRECT_HOST}:${AUTH_REDIRECT_PORT}`; | ||
| export const AUTH_PERMIT_DOMAIN = 'app.permit.io'; | ||
| export const AUTH_API_URL = 'https://api.permit.io/v1/'; | ||
| // auth.permit.io is common for both regions | ||
| export const AUTH_PERMIT_URL = 'https://auth.permit.io'; | ||
| export const AUTH0_AUDIENCE = 'https://api.permit.io/v1/'; // Auth0 audience is shared across all regions | ||
|
|
||
| export const TERRAFORM_PERMIT_URL = | ||
| 'https://permit-cli-terraform.up.railway.app'; |
This file contains hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.