-
Notifications
You must be signed in to change notification settings - Fork 88
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
feat(auth): use split auth specs in app #692
Conversation
db2d126
to
d68bd20
Compare
fd155a8
to
52547fb
Compare
@njlie Want to open a pull request in https://github.com/interledger/open-payments removing/fixing whatever |
52547fb
to
da02c37
Compare
Sounds good. |
packages/auth/package.json
Outdated
@@ -11,7 +11,7 @@ | |||
"build": "pnpm build:deps && tsc --build tsconfig.json", | |||
"clean": "rm -fr dist/", | |||
"fetch-schemas": "./scripts/get-op-schema.sh", | |||
"test": "jest --passWithNoTests --maxWorkers=50%", | |||
"test": "pnpm fetch-schemas && jest --passWithNoTests --maxWorkers=50%", |
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.
In the spirit of #684 (comment), I think we shouldn't cause a local dev to inadvertently nuke their local schemas.
packages/auth/src/index.ts
Outdated
@@ -104,7 +104,16 @@ export function initIocContainer( | |||
|
|||
container.singleton('openApi', async (deps) => { | |||
const config = await deps.use('config') | |||
return await createOpenAPI(config.authServerSpec) | |||
const clientSpec = await createOpenAPI(config.authServerSpec) |
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.
What if get-op-schema.sh
also fetched the auth server spec, and we just used the local file (remove config.authServerSpec
) as with the other specs?
That way we ensure all the OpenAPI specs in auth
are using the same version of the schemas.
curl -o "$OUTDIR/schemas.yaml" https://raw.githubusercontent.com/interledger/open-payments/main/openapi/schemas.yaml | ||
curl -o "$OUTDIR/auth-server.yaml" https://raw.githubusercontent.com/interledger/open-payments/main/openapi/auth-server.yaml |
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.
I think we should either pin to (current) head of main
or support an env var when running fetch-schemas
, something like:
curl -o "$OUTDIR/schemas.yaml" https://raw.githubusercontent.com/interledger/open-payments/main/openapi/schemas.yaml | |
curl -o "$OUTDIR/auth-server.yaml" https://raw.githubusercontent.com/interledger/open-payments/main/openapi/auth-server.yaml | |
curl -o "$OUTDIR/schemas.yaml" https://raw.githubusercontent.com/interledger/open-payments/${OPEN_PAYMENTS_COMMIT:-main}/openapi/schemas.yaml | |
curl -o "$OUTDIR/client.yaml" https://raw.githubusercontent.com/interledger/open-payments/${OPEN_PAYMENTS_COMMIT:-main}/openapi/auth-server.yaml |
packages/auth/src/index.ts
Outdated
@@ -103,8 +103,7 @@ export function initIocContainer( | |||
}) | |||
|
|||
container.singleton('openApi', async (deps) => { | |||
const config = await deps.use('config') | |||
const clientSpec = await createOpenAPI(config.authServerSpec) | |||
const clientSpec = await createOpenAPI('./openapi/auth-server.yaml') |
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.
What if we rename the fetched AS spec to match the existing local specs:
const clientSpec = await createOpenAPI('./openapi/auth-server.yaml') | |
const clientSpec = await createOpenAPI('./openapi/client.yaml') |
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.
I feel compelled to use the original name since it's being pulled in from somewhere external. The association with that spec's externality seems stronger that way, and it's holding the actual GNAP implementation so I feel auth-server might be a better name anyways.
d327912
to
21c3c1f
Compare
@@ -46,6 +46,7 @@ jobs: | |||
- uses: actions/checkout@v2 | |||
- uses: ./.github/workflows/rafiki/env-setup | |||
- run: pnpm --filter openapi build | |||
- run: pnpm --filter auth fetch-schemas |
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.
Actually, I wonder if fetch-schemas
also needs to be run in the Dockerfile
https://github.com/interledger/rafiki/blob/main/packages/auth/Dockerfile#L18
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.
Yeah, local env fails as is with:
local-peer-auth-1 | {"level":50,"time":1667568836819,"pid":1,"hostname":"f5cbb380f8b7","msg":"ResolverError: Error opening file \"/workspace/openapi/auth-server.yaml\" \nENOENT: no such file or directory, open '/workspace/openapi/auth-server.yaml'\n at ReadFileContext.callback (/workspace/node_modules/.pnpm/@[email protected]/node_modules/@apidevtools/json-schema-ref-parser/lib/resolvers/file.js:52:20)\n at FSReqCallback.readFileAfterOpen [as oncomplete] (node:fs:323:13)"}
I'm thinking instead of adding fetch-schemas
to the Dockerfile, we just add it to https://github.com/interledger/rafiki#environment-setup
That way localenv can run with modified specs.
@@ -46,6 +46,7 @@ jobs: | |||
- uses: actions/checkout@v2 | |||
- uses: ./.github/workflows/rafiki/env-setup | |||
- run: pnpm --filter openapi build | |||
- run: pnpm --filter auth fetch-schemas |
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.
Yeah, local env fails as is with:
local-peer-auth-1 | {"level":50,"time":1667568836819,"pid":1,"hostname":"f5cbb380f8b7","msg":"ResolverError: Error opening file \"/workspace/openapi/auth-server.yaml\" \nENOENT: no such file or directory, open '/workspace/openapi/auth-server.yaml'\n at ReadFileContext.callback (/workspace/node_modules/.pnpm/@[email protected]/node_modules/@apidevtools/json-schema-ref-parser/lib/resolvers/file.js:52:20)\n at FSReqCallback.readFileAfterOpen [as oncomplete] (node:fs:323:13)"}
I'm thinking instead of adding fetch-schemas
to the Dockerfile, we just add it to https://github.com/interledger/rafiki#environment-setup
That way localenv can run with modified specs.
packages/auth/src/index.ts
Outdated
const authServerSpec = await createOpenAPI('./openapi/auth-server.yaml') | ||
const resourceServerSpec = await createOpenAPI( | ||
'./openapi/resource-server.yaml' | ||
) | ||
const idpSpec = await createOpenAPI('./openapi/id-provider.yaml') |
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.
auth
build script needs to add these to the dist
folder:
rafiki/packages/auth/package.json
Line 11 in 8898075
"build": "pnpm build:deps && tsc --build tsconfig.json", |
See
backend
's copy-files
:rafiki/packages/backend/package.json
Lines 8 to 10 in 8898075
"build": "pnpm build:deps && tsc --build tsconfig.json && pnpm copy-files", | |
"clean": "rm -fr dist/", | |
"copy-files": "cp src/graphql/schema.graphql dist/graphql/", |
(this is causing local env to fail even after running
fetch-schemas
)
983d511
to
c7f1f8a
Compare
packages/auth/package.json
Outdated
"clean": "rm -fr dist/", | ||
"fetch-schemas": "./scripts/get-op-schema.sh", | ||
"test": "jest --passWithNoTests --maxWorkers=50%", | ||
"prepack": "pnpm build" | ||
"prepack": "pnpm build", | ||
"copy-files": "pnpm fetch-schemas && cp -r ./openapi ./dist" |
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.
"copy-files": "pnpm fetch-schemas && cp -r ./openapi ./dist" | |
"copy-files": "cp -r ./openapi ./dist" |
Otherwise copy-files
& build
nuke local modified specs.
edd7d01
to
00f7a8b
Compare
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.
👍
local env works as long after running:
pnpm --filter auth fetch-schemas
Changes proposed in this pull request
Context
With the updated OpenAPI specs, this branch now suffers from #630
Also, should be updated to use #684 once it is merged in.
Checklist
fixes #number