active-directory-dotnet-webapp-webapi-openidconnect | NET 4.5 MVC web app that signs Azure AD users | OAuth library

 by   Azure-Samples C# Version: 87104 License: No License

kandi X-RAY | active-directory-dotnet-webapp-webapi-openidconnect Summary

kandi X-RAY | active-directory-dotnet-webapp-webapi-openidconnect Summary

active-directory-dotnet-webapp-webapi-openidconnect is a C# library typically used in Security, OAuth applications. active-directory-dotnet-webapp-webapi-openidconnect has no vulnerabilities and it has low support. However active-directory-dotnet-webapp-webapi-openidconnect has 13 bugs. You can download it from GitHub.

A .NET 4.5 MVC web app that signs Azure AD users in with OpenID Connect and calls a web api using OAuth 2.0 access tokens.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              active-directory-dotnet-webapp-webapi-openidconnect has a low active ecosystem.
              It has 84 star(s) with 68 fork(s). There are 77 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 0 open issues and 25 have been closed. On average issues are closed in 374 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of active-directory-dotnet-webapp-webapi-openidconnect is 87104

            kandi-Quality Quality

              active-directory-dotnet-webapp-webapi-openidconnect has 13 bugs (0 blocker, 0 critical, 5 major, 8 minor) and 0 code smells.

            kandi-Security Security

              active-directory-dotnet-webapp-webapi-openidconnect has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              active-directory-dotnet-webapp-webapi-openidconnect code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              active-directory-dotnet-webapp-webapi-openidconnect does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              active-directory-dotnet-webapp-webapi-openidconnect releases are available to install and integrate.
              active-directory-dotnet-webapp-webapi-openidconnect saves you 6898 person hours of effort in developing the same functionality from scratch.
              It has 14298 lines of code, 0 functions and 113 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of active-directory-dotnet-webapp-webapi-openidconnect
            Get all kandi verified functions for this library.

            active-directory-dotnet-webapp-webapi-openidconnect Key Features

            No Key Features are available at this moment for active-directory-dotnet-webapp-webapi-openidconnect.

            active-directory-dotnet-webapp-webapi-openidconnect Examples and Code Snippets

            No Code Snippets are available at this moment for active-directory-dotnet-webapp-webapi-openidconnect.

            Community Discussions

            QUESTION

            IDX20803: Unable to obtain configuration from
            Asked 2019-Nov-21 at 02:23

            I know this question has been answered, but I don't understand what people exactly do (about certificates, ssl) and they all use a localhost but not me.

            I used this sample as my example OpenIdConnect

            I'm using:

            • A web app
            • A web API

            Both are using .Net Core 2.1. The Web App is using the Azure AD connection to get a JwtBearer token, that is sent to the API.

            Seeing the route /api/information in the API, a request is sent from the Web App to the API, and the API is returning the error above.

            The exact error is:

            ...

            ANSWER

            Answered 2018-Jun-07 at 14:44

            Solved it by replacing, in appsettings.json :

            Source https://stackoverflow.com/questions/50742248

            QUESTION

            Why do I need two AAD applications just to add roles into an access token?
            Asked 2019-Oct-28 at 19:00

            As shown by many samples I have two AAD application registrations, one for my javascript-based front end, and one for my JSON-only web APIs.

            If I fully trust my client AAD application, why does AAD require me to create a second AAD application for my web APIs?

            For example, assuming I add specific roles to my client AAD application, if client signs in with AAD and gets an id token and access token containing my roles, it only needs to send the access token to my APIs. The API only needs to crack the JWT, validate the audience, issuer, tenant, roles permissions, and signature. In this world, no client secret is needed in the web APIs, a second AAD application registration not needed, and still no call to AAD from my APIs. Unfortunately, without two AAD applications, I cannot figure out a way to have AAD include roles into my access token.

            If I didn't fully trust the issuer from mucking with claims, I can see why I would need two AAD applications and a client secret. But since I do trust my AAD application and the signature of the JWT, why the extra complexity? Or maybe there is a way to do this that I haven't found?

            Thanks!

            Responding to Marc here because just not enough characters in the comments field -- The sample you referenced is an excellent sample, specifically the JavaScript one calling the Web API. It is what I am doing right now in fact. However, the problem is that Web API in the sample is open to anybody who has authenticated on the tenant. I need to secure the Web API down to certain individuals in the tenant, and simply checking the client/app id is not sufficient as anybody who can create an AAD app can fake it.

            So what I need to do is have roles added to the the access token so I know that my application authenticated the user, and that user has been granted the required roles. For example, here is a Microsoft sample. And even here a Microsoft video walking through the process.

            If I don't have two AAD applications w/client secret, the roles claims is never provided in the access token. It is always provided in the id token, but not the access token.

            I feel like I am missing something obvious here. If AAD would just put the roles I requested into the JWT when I authenticated against it, and I validated its signature, audience, issuer, and roles, I wouldn't need any of this extra complexity?

            ...

            ANSWER

            Answered 2019-Oct-25 at 20:14

            Can you provide a link showing that two apps are needed? That should only be the case if the API you want to call is not provided by the web app which served the JS to the browser. None of the 'official' samples require you to register two apps (Graph API, used in some of these samples is a separate API and it is already registered). A problem with tokens passed from the browser is that they were acquired by a public client, not using any secrets apart from user creds. Therefore, they are easier to steal and re-use. Your own back-end app may want to use a secret to get its own token (extension grant) to call yet another API using a token that does not reside in a public client.

            Source https://stackoverflow.com/questions/58555350

            QUESTION

            IIS Reverse Proxy with OpenIdConnect going to wrong Identity provider
            Asked 2019-May-23 at 06:26

            OpenIdConnect (Azure) Settings

            ...

            ANSWER

            Answered 2019-May-23 at 06:26

            What is causing this? I mean, obviously the reverse proxy, but how do I fix it without removing the reverse proxy?

            As far as I know, if you use url rewirte rule in the web.config, it will rewrite all the request to the https://my.domain.com/ domain which is include the login.microsoftonline.com.

            I suggest you could write a new rule which is used to match the /oauth2 request url to directly rediret to the login.microsoftonline.com instead of the https://my.domain.com/. Then it will work well.

            More details, you could refer to below url rewrite rule.

            Source https://stackoverflow.com/questions/56264381

            QUESTION

            How to access web api from another web app which is in same Azure AD?
            Asked 2018-Oct-11 at 20:41

            I have hosted one web api ProductInfo on azure and register that application into Azure AD.

            I have another web app UIProduct and this web app want to access the web api ProductInfo both are in same Domain and same Azure AD.

            How can I access web api ProductInfo from web app UIProduct ? is there any token I need to generate again ?

            any sample code will be helpful. code sample taken from this link

            After successfully login i'm at Home page then i click on about page where i write this

            ...

            ANSWER

            Answered 2018-Oct-09 at 19:13

            You'll want to go register both apps in the Azure portal both as Web Apps/APIs.

            Then in your Web API, set a App ID URI as well as create any scopes you'd like to expose. If this is the only client you'll be using, you may be able to just have an Access scope, but bear in mind this is what end users will see when consenting to your app.

            In your web app, you'll then be able to set a Required Permissions for this new web API and scope. This indicates that the client should require consent for this web API and can be granted access tokens for it.

            This code sample covers this exact scenario.

            The web API basics doc also covers some conceptual info related to this scenario

            Source https://stackoverflow.com/questions/52727641

            QUESTION

            Web Application and API AzureAD authentication flow ASP.NET Core
            Asked 2018-Aug-10 at 04:59

            I'm currently confused about how to realize the authentication / authorization flow.

            I'm developing two applications, the one is the frontend/Webapplication and the other the backend/API, both with ASP.NET Core. The goal is to use the AzureAD and use the users/groups from the domain. The authentication I already implemented on both applications and I'm able to login and restrict content based on the login state.

            As reference I took this example from a microsoft developer. There should be exactly this what I want to do. There is a WebApp and API. The used authentication flow is the authorization code flow. First the user needs to login and after that when some data needs to be requested from the API, an access token will be requested.

            Question 1: Is this the right authentication flow? For me this seems like a doubled authentication, because first I authenticate myself at the frontend and when the Webapp needs some data I need to authenticate myself again at the backend. The same Azure AD tenant is used, so what do you think here?

            The next point what seems very "ugly" is the procedure getting some data. In the example when some data is requested first the token will be requested and after this the data. But in my opinion with a lot of boilerplate. The example code below is needed for just one request of all ToDo items.

            ...

            ANSWER

            Answered 2018-Aug-10 at 04:59

            I found a proper solution to solve this.

            I just used the approach from this example here multitenant-saas-guidance and it works like charm.

            Source https://stackoverflow.com/questions/51719944

            QUESTION

            OpenIdConnectAuthenticationNotifications.AuthorizationCodeReceived event not invoked for Azure WebApp Secured by Azure Active Directory
            Asked 2018-Feb-26 at 21:41

            My MVC WebApp is deployed to Azure Paas and secured using Azure AD. The authentication setup uses the sample code below as its base and it is working in localhost with either IISExpress or IIS.

            https://github.com/Azure-Samples/active-directory-dotnet-webapp-webapi-openidconnect

            But it is not working after deployment to Azure. Even though the user will authenticate properly, the AuthorizationCodeReceived delegate is never invoked.

            This is start up code that setup the authentication:

            ...

            ANSWER

            Answered 2017-Jun-13 at 07:01

            According to reply url : https://albatrossweb.azurewebsites.net/.auth/login/aad/callback/ , it seems you enabled "Authentication / Authorization" feature of azure app service. and i could reproduce that if i enabled "Authentication / Authorization" feature , in that scenario easy authentication will take over the authentication process . If you enabled "Authentication / Authorization" of app service , please try to disable that and try again .

            Source https://stackoverflow.com/questions/44509409

            QUESTION

            Using an AutoRest C# client to access a Web API with a bearer token - TokenCredentials does not work
            Asked 2017-Oct-24 at 13:02

            EDIT 10/24 I think this was all likely user error - see my answer below for remedy before getting too deep into this question

            TL;DR: For my OAuth 2.0 code flow...

            Why does my TokenCredentials not work with my AutoRest client? I'm getting NO bearer token applied to the request / no Authorization header set

            I know my pipeline works already..

            Using code from this azure sample, which is NOT an AutoRest client, I can successfully get my access_token and can get JSON from my protected Web API project.. so I've ruled out all the prerequisite stuff.. I know my pipeline works

            My AutoRest setup..

            1.) Downloaded from GitHub this AutoRest repo v1.1.0

            2.) Downloaded my swagger JSON to disk, saved as swagger.json

            3.) Ran this command-line to generate C# files:

            autorest --input-file=swagger.json --csharp --output-folder=MyCorp_ApiClient_Tsl --namespace='MyCorp.ApiClient' --add-credentials

            4.) Copied generated classes into my .NET 4.6.2 web site

            5.) These are my NuGets:

            ...

            ANSWER

            Answered 2017-Jul-17 at 13:22

            While I believe I ran my autorest command with --add-credentials it's possible I may have used the older syntax... --AddCredentials true

            I also did not run autorest --reset as the docs recommend you do

            One of these is the culprit, because now my 1.1.0 autorest installation is generating everything correctly.

            Source https://stackoverflow.com/questions/45038533

            QUESTION

            HttpContext.Current is null on TokenCache.BeforeAccess
            Asked 2017-Sep-02 at 11:28

            I am testing a webproject using OWIN and OpenID Connect against Azure AD. I am using much of the code from this sample: https://github.com/Azure-Samples/active-directory-dotnet-webapp-webapi-openidconnect

            I have an issue where i get a null exception on line 27 of this file: https://github.com/Azure-Samples/active-directory-dotnet-webapp-webapi-openidconnect/blob/master/TodoListWebApp/Utils/NaiveSessionCache.cs

            I get the exception because HttpContext.Current is null.

            I can see that Load() is called from BeforeAccessNotification().

            My framework version is 4.5.2 and i have in my web.config.

            Why is HttpContext.Current null in this context?

            Updated:

            The only difference i have from the sample is that my ActionResult on my controller is not async. I call AcquireTokenSilentAsync in a async Task that is called with a .Wait() from a standard ActionResult. I am working within a CMS that does not allow me to use async ActionResults.

            This is OnAuthorizationCodeReceived:

            ...

            ANSWER

            Answered 2017-May-16 at 20:58

            I'm not sure if it's your case, but sometimes the root cause of HttpContext.Current null is a missing key in web.config:

            Source https://stackoverflow.com/questions/43908344

            QUESTION

            Connecting with EWS API service to outlook.com account with oAuth2 token
            Asked 2017-May-28 at 19:07

            I'm able to authenticate with live.com with my account on outlook.com at url

            ...

            ANSWER

            Answered 2017-May-28 at 18:52

            It seems like the retrieving of data with EWS Managed API is not supported with outlook.com accounts.

            you can read (in the yellow section) about it here and also here.

            Basically, there are 2 portals today that apps can be created with:

            1. Application Registration portal
            2. Azure management portal

            It states that for these reasons outlook.com accounts are not supported:

            1. New app registrations should be created and managed in the new Application Registration Portal to be compatible with Outlook.com. This means that if you have an app that was created thru Azure Management Portal it will not be supported with outlook.com and the token will not work with outlook.com accounts.

            2. Existing app registrations that were created in the the Azure Management Portal will continue to work for Office 365 only

            3. Also if you created your app with Application Registration Portal The REST API is currently enabled on all Office 365 accounts that have Exchange Online and only some Outlook.com accounts. this means it is not guaranteed to all outlook.com accounts because they haven't migrated all of them (yet).

            4. Microsoft accounts with Outlook.com mailboxes (including Outlook.com, Hotmail.com, Live.com, MSN.com, and Passport.com) are in the process of being upgraded to enable the REST APIs. During this process, making API calls to mailboxes that are not yet upgraded will return a MailboxNotEnabledForRESTAPI or MailboxNotSupportedForRESTAPI error code.

            Source https://stackoverflow.com/questions/44224954

            QUESTION

            HttpContext.Current is null after Azure AD authentication success
            Asked 2017-May-02 at 18:07

            Question: What could be causing HttpContext.Current to be null only sometimes?

            Question: Is HttpContext.Current initialized after PrincipalService.OnAzureAuthenticationSuccess is called? If so, why only sometiems?

            Description

            What happens is quite often a user will click sign-in and HttpContext.Current will be null causing the cookie to be never set. Which redirects them back to the home-page and since the cookie wasn't set they click sign-in again and again and again. Sometimes it'll decide to let the cookie be set after 2 or 3 clicks other times it won't do it without clearing cookies or logging out of another Azure AD account (e.g. Our sharepoint server uses Azure AD).

            These things seem so odd to me and I haven't been able to pin down what the cause is despite hours of research into it.

            Azure Config

            ...

            ANSWER

            Answered 2017-May-02 at 18:07

            Alright, so it turns out I was being a big dummy and doing things the hard way. I don't 100% fully understand why it was null but I did find a much simpler way around the issue.

            1. Started by removing the code related to me creating my own cookie (i.e. AuthorizationCodeReceived = PrincipalService.OnAzureAuthenticationSuccess).

            What happened was I realized that Azure AD was creating its own principal and cookie via the app.UseCookieAuthentication(new CookieAuthenticationOptions()); This realization happened thanks to the git hub project that Fei Xue linked.

            1. After that I switched my custom principal to create based on the 'built-in' cookie instead of the cookie I was creating (which was only getting created half of the time due to HttpContext.Current being null).

            Now that the custom principal creation wasn't dependent on HttpContext.Current I didn't have a sign-in loop happening at all because the principal and cookie both exist.

            Thanks a ton to Fei Xue!

            Source https://stackoverflow.com/questions/43725109

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install active-directory-dotnet-webapp-webapi-openidconnect

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries

            Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular OAuth Libraries

            satellizer

            by sahat

            cpprestsdk

            by microsoft

            oauth2-server

            by thephpleague

            scribejava

            by scribejava

            socialite

            by laravel

            Try Top Libraries by Azure-Samples

            azure-search-openai-demo

            by Azure-SamplesPython

            blockchain

            by Azure-SamplesHTML

            Cognitive-Speech-TTS

            by Azure-SamplesC#