-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(oracle-fusion): add shared integration foundation #7427
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
Open
BillLeoutsakosvl346
wants to merge
12
commits into
staging
Choose a base branch
from
feat/oracle-fusion-foundation
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,818
−9
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
abb64b8
feat(oracle-fusion): add shared integration foundation
BillLeoutsakosvl346 a7ae174
fix(oracle-fusion): harden numeric and origin parsing
BillLeoutsakosvl346 7b669e7
fix(oracle-fusion): handle large integral exponents
BillLeoutsakosvl346 b0d41e7
fix(oracle-fusion): classify rejected redirects
BillLeoutsakosvl346 623fc6e
fix(credentials): enforce service-account provider and kind centrally
a63a436
refactor(oracle-fusion): stabilize addressing and protocol primitives
c8c83c8
feat(oracle-fusion): add bounded JSON mutations
584f770
fix(credentials): reuse trusted tool policy during resolution
4600846
fix(oracle-fusion): close validation edge cases
0431a39
fix(oracle-fusion): preserve validated protocol values
fc2d2ea
fix(oracle-fusion): harden response invariants
4d644af
fix(oracle-fusion): validate continuing page totals
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
94 changes: 94 additions & 0 deletions
94
apps/sim/lib/credentials/client-credential-accounts/minters/oracle-fusion.test.ts
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 |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| /** | ||
| * @vitest-environment node | ||
| */ | ||
| import { describe, expect, it, vi } from 'vitest' | ||
| import { mintOracleFusionServiceAccountToken } from '@/lib/credentials/client-credential-accounts/minters/oracle-fusion' | ||
|
|
||
| const FIELDS = { | ||
| orgId: 'https://vision.fa.us2.oraclecloud.com', | ||
| clientId: 'integration-user', | ||
| clientSecret: 'password-with-symbols-!@#', | ||
| } | ||
|
|
||
| describe('mintOracleFusionServiceAccountToken', () => { | ||
| it('derives an opaque Basic credential locally with a five-minute lifetime', async () => { | ||
| const fetchSpy = vi.spyOn(globalThis, 'fetch') | ||
|
|
||
| await expect(mintOracleFusionServiceAccountToken(FIELDS)).resolves.toEqual({ | ||
| instanceUrl: FIELDS.orgId, | ||
| accessToken: Buffer.from(`${FIELDS.clientId}:${FIELDS.clientSecret}`, 'utf8').toString( | ||
| 'base64' | ||
| ), | ||
| expiresInSeconds: 300, | ||
| identity: { | ||
| displayName: 'Oracle Fusion vision', | ||
| principal: null, | ||
| auditMetadata: { oracleFusionApplicationOrigin: FIELDS.orgId }, | ||
| storedMetadata: { applicationOrigin: FIELDS.orgId }, | ||
| }, | ||
| }) | ||
| expect(fetchSpy).not.toHaveBeenCalled() | ||
| fetchSpy.mockRestore() | ||
| }) | ||
|
|
||
| it('normalizes the origin and omits connect-time identity during resolution', async () => { | ||
| await expect( | ||
| mintOracleFusionServiceAccountToken( | ||
| { ...FIELDS, orgId: ' HTTPS://VISION.FA.OCS.ORACLECLOUD.COM/ ' }, | ||
| { skipIdentity: true } | ||
| ) | ||
| ).resolves.toEqual({ | ||
| instanceUrl: 'https://vision.fa.ocs.oraclecloud.com', | ||
| accessToken: Buffer.from(`${FIELDS.clientId}:${FIELDS.clientSecret}`, 'utf8').toString( | ||
| 'base64' | ||
| ), | ||
| expiresInSeconds: 300, | ||
| }) | ||
| }) | ||
|
|
||
| it.each([ | ||
| 'http://vision.fa.us2.oraclecloud.com', | ||
| 'https://vision.fa.us2.oraclecloud.com/path', | ||
| 'https://vision.fa.us2.oraclecloud.com/path/..', | ||
| 'https://vision.fa.us2.oraclecloud.com/%2e%2e/', | ||
| 'https://vision.fa.us2.oraclecloud.com:443', | ||
| 'https://user:password@vision.fa.us2.oraclecloud.com', | ||
| 'https://vision.fa.us2.oraclecloud.com?tenant=other', | ||
| 'https://vision.fa.us2.oraclecloud.com#fragment', | ||
| 'https://vision.fa.us2.oraclecloud.com.evil.example', | ||
| 'https://vanity.example.com', | ||
| ])('rejects the unsafe application URL %j without a network probe', async (orgId) => { | ||
| const fetchSpy = vi.spyOn(globalThis, 'fetch') | ||
| await expect(mintOracleFusionServiceAccountToken({ ...FIELDS, orgId })).rejects.toMatchObject({ | ||
| code: 'site_not_found', | ||
| status: 400, | ||
| }) | ||
| expect(fetchSpy).not.toHaveBeenCalled() | ||
| fetchSpy.mockRestore() | ||
| }) | ||
|
|
||
| it.each([ | ||
| ['', FIELDS.clientSecret], | ||
| ['user:name', FIELDS.clientSecret], | ||
| ['user\nname', FIELDS.clientSecret], | ||
| ['u'.repeat(256), FIELDS.clientSecret], | ||
| [FIELDS.clientId, ''], | ||
| [FIELDS.clientId, 'password\n'], | ||
| [FIELDS.clientId, 'p'.repeat(1025)], | ||
| ])( | ||
| 'rejects malformed local credentials without exposing them', | ||
| async (clientId, clientSecret) => { | ||
| const error = await mintOracleFusionServiceAccountToken({ | ||
| ...FIELDS, | ||
| clientId, | ||
| clientSecret, | ||
| }).catch((caught: unknown) => caught) | ||
| expect(error).toMatchObject({ code: 'invalid_credentials', status: 400 }) | ||
| const serialized = JSON.stringify(error) | ||
| if (clientId) expect(serialized).not.toContain(clientId) | ||
| if (clientSecret) expect(serialized).not.toContain(clientSecret) | ||
| const encoded = Buffer.from(`${clientId}:${clientSecret}`, 'utf8').toString('base64') | ||
| if (encoded) expect(serialized).not.toContain(encoded) | ||
| } | ||
| ) | ||
| }) |
68 changes: 68 additions & 0 deletions
68
apps/sim/lib/credentials/client-credential-accounts/minters/oracle-fusion.ts
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 |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { normalizeOracleFusionApplicationOrigin } from '@/lib/credentials/client-credential-accounts/descriptors' | ||
| import type { | ||
| ClientCredentialAccountFields, | ||
| ClientCredentialAccountMintOptions, | ||
| ClientCredentialAccountMintResult, | ||
| } from '@/lib/credentials/client-credential-accounts/server' | ||
| import { TokenServiceAccountValidationError } from '@/lib/credentials/token-service-accounts/errors' | ||
|
|
||
| const BASIC_CREDENTIAL_CACHE_TTL_SECONDS = 5 * 60 | ||
| const ORACLE_FUSION_CREDENTIAL_STEP = 'oracle_fusion_credential_validation' | ||
| const USERNAME_MAX_LENGTH = 255 | ||
| const PASSWORD_MAX_LENGTH = 1024 | ||
| const CONTROL_CHARACTER = /[\u0000-\u001f\u007f]/ | ||
|
|
||
| function invalidCredential(reason: string): TokenServiceAccountValidationError { | ||
| return new TokenServiceAccountValidationError('invalid_credentials', 400, { | ||
| step: ORACLE_FUSION_CREDENTIAL_STEP, | ||
| reason, | ||
| }) | ||
| } | ||
|
|
||
| /** | ||
| * Resolves locally validated Oracle Basic credentials through the shared | ||
| * client-credential minter contract. Oracle does not expose a documented, | ||
| * privilege-neutral identity probe, so authentication occurs on first use. | ||
| */ | ||
| export async function mintOracleFusionServiceAccountToken( | ||
| fields: ClientCredentialAccountFields, | ||
| options?: ClientCredentialAccountMintOptions | ||
| ): Promise<ClientCredentialAccountMintResult> { | ||
| const instanceUrl = normalizeOracleFusionApplicationOrigin(fields.orgId) | ||
| if (!instanceUrl) { | ||
| throw new TokenServiceAccountValidationError('site_not_found', 400, { | ||
| step: ORACLE_FUSION_CREDENTIAL_STEP, | ||
| reason: 'Fusion Applications URL must be a canonical Oracle-assigned HTTPS origin', | ||
| }) | ||
| } | ||
|
|
||
| const username = fields.clientId.trim() | ||
| const password = fields.clientSecret | ||
| if (!username || username.length > USERNAME_MAX_LENGTH || CONTROL_CHARACTER.test(username)) { | ||
| throw invalidCredential('integration username is invalid') | ||
| } | ||
| if (username.includes(':')) { | ||
| throw invalidCredential('integration username must not contain a colon') | ||
| } | ||
| if (!password || password.length > PASSWORD_MAX_LENGTH || CONTROL_CHARACTER.test(password)) { | ||
| throw invalidCredential('password is invalid') | ||
| } | ||
|
|
||
| const accessToken = Buffer.from(`${username}:${password}`, 'utf8').toString('base64') | ||
| const tenant = new URL(instanceUrl).hostname.split('.')[0] | ||
| return { | ||
| instanceUrl, | ||
| accessToken, | ||
| expiresInSeconds: BASIC_CREDENTIAL_CACHE_TTL_SECONDS, | ||
| ...(!options?.skipIdentity | ||
| ? { | ||
| identity: { | ||
| displayName: `Oracle Fusion ${tenant}`, | ||
| principal: null, | ||
| auditMetadata: { oracleFusionApplicationOrigin: instanceUrl }, | ||
| storedMetadata: { applicationOrigin: instanceUrl }, | ||
| }, | ||
| } | ||
| : {}), | ||
| } | ||
| } |
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.