question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamic CB Not Firing When Hit By Differently Scoped User

See original GitHub issue

Dev setup:

  • graphql-auth version: version “0.2.0”
  • node version: v6.11.1

I am using graphql-auth with:

  • hapi
  • express
  • koa
  • other:

What you did:

I have an endpoint that is using the dynamic scope cb to change the scoped based on the params.

	Mutation: {
		sendMessage: withAuth(
			(obj, { input }, context) => {
				console.log('params input: ', input)
				return input.A ? ["scope:A"] : ["scope:B"];
			}, 
			async (
				obj,
				{ input },
				context
			) => {...code}

I log in to my app as User A with scope A I hit the above mutation I see the console log I receive the correct result I log out I log in to my app as User B with scope B I hit the above mutation I do not see a console log I get a permission denied error I terminate the server process I start the server process (I am still logged in with B from the previous session) I hit the above mutation I see the console log I receive the correct result I log out (with User B) I log in to my app as User A with scope A I hit the above mutation I do not see a console log I get a permission denied error

What happened:

In my context creation function, the one that puts auth on the context, I can see that the correct scopes are being applied. However, I believe the error has something to do with the dynamic cb being cached or not executed again (because I do not see the console log)

AuthorizationError: Permission Denied!
    at AuthorizationError (/Users/test/workspace/petigree/code/node_modules/graphql-auth/index.js:11:5)
    at /Users/test/workspace/petigree/code/node_modules/graphql-auth/index.js:51:14
    at next (native)
    at step (/Users/test/workspace/petigree/code/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/test/workspace/petigree/code/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at Promise.F (/Users/test/workspace/petigree/code/node_modules/core-js/library/modules/_export.js:35:28)
    at /Users/test/workspace/petigree/code/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12
    at /Users/test/workspace/petigree/code/node_modules/graphql-auth/index.js:35:3
    at /Users/test/workspace/petigree/code/node_modules/graphql-tools/src/schemaGenerator.ts:536:22
    at resolveFieldValueOrError (/Users/test/workspace/petigree/code/node_modules/graphql/execution/execute.js:498:12)
    at resolveField (/Users/test/workspace/petigree/code/node_modules/graphql/execution/execute.js:462:16)
    at /Users/test/workspace/petigree/code/node_modules/graphql/execution/execute.js:284:20
    at process._tickCallback (internal/process/next_tick.js:109:7)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
dcurletticommented, Apr 11, 2018

puts that requiredScope function at the end of the event loop, thereby freeing other functions to run before it gets called.

I’m assuming it is to protect against anyone doing a DB call, or any other long-running function, in their auth scope function.

1reaction
dcurletticommented, Apr 11, 2018

@BipinBhandari nice- I did the same as you, expect i only moved where the variable was being defined.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can ES6 template literals be substituted at runtime (or reused)?
To make these literals work like other template engines there needs to be an intermediary form. The best way to do this is...
Read more >
Dynamic capillary stalls in reperfused ischemic penumbra ...
After recanalization, there was no visible injury to the MCA, ... Dynamic capillary stalls increase in ischemic penumbra and persist after reperfusion.
Read more >
Use conditional formatting to highlight information
How to use conditional formatting in Excel to visually explore, analyze, and identify patterns and trends.
Read more >
6 Using Substitution Variables - Oracle Help Center
You can define variables, called substitution variables, for repeated use in a single script by using the SQL*Plus DEFINE command.
Read more >
VMware Carbon Black EDR User Guide
VMware Carbon Black EDR Server Configuration Guide (cb.conf) – Describes the ... Carbon Black EDR does not present a message on the affected...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found