Request ifAuthenticatedInRole error #148
Unanswered
aghoughton
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Apologies if I'm missing something, am trying out the framework for the first time and running into an authentication issue.
Relevant points:
Everything appears to work fine until I try to request authentication for an endpoint when not logged in.
Endpoint handler:
However when it calls the 'ifAuthenticatedInRole' method I get a NullReferenceException
Request.fs
When the match is performed authenticateResult has a Succeeded value of false (as expected because I'm not logged in) but the isInRole function is still called. Given the authentication did not succeed the authenticateResult.Principal is null hence causing an error.
It seems the ifAuthenticatedWithScope function verifies whether the authenticationResult has succeeded before trying to access the authenticateResult.Principal. I'm wondering whether ifAuthenticatedInRole should be doing the same thing.
Suggested change to ifAuthenticatedInRole:
Hopefully I'm not missing something obvious
Beta Was this translation helpful? Give feedback.
All reactions