Code Monkey home page Code Monkey logo

appmodelv2-webapp-openidconnect-dotnet's People

Contributors

aiwangmicrosoft avatar andretms avatar archieag avatar dependabot[bot] avatar dstrockis avatar geok avatar gsacavdm avatar jmprieur avatar rwike77 avatar shama-k avatar swizzy avatar tal32123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appmodelv2-webapp-openidconnect-dotnet's Issues

Writing to Session disrupts ASP.NET MVC OpenId SignIn

Trying to understand why writing to Session with OpenId Connect disrupts the Sign In process.

For example, if I modify HomeController the way below, the SignIn stops working; By SignIn, it will redirect you to Azure AD and return to the Index unauthenticated.

public ActionResult Index()
{
    Session["TEST"] = "TEST"; // Let's make a SignIn disruption
    return View();
}

Removing the code during debug will not rectify the process, only if you restart the app.
Any solution or workaround?

Authorization Code Flow

We need to use Authorization Code Flow for existing ASP.Net Web Forms Application. We were trying to follow this sample.

This sample is using ResponseType - OpenIdConnectResponseType.CodeIdToken.

We were assuming that for using Authorization Code Flow, we need to use ResponseType Code, not CodeIdToken.

But if we change ResponseType to Code in UseOpenIdConnectAuthentication, we get following error:

AADSTS9002313: Invalid request. Request is malformed or invalid.
Trace ID: 9bdf8e16-5395-4358-a21f-890631a05b00
Correlation ID: 7938070f-2b7b-4a17-898e-96184c770153
Timestamp: 2021-03-23 20:22:05Z

Also, In App Registration screen on Azure Portal, We have to select Access Tokens. I think that is not recommended for ASP.Net Web applications.

image

But If we deselect Access Tokens Option (as we don't want to use Implicit Flow), we get following error:

OpenIdConnectMessage.Error was not null, indicating an error. Error: 'unauthorized_client'. Error_Description (may be empty): 'AADB2C90057: The provided application is not configured to allow the 'OAuth' Implicit flow.
Correlation ID: c9279b25-8857-414f-bf61-6e6ffcb10f5d
Timestamp: 2021-03-24 07:39:29Z
'. Error_Uri (may be empty): 'error_uri is null'.

Please suggest if we are missing some settings or configurations.

The nonce cannot be validated issue occurred

Hi,
We have received the below error while running this source.

Error: IDX21323: RequireNonce is 'System.Boolean'. OpenIdConnectProtocolValidationContext.Nonce was null, OpenIdConnectProtocol.ValidatedIdToken.Payload.Nonce was not null. The nonce cannot be validated. If you don't need to check the nonce, set OpenIdConnectProtocolValidator.RequireNonce to 'false'. Note if a 'nonce' is found it will be evaluated.

Kindly let us know if anything to be added in startup.cs page.

Thank you in advance.

What Whitelist URLs to run behind corporate proxy?

My production server is behind revert proxy. I'm already whitelisted login.microsoftonline.com:443.It redirect to MS login page but cannot login.
I've checked the firewall, show that some IP did not match. What URLs do I have to whitelist more?

Request: Change sample to use the OIDC 'authorization code flow' instead of the less secure 'implicit flow'.

Hi. This demo is currently using the OIDC 'implicit flow', which is no longer recommended by the IETF. As such it would be good to get the demo changed to use the OIDC 'Authorization code flow' instead.

From:

https://oauth.net/2/grant-types/implicit/

The Implicit flow was a simplified OAuth flow previously recommended for native apps and JavaScript apps where the access token was returned immediately without an extra authorization code exchange step.

It is not recommended to use the implicit flow (and some servers prohibit this flow entirely) due to the inherent risks of returning access tokens in an HTTP redirect without any confirmation that it has been received by the client.

Public clients such as native apps and JavaScript apps should now use the authorization code flow with the PKCE extension instead.

The OAuth 2.0 Security Best Current Practice document recommends against using the Implicit flow entirely, and OAuth 2.0 for Browser-Based Apps describes the technique of using the authorization code flow with PKCE instead.

That is, the 'implicit flow' was designed to be used by client side (i.e. browser) single page apps (SPAs) that are hosted on a lightweight/dumb web server, i.e. hosting the app as static content only.

In the ASP.NET integration with OIDC, the server takes part in the authorization flow, and can therefore implement the more secure 'authorization code flow'. See:

https://oauth.net/2/grant-types/authorization-code/

In this mode, the identity provider (IdP) returns a simple 'authorization code' to the browser (instead of an access token), the browser passes this to the ASP.NET server, which then redeems it for an access token - in this final step the server supplies a client secret known only to the server and IdP, thus adding an extra level of security.

Here is a demo app that appears to be using authorization code flow:

E.g. in Startup.cs it does:

  ResponseType = OpenIdConnectResponseType.CodeIdToken,

Instead of

  ResponseType = OpenIdConnectResponseType.IdToken,

Unable to sign in, error: Application with identifier 'Enter_the_Application_Id_here' was not found in the directory 'abc '.

AADSTS700016: Application with identifier 'Enter_the_Application_Id_here' was not found in the directory 'abc '. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant.

downloaded sample code and added tenant and client id in configuration and cross checked consented with AD admin user as well, all seems correct according to documentation but still getting this error.

unable to sign in with Microsoft personal account

Compiled, configured, and ran sample. Trying to sign in with a Microsoft (personal) Account and the flow ends up in this error from login.live.com:
error=unsupported_response_type
error_description=The provided value for the input parameter 'response_type' is not allowed for this client. Expected value is 'code'.

It seems like the OpenID Connect flow isn't supported for Microsofts (personal) accounts?

Use which library to configure aad auth in startup.cs?

I see using Microsoft.Owin.Security.OpenIdConnect configure AAD auth in readme.
image

but in the real startup.cs it using Microsoft.Identity.Web library:
image

I'm wondering which library should I use in .net framework? I need to integrate with Graph API also.

The commit on April 16, 2023 blew up the repo

The commit on April 16, 2023 blew up the repo. The instant indication was that all of the authentication config values in web.config (ClientId, Tenant, etc.) disappear in this checkin and an anomalous appsettings.json appears. The most current release does not work. The commit comments also begin to talk about Graph, which was not needed or mentioned in the app prior to April 16. I did see that some of the intermediate readme files after April 16 seem to be talking about the changes, but the current readme does not mention it. Reverting to the release before April 16 works fine.

Maybe it got mixed up with https://github.com/Azure-Samples/ms-identity-aspnet-webapp-openidconnect that does specifically talk about using Graph?

Azure AD B2C

Hello there,

is this sample compatible with Azure AD B2C ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.