dotnetcore-webapp | dotnet new webapp | Web Site library
kandi X-RAY | dotnetcore-webapp Summary
kandi X-RAY | dotnetcore-webapp Summary
dotnet new webapp
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of dotnetcore-webapp
dotnetcore-webapp Key Features
dotnetcore-webapp Examples and Code Snippets
Community Discussions
Trending Discussions on dotnetcore-webapp
QUESTION
Could anyone provide some insight or new links on using Azure B2C with MVC, .NET Core 3.1. Most examples are based on Core 2.2
However, it seems more than a few things are done differently with 3.1.
The error I encounter in 2.2 is:
...System.ArgumentNullException: Value cannot be null. (Parameter 'uriString') at System.Uri..ctor(String uriString) at Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COpenIdConnectOptionsConfiguration.BuildAuthority(AzureADB2COptions AzureADB2COptions) at Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COpenIdConnectOptionsConfiguration.Configure(String name, OpenIdConnectOptions options) at Microsoft.Extensions.Options.OptionsFactory
1.Create(String name) at Microsoft.Extensions.Options.OptionsMonitor
1.<>c__DisplayClass11_0.b__0() at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy
1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy1.CreateValue() at System.Lazy
1.get_Value() at Microsoft.Extensions.Options.OptionsCache1.GetOrAdd(String name, Func
1 createOptions) at Microsoft.Extensions.Options.OptionsMonitor1.Get(String name) at Microsoft.AspNetCore.Authentication.AuthenticationHandler
1.InitializeAsync(AuthenticationScheme scheme, HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationHandlerProvider.GetHandlerAsync(HttpContext context, String authenticationScheme) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
ANSWER
Answered 2020-Apr-07 at 02:20If you want to configure Azure AD B2C auth for your .net core application, you can use sdk Microsoft.AspNetCore.Authentication.AzureADB2C.UI
. But please note that you need to choose the right sdk version according to the .net core version you use. For example, if you use .net core 2.2, the sdk version should be 2.2.0.
The detailed steps are as below
Implement Azure AD B2C auth in web application
a. add the following settings in the appsettings.json
QUESTION
I have a 2 application using a single AD B2C
tenant. I want to logout the user from both websites when the user signs out to either one of them. I'm using email for local accounts.
In AAD
, there is a LogoutUrl
registered on each application which receives a GET
request to users currently signed in to. Source
I wonder if there is workaround for AD B2C
like in AAD
.
PS: I am using this repo as reference.
...ANSWER
Answered 2019-Jun-03 at 14:16Azure AD B2C doesn't support Single Log Out and we weren't able to find a workaround.
I've understood that in B2C scenarios Microsoft has assumed that IdPs are "social-media" type and considered it is not of end-users interest to be logged out of Facebook when they log out of some service to which they've authenticated via Twitter. Makes sense in that scenario.
However, in government-provided IdP scenarios it is usually a hard requirement to be able to support SLO.
We considered it to be more of a limitation by-design in B2C than technical, so we moved to using another authentication service provider that supports SLO. Apparently a wise choice as I haven't at least heard anything regarding SLO and Azure B2C as of today.
QUESTION
I have a aps.net core mvc app connected to Azure AD B2C (here is a example I use). When I run the up on my local laptop it runs fine Return URL: https://localhost:44316/signin-oidc But when I publish the app to azure web app plan it not works. With the return URL https:// https://myapp.azurewebsites.net/signin-oidc I become an HTML 404 error when I try to login. With the url: https://myapp.azurewebsites.net/ it goes back to my application without any login.
...ANSWER
Answered 2019-Feb-11 at 09:07I was getting the same error when my reply URL in application was http://localhost:port/signin-oidc . I have corrected the app.setting with the callback path to and published :-
QUESTION
I'm trying to set up my asp.net core with a web app. But I am running into errors. I did some googling and found possible solutions like
[documentation on making an ASP.NET Core web app with Azure AD B2C] (https://azure.microsoft.com/de-de/resources/samples/active-directory-b2c-dotnetcore-webapp/) and this .NETCore B2C sample
In the solution for the sample, the appsettings.json
file also has the Api.
ANSWER
Answered 2019-Feb-06 at 00:27I would recommend reading through the ReadMe on the .NetCore webapp sample, and running the sample as-is first.
Then, follow the [OPTIONAL]
steps, which explain how the sample works and how to set it up using your own B2C tenant and policies. The sample calls an API "https://fabrikamb2chello.azurewebsites.net/hello"
, so here you'd need to register your own Web API with B2C so you can define the scopes that you will request access tokens for.
Then you will replace your app coordinates with the ones in the sample (ex. Tenant, ClientId, Policies, ClientSecret, ApiUrl, and ApiScopes). Finally, you should be able to rebuild and run the solution.
QUESTION
I have an ASP.NET MVC Core 2.2 application, that integrates with an Azure AD B2C to authenticate users. I can sign in correctly, and the user is authenticated.
I also have created an ASP.NET Core Web API which is also integrated with the Azure B2C AD, and the goal is to call that web api from an ASP.NET MVC controller action method.
So I added the following test code in the controller of the MVC site:
...ANSWER
Answered 2019-Jan-24 at 06:37Firstly , you need to asking for the scopes you need for accessing your api when invoke AcquireTokenSilentAsync
QUESTION
I've followed AzureAD aspnetcore sample as closely as possible to try and implement Azure AD authentication in our aspnetcore 2.2 webapp. I am able to login successfully using Azure AD. However, the user's name is not being displayed AFTER login.
https://github.com/Azure-Samples/active-directory-b2c-dotnetcore-webapp
This value should be read in the view from the User.Identity.Name property.
On further inspection, I can see that the principal claims are being correctly returned to the application. However, for some reason the HttpContext.User object is not correctly populated. I don't know why this is happening. When I look at the same value from the sample above, HttpContext is correctly set. For clarification, I have implemented OnSecurityTokenValidated handler and I use this context:
As can be seen, userPrincipal has the claims as expected.
However, the httpContext has no claims. Also User.Identity.Name therefore is null:
I've tried to carry out a manual signin, but that doesn't work either:
...ANSWER
Answered 2019-Jan-31 at 06:31Do you set the NameClaimType
in OpenIdConnectOptions
configuration:
QUESTION
var scope = AzureAdB2COptions.ApiScopes.Split(' ');
string signedInUserID = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
TokenCache userTokenCache = new MSALSessionCache(signedInUserID, this.HttpContext).GetMsalCacheInstance();
ConfidentialClientApplication cca = new ConfidentialClientApplication(AzureAdB2COptions.ClientId, AzureAdB2COptions.Authority, AzureAdB2COptions.RedirectUri, new ClientCredential(AzureAdB2COptions.ClientSecret), userTokenCache, null);
AuthenticationResult result = await cca.AcquireTokenSilentAsync(scope, cca.Users.FirstOrDefault(), AzureAdB2COptions.Authority, false);
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, AzureAdB2COptions.ApiUrl);
// Add token to the Authorization header and make the request
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);
HttpResponseMessage response = await client.SendAsync(request);
...ANSWER
Answered 2019-Jan-27 at 19:15There were several changes made between MSALv1 and v2. Here is the blog post which details the differences between the two. As noted in the error messages, the types that had fields or properties of type IUser
now reference IAccount
. And ClientApplicationBase.Users
becomes GetAccountsAsync()
.
Depending on your code, you'd need something like this:
QUESTION
I am trying to implement Azure AD B2C for an AspNet Core 2.1 website. I'm not having any luck finding a good example with source code.
I did find https://github.com/Azure-Samples/active-directory-b2c-dotnetcore-webapp/tree/master/WebApp-OpenIDConnect-DotNet, which might be a starting point, but given my current limited understanding of the various APIs it's not too helpful. For example, the properties in the AspNet Core 2.1 class AzureADB2COptions don't map all that well to the properties in the example's AzureAdB2COptions class, even though it looks like instances of both objects serve the same purpose in configuring the interaction with Azure's AD B2C system.
Has anyone come across some good examples they could pass along?
...ANSWER
Answered 2018-Sep-25 at 04:55I've created a code sample at GitHub for an ASP.NET Core 2.1 web application that authenticates an end user against Azure AD B2C using the ASP.NET Core 2.1 authentication middleware for Azure AD B2C, acquires an access token using MSAL.NET, and accesses a web API using this access token.
QUESTION
I would like to understand the authentication process for Azure B2C. It is my understanding that up to 50k authentication per months are free and you pay more if it goes over 50k.
I am developing two applications. One for front-end and another for back-end that will use Azure B2C to authenticate users.
Here is my scenario.
- Users will go to UI portal to login with their social accounts.
- Users can access back-end resources by making API call based on their permissions.
So it is my understanding that when you login to UI using your social account you receive an access token, which is one authentication in B2C. If they want to access back-end resources from API, it requires you to acquire access token by making another request as shown here. Below is the example code that acquires token silently.
...ANSWER
Answered 2018-Jun-17 at 09:01After your web application handles the authentication response, the ConfidentialClientApplication.AcquireTokenByAuthorizationCodeAsync
method retrieves the access token from Azure AD B2C and then writes it to a token cache, which is implemented by the MSALSessionCache
class.
Before your web application invokes your web API, the ConfidentialClientApplication.AcquireTokenSilentAsync
method reads the existing access token from the token cache and only requests a new access token from Azure AD B2C if:
- The access token doesn't exist in the token cache;
- It is about to expire; or
- It has expired.
If the existing access token is read from the token cache, then you aren't charged for the issued token.
If a new access token is requested from Azure AD B2C, then you are charged for the issued token.
QUESTION
Is there a tutorial or setup guide for setting up Azure AD B2C in .Net Core? The sample code provided by the official documentation is very outdated and doesn't have much explanation.
...ANSWER
Answered 2018-Feb-15 at 20:08There is not mutch you have to configure on your ASP.NET core application. The main part (beside configure your AAD B2C) is to add / set the authentication middleware to use jwt bearer and pass your tenant / policy to it.
Example configuration (taken from the tutorial):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install dotnetcore-webapp
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