❔ ✅ Need help to reuse RequireAuthorization() method on a different project
I was wondering if since I have project A project as the main project to have the login/register endpoints and I create a second project where I just use the RequireAuthorization() method on my endpoints, would the second project endpoints work if i supply a token from the first project? I'm trying to avoid needing to call httpclient to check if the token is valid.
Im using dotnet 8, EFCore, IdentityServer and postgres. I basically followed this video from Nick Chapsas https://www.youtube.com/watch?v=sZnu-TyaGNk&t=302s and was wondering if I can't have the RequireAuthorization method on my endpoints from my second project?
Nick Chapsas
YouTube
The .NET 8 Auth Changes You Must Know About!
Use code DDD20 and get 20% off the brand new Domain-Driven Design course on Dometrain: https://dometrain.com/course/getting-started-domain-driven-design-ddd
Become a Patreon and get source code access: https://www.patreon.com/nickchapsas
Hello, everybody, I'm Nick, and in this video, I will show you how Authentication and Identity have changed...
27 Replies
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
am I forced to build the identity server section into every project?
When i pass the token in the header to WebApiB that is running then it still says unauthorized but when I use that same token on WebApiA then it works
all I want to be able to do is login to WebApiA and get my token which works. Using that token on any endpoint on WebApiA works perfectly but doesn't work in WebApiB. Is there no possible way to achieve this?
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
yes that's all I want
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
then how would I go about authorizing separates projects?
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
from WebApiB?
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
so I have to make an httpclient call from WebApiB to be authenticated by WebApiA?
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
How would WebApiB be able to verify a token? I know how to pass it as a bearer token in a api request but, Im confused at the logic how would WebApiB know to check this token?
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
Its not JWT, this is what it looks like
as you see in the txt file I sent, a lot is done behind the scenes on dotnet 8 with identity
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
so both WebApi projects would need like shared config?
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
oh! that's possibly why my token works in WebApiA and not WebApiB, because the audience and configs are different
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
Then I'll switch to JWT like this
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
Thanks!
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
I appreciate your help. I think moving over to jwt will be a start is right direction
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.
Was this issue resolved? If so, run /close
- otherwise I will mark this as stale and this post will be archived until there is new activity.