-
Notifications
You must be signed in to change notification settings - Fork 10
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
Introduce new response headers for world readable/writable realm #999
Introduce new response headers for world readable/writable realm #999
Conversation
Test Results491 tests ±0 487 ✔️ ±0 6m 37s ⏱️ +9s Results for commit 03c528f. ± Comparison against base commit d75de62. This pull request removes 491 and adds 491 tests. Note that renamed tests count towards both.
This pull request removes 4 skipped tests and adds 4 skipped tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
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.
Minor suggestions
as for the question of whether writable is worth having, I can imagine a world-writable realm existing in an intranet-sort of context so it seems good to have to me, but I defer to those who know this more deeply!
assert.true( | ||
response.get('X-realm-public-writable') != undefined, | ||
'realm is public writable', | ||
); |
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.
Would these and below work with assert.ok(response.get('X-realm-public-writable'))
instead? It seems a bit more concise to just check for truthiness.
@@ -9,6 +12,8 @@ export function createResponse( | |||
headers: { | |||
...init?.headers, | |||
'X-Boxel-Realm-Url': unresolvedRealmURL, | |||
...(permissions['*'].includes('read') && { 'X-Realm-Public-Readable': 'true' }), | |||
...(permissions['*'].includes('write') && { 'X-Realm-Public-Writable': 'true' }), |
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.
Since we already have X-Boxel-Realm-…
maybe these should follow that pattern? X-Boxel-Realm-Public-Readable
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.
Agreed 👍
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 passing realm permissions config along so far into response creating functions and having related logic there might not be ideal. I'm leaning towards thinking the logic for telling whether the realm is publicly readable or writable should be the responsibility of the realm itself - I'd consider adding realm.isPubliclyReadable
and realm.isPubliclyWritable
getters and using that for determining response headers. It would also be a bit easier to refactor once we move to Postgres
Co-authored-by: Buck Doyle <[email protected]>
packages/runtime-common/realm.ts
Outdated
@@ -705,30 +715,30 @@ export class Realm { | |||
'7d', | |||
this.#realmSecretSeed, | |||
); | |||
return createResponse(this.url, null, { | |||
return createResponse(this.url, this.isPublicReadable, this.isPublicWritable, null, { |
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.
Given that all first three params are properties of realm maybe at this point we can just pass realm
and read the needed properties in createResponse
?
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.
updated db68a7e
…-readable-writable
In this PR, I added new headers
X-Realm-Public-Readable
andX-Realm-Public-Writable
for world readable/writable realm.*) I'm not sure with world writable realm. Do we need that?