IdentityServer4.Demo | OpenID Connect and OAuth | Authentication library
kandi X-RAY | IdentityServer4.Demo Summary
kandi X-RAY | IdentityServer4.Demo Summary
OpenID Connect and OAuth 2.0 Framework for ASP.NET Core(Samples)
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Default prefitter .
- Callback for when we re done
- Searches for single selector .
- Create animation animation .
- Creates a new group matcher .
- Main matcher function
- workaround for AJAX requests
- Creates a new matcher that matches the given tokens .
- Handle incoming responses
- Call the combinator function for each element
IdentityServer4.Demo Key Features
IdentityServer4.Demo Examples and Code Snippets
Community Discussions
Trending Discussions on IdentityServer4.Demo
QUESTION
I've been following the documentation for using IdentityServer4 with single-page-applications on ASP.NET-Core 3.1 and as such created a project via the dotnet new react -au Individual
command.
This creates a project which uses the Microsoft.AspNetCore.ApiAuthorization.IdentityServer
NuGet package.
So far it's been really great and it got token-based authentication for my ReactJS application working without any pain! From my ReactJS application, I can access the user information populated by the oidc-client npm package such as the username.
Also, calls to my Web APIs with the [Authorize]
attribute work as expected: only calls with a valid JWT access token in the request header have access to the API.
I'm now trying to access basic user information (specifically username) from within a GraphQL mutation resolver via an injected IHttpContextAccessor
but the only user information I can find are the following claims under IHttpContextAccessor.HttpContext.User
:
ANSWER
Answered 2020-Sep-14 at 15:55User information can be retrieved via the scoped UserManager
service which is set up by the project template. The users's claims contains "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"
(ClaimTypes.NameIdentifier
) whose value is the user identifier. UserManager<>.FindByIdAsync()
can then be used to retrieve the ApplicationUser
associated with the user and which contains additional user information.
Note that this contacts the user store each time it's invoked. A better solution would be to have the extra user information in the claims.
First, explicitly add the IHttpContextAccessor
service if you haven't already by calling services.AddHttpContextAccessor();
From within an arbitrary singleton service:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install IdentityServer4.Demo
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page