Skip to content

Commit 539ced6

Browse files
cozminumkurapovnjlie
authored
feat(auth): add subject to grant (#3440)
* feat(auth): add subject to grant * feat(auth): add subject to grant * fix(auth): grant access when is undefined * feat(auth): subject id validation * fix(auth): fix tests * Update packages/auth/src/graphql/schema.graphql Co-authored-by: Max Kurapov <[email protected]> * feat(auth): throw GrantError instead of Error * fix(auth): description for subIdFormat * fix(auth): trx in tests is knex * fix: grant service to throw only grant errors * fix(auth): address change requests * fix(auth): address change requests * fix tests * access token optional in grant response * fix(auth): move accessErrorsMap to grant * fix(auth): fix test for grant access * fix(auth): changed interaction generic error message * use main OpenAPI spec for Auth * fix(auth): approved grant does not return subject * fix(auth): remove unused import Co-authored-by: Max Kurapov <[email protected]> * fix(auth): make access_token optional in response * fix(deps): sha.js critical update * fix(deps): critical update * Update package.json Co-authored-by: Max Kurapov <[email protected]> * update pnpm lock file * change op specs version * feat(auth): update idp openapi spec * feat(auth): make idp standalone * chore(deps): update axios * fix(auth): access token in response when it shouldnt * fix(auth): tests * try to fix grype scan * try fix grype * restore 'fix' * try fix grype * try fix grype 2 * feat(localenv): expose subject during consent in mock-ase (#3666) * feat(localenv): expose subject during consent in mock-ase * feat: include client name in subject grant line * fix(mase): grantId not being retrieved * fix(mase): consent and confirmation texts * fix: handle subject-only grants properly --------- Co-authored-by: Cozmin Ungureanu <[email protected]> --------- Co-authored-by: Max Kurapov <[email protected]> Co-authored-by: Nathan Lie <[email protected]>
1 parent 81f971b commit 539ced6

File tree

37 files changed

+1326
-136
lines changed

37 files changed

+1326
-136
lines changed

.github/workflows/node-build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ jobs:
115115
- name: fail if GraphQL was generated
116116
if: steps.verify-changed-files.outputs.files_changed == 'true'
117117
run: exit 1
118-
118+
119119
codeql-analyze:
120120
runs-on: ubuntu-latest
121121
needs: prerequisite
@@ -263,7 +263,7 @@ jobs:
263263
const truncatedLogs = logContent.length > maxLogSize ? `...(truncated)...\n${logContent.slice(-maxLogSize)}` : logContent;
264264
265265
const commentBody = `
266-
### 🚀 Performance Test Results
266+
### 🚀 Performance Test Results
267267
268268
${summaryContent}
269269
@@ -313,7 +313,7 @@ jobs:
313313
runs-on: ubuntu-latest
314314
timeout-minutes: 5
315315
needs: [auth, backend, frontend, token-introspection, mock-account-servicing-entity, graphql, codeql-analyze, integration-test]
316-
steps:
316+
steps:
317317
- uses: actions/checkout@v4
318318
- uses: ./.github/workflows/rafiki/env-setup
319319
- run: pnpm build
@@ -425,7 +425,7 @@ jobs:
425425
with:
426426
path: /tmp/${{ github.sha }}-${{ matrix.package }}-${{ matrix.platform.name }}-${{ needs.version-generator.outputs.version }}.tar
427427
key: ${{ github.sha }}-${{ matrix.package }}-${{ matrix.platform.name }}-${{ needs.version-generator.outputs.version }}
428-
428+
429429
docker-grype:
430430
name: Docker Grype Scan
431431
needs: [version-generator, docker-build]
@@ -519,7 +519,7 @@ jobs:
519519
platform_name: ${{ matrix.platform.name }}
520520
version: ${{ needs.version-generator.outputs.version }}
521521
gh_token: ${{ secrets.GITHUB_TOKEN }}
522-
522+
523523
push-manifest:
524524
name: Push multi-arch manifest list
525525
needs: [version-generator,push]
@@ -540,7 +540,7 @@ jobs:
540540
package: ${{ matrix.package }}
541541
gh_token: ${{ secrets.GITHUB_TOKEN }}
542542
version: ${{ needs.version-generator.outputs.version }}
543-
543+
544544
generate-release:
545545
runs-on: ubuntu-latest
546546
needs: [push-manifest, version-generator]
@@ -561,7 +561,7 @@ jobs:
561561
allowUpdates: true
562562
draft: false
563563
makeLatest: true
564-
prerelease: endsWith(needs.version-generator.outputs.version, '-alpha')
564+
prerelease: endsWith(needs.version-generator.outputs.version, '-alpha')
565565
name: ${{ needs.version-generator.outputs.version }}
566566
body: ${{ steps.changelog.outputs.changes }}
567567
tag: ${{ needs.version-generator.outputs.version }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
meta {
2+
name: Continuation Request
3+
type: http
4+
seq: 8
5+
}
6+
7+
post {
8+
url: {{senderOpenPaymentsContinuationUri}}
9+
body: json
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: GNAP {{continueToken}}
15+
}
16+
17+
script:pre-request {
18+
const scripts = require('./scripts');
19+
20+
await scripts.addSignatureHeaders();
21+
}
22+
23+
script:post-response {
24+
const scripts = require('./scripts');
25+
26+
scripts.storeTokenDetails();
27+
}
28+
29+
tests {
30+
test("Status code is 200", function() {
31+
expect(res.getStatus()).to.equal(200);
32+
});
33+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
meta {
2+
name: Get sender wallet address
3+
type: http
4+
seq: 1
5+
}
6+
7+
get {
8+
url: {{senderWalletAddress}}
9+
body: none
10+
auth: none
11+
}
12+
13+
headers {
14+
Accept: application/json
15+
}
16+
17+
script:pre-request {
18+
const scripts = require('./scripts');
19+
20+
scripts.addHostHeader("senderOpenPaymentsHost");
21+
}
22+
23+
script:post-response {
24+
const url = require('url')
25+
26+
if (res.getStatus() !== 200) {
27+
return
28+
}
29+
30+
const body = res.getBody()
31+
bru.setEnvVar("senderAssetCode", body?.assetCode)
32+
bru.setEnvVar("senderAssetScale", body?.assetScale)
33+
34+
const authUrl = url.parse(body?.authServer)
35+
if (
36+
authUrl.hostname.includes('cloud-nine-wallet') ||
37+
authUrl.hostname.includes('happy-life-bank')
38+
){
39+
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
40+
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
41+
} else {
42+
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
43+
}
44+
45+
const resourceUrl = url.parse(body?.resourceServer)
46+
if (resourceUrl.hostname.includes('cloud-nine-wallet') || resourceUrl.hostname.includes('happy-life-bank')) {
47+
const port = resourceUrl.hostname.includes('happy-life-bank') ? bru.getEnvVar('happyLifeOpenPaymentsPort') : bru.getEnvVar('cloudNineOpenPaymentsPort')
48+
bru.setEnvVar("senderOpenPaymentsHost", 'http://localhost:' + port + resourceUrl.path);
49+
} else {
50+
bru.setEnvVar("senderOpenPaymentsHost", body?.resourceServer);
51+
}
52+
}
53+
54+
tests {
55+
test("Status code is 200", function() {
56+
expect(res.getStatus()).to.equal(200);
57+
});
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
meta {
2+
name: Grant Request for Subject Information
3+
type: http
4+
seq: 7
5+
}
6+
7+
post {
8+
url: {{senderOpenPaymentsAuthHost}}
9+
body: json
10+
auth: none
11+
}
12+
13+
body:json {
14+
{
15+
"subject": {
16+
"sub_ids": [
17+
{
18+
"id": "{{senderWalletAddress}}",
19+
"format": "uri"
20+
}
21+
]
22+
},
23+
"client": "{{clientWalletAddress}}",
24+
"interact": {
25+
"start": [
26+
"redirect"
27+
]
28+
}
29+
}
30+
31+
}
32+
33+
script:pre-request {
34+
const scripts = require('./scripts');
35+
36+
await scripts.addSignatureHeaders();
37+
}
38+
39+
script:post-response {
40+
const scripts = require('./scripts');
41+
42+
scripts.storeTokenDetails();
43+
44+
const body = res.getBody()
45+
bru.setEnvVar("senderOpenPaymentsContinuationUri", body?.continue.uri)
46+
}
47+
48+
tests {
49+
test("Status code is 200", function() {
50+
expect(res.getStatus()).to.equal(200);
51+
});
52+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
meta {
2+
name: Vailidating Wallet Address Ownership with Open Payments
3+
seq: 6
4+
}

localenv/mock-account-servicing-entity/app/lib/apiClient.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ export class ApiClient {
5050
if (response.status === 200) {
5151
return {
5252
isFailure: false,
53-
payload: response.data.access,
53+
payload: {
54+
access: response.data.access,
55+
subject: response.data.subject,
56+
grantId: response.data.grantId,
57+
state: response.data.state
58+
},
5459
contextUpdates: {
5560
grant: response.data
5661
}

localenv/mock-account-servicing-entity/app/lib/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export interface Access {
2828
limits?: AccessLimit
2929
}
3030

31+
export interface SubjectId {
32+
id: string
33+
format: string
34+
}
35+
3136
export type InstanceConfig = {
3237
name: string
3338
logo: string

0 commit comments

Comments
 (0)