-
Notifications
You must be signed in to change notification settings - Fork 1
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
feature(demo-game): make report's page available for players #78
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#import "./FGameData.graphql" | ||
#import "./FPlayerData.graphql" | ||
|
||
query GameWithoutFacts($id: Int) { | ||
gameWithoutFacts(id: $id) { | ||
...GameData | ||
activePeriod { | ||
id | ||
activeSegmentIx | ||
activeSegment { | ||
id | ||
countdownExpiresAt | ||
countdownDurationMs | ||
} | ||
segmentCount | ||
segments { | ||
id | ||
} | ||
} | ||
periods { | ||
id | ||
|
||
index | ||
activeSegmentIx | ||
|
||
segments { | ||
id | ||
|
||
index | ||
|
||
countdownExpiresAt | ||
countdownDurationMs | ||
|
||
learningElements { | ||
id | ||
title | ||
} | ||
|
||
storyElements { | ||
id | ||
title | ||
} | ||
} | ||
segmentCount | ||
} | ||
players { | ||
id | ||
|
||
isReady | ||
|
||
role | ||
|
||
number | ||
name | ||
|
||
facts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security concern: Remove facts field from player data The query still includes the Remove this line to ensure no facts are exposed to non-admin users: - facts |
||
|
||
experience | ||
experienceToNext | ||
token | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,16 @@ export function generateBaseQueries() { | |
}, | ||
}) | ||
|
||
t.field('gameWithoutFacts', { | ||
type: Game, | ||
args: { | ||
id: intArg(), | ||
}, | ||
async resolve(_, args, ctx) { | ||
return GameService.getGame(args, ctx) | ||
}, | ||
}) | ||
Comment on lines
+30
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security concern: Implement facts filtering in resolver The Consider implementing a separate resolver that explicitly filters out facts: t.field('gameWithoutFacts', {
type: Game,
args: {
id: intArg(),
},
async resolve(_, args, ctx) {
- return GameService.getGame(args, ctx)
+ const game = await GameService.getGame(args, ctx)
+ return {
+ ...game,
+ periods: game.periods.map(period => ({
+ ...period,
+ segments: period.segments.map(segment => ({
+ ...segment,
+ facts: undefined
+ }))
+ }))
+ }
},
})
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rschlaefli that's an interesting suggestion ... Maybe we only need one graphql doc? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
t.field('result', { | ||
type: PlayerState, | ||
async resolve(_, args, ctx) { | ||
|
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.
coming from a security perspective, this is not "secure" as the variable can just be changed and the request sent with true to receive all data (even though probably no student ever would do that for a game :D). to make it secure, we would need two requests and authorization such that one request (including facts) is only allowed for the game master, and one request (excluding facts) is accessible to the student. the authorization would work based on the player role.
even if it is not really critical here, I think it would be worth it to do it the right way so that we have 1) a good example for how it should be done and 2) so that you have seen how it works for all of the other game elements where it is more critical to authorize
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.
ah yes, I see what you mean - good point :D!
I took a look and modified it to the best of my knowledge -> I basically check with the useSession hook who is authenticated and based on that I load the corresponding graphql doc.
Changing the variable (in the new case) isAdmin, should not be possible, right?
Please have a look and let me know if it's aligning with your description