Azure Active Directory and Federated Authentication - azure

We're using Azure Active Directory with Federated Authentication. This is working without a problem - but we need the ability to have users sign in with credentials other than their logged in Windows credentials.
What happens right now is
User navigates to our web app and the Azure ADAL for JavaScript attempts to log in
The user is redirected to https://login.microsoftonline.com/common/oauth2/authorize?response_type=id_token&client_id=xxxx&redirect_uri=xxxx&client-request-id=xxxx&x-client-SKU=Js&x-client-Ver=1.0.2&nonce=xxxx
The user is presented with a username and password box.
Upon entering the username (even if it is someone else's username) (as soon as focus is lost from the username textbox), the page shows
It looks like this email is used with more than one account from
Microsoft. Which one do you want to use? Work or school account Work
or school account Assigned by your work or school
Upon clicking "Work or school account", the user is presented with
Redirecting We're taking you to your organization's sign-in page.
The page redirects to the url
https://ds1.mydomain.com/adfs/ls/auth/integrated/?username=me%40mydomain.com&wa=wsignin1.0&wtrealm=urn%3afederation%3aMicrosoftOnline&wctx=estsredirect%3d2%26estsrequest%xxxxx&popupui=1
The user is automatically logged in using their active Windows credentials (even if they entered a different username on the previous page).
If I navigate to the URL https://ds1.mydomain.com/adfs/ls/auth/integrated/?username=me%40mydomain.com&wa=wsignin1.0&wtrealm=urn%3afederation%3aMicrosoftOnline&wctx=estsredirect%3d2%26estsrequest%xxxxx&popupui=1 using a Windows session with a non-domain (local) account, I get a standard Integrated Authentication prompt
So - it seems like our ADFS server is using Integrated Windows Authentication on an IIS Website.
My question is - how can I allow the user to log in as a different domain user for the web app. Is there a special ADFS login URL I can use? And if so, how do I tell the Azure app to use that URL. Or is there a way to disable Integrated Authentication in some other way, on demand?
Thank you.
UPDATE:
I see that if I point the ADFS URL to the basic auth endpoint
https://ds1.mydomain.com/adfs/ls/auth/basic/?username=me%40mydomain.com&wa=wsignin1.0&wtrealm=urn%3afederation%3aMicrosoftOnline&wctx=estsredirect%3d2%26estsrequest%xxxxx&popupui=1
I am prompted for basic authentication (exactly what I want)...so how do I tell my Azure AD or Azure AD App what login URL to use? And how can I control it conditionally?

You would need to either remove AD FS from the Local Intranet zone on the relevant machines so they prompt, or better, look in to the User Agent based targeting in AD FS and configure those machines to send a User Agent that triggers Forms Based AuthN.
Have a look at https://technet.microsoft.com/en-us/library/dn727110.aspx for more info on this.

Answer is actually pretty simple (with some help from Fiddler):
Add &prompt=login to the query string generated by the ADAL JavaScript when redirecting to login.microsoftonline.com. This causes the MS portal to redirect to the ADFS Forms Auth URL instead of the one using integrated security.

Related

python3-saml and Azure AD - missing a point

Good afternoon experts,
I have a Django web application (it is not internet-facing) and so far I used the django.contrib.auth.backends.ModelBackend to authenticate the users.
However I want to integrate this webapp to an existing SSO solution (like Azure AD) so I thought python3-saml would be a good library to be used (more specifically I use python3-saml-django but it is just a wrapper around python3-saml).
Probably I am missing some fundamental point as I don't really understand how this should work.
When I used ModelBackend then I had a login form where the user could type their username+password which was checked against Django database and the authentication was completed. Should the same work with SSO too? i.e. the login form appears, the user will type their credentials but they will be checked in Azure AD instead of Django auth tables? Or the custom login form of that specific auth solution (in this case Azure AD -> Microsoft login form) should be displayed...?
The LOGIN_URL setting is configured in my Django app so if no user is logged in then automatically my login form appears.
Also I set the AUTHENTICATION_BACKENDS setting and it points only to django_saml.backends.SamlUserBAckend.
I configured AZure AD (registered the app and added a user, I tested it in Azure AD console) hopefully correctly. I also populated python3-saml's settings.json with login/logout URL, etc.
Whenever I try to log in with the Azure AD user I got an auth error (the user and password did).
I am just wondering if somebody could shed some light please how this should work? Can I debug the SAML requests / responses?
auth is token based in azure ad and it will redirect the user to the microsoft login. You will receive an auth token which then you can use to for authorization and providing secure pages.
First register your app in azure portal in azure active directory and also create a user flow.
Then download MSAL for python (using pip) which is used for auth using azure ad for python.
The basic architecture is that when the user tries to login the Microsoft login page will be shown, after signing in your app will receive a token which then you should use to show the logged in pages.
References:
quickstart for auth in python
userflow
MSAL Library

Azure AD B2C - Sign in page getting skipped

I created a new Azure AD B2C.
I created a new application.
Accounts in any identity provider or organizational directory (for authenticating users with user flows)
provided a redirect URL of my app (I also tried by giving external URL, https://jwt.ms)
Generated secret key and cerificates.
I enabled Implicit grant and hybrid flows.
I created a new user flow for signup and signin, run this flow from azure portal and it successfully runs and show token on https://jwt.ms.
I Cloned the sample app (WebApp-OpenIDConnect-DotNet), run it with default values which came in the sample app and everything works fine.
I Added my client id, instance, domain etc. settings to appsettings.json file.
When I run it, and click on login button, it generates the URL but it never takes me to the login page, instead it takes me to redirect url without any code or querystring in the URL.
I am expecting the azure AD B2C signin page to appear, and only after login , it will take me to the redirect URL.
Can you please guide me what I am missing here or let me know if more information is needed here ? I will try my best to provide as much information as possible.
As stated by Jas Suri, it was due to URI mistmatch. I checked in Chrome dev tool and found the issue.
Thanks for excellent community on stack overflow.

Azure AD Single Sign On

My company has developed a web-based application for internal and external use. The application is developed by angular + asp.net WebApi and authorised by OAuth. Users have to use the username and password given by us to login. The application works well. Recently, clients made a new request to login our system through Azure AD SSO. They want us to integrate their Azure AD.
Requirements:
On login page, there should be a new option for users to login our system by connecting to their Azure AD.
Alternatively, if their employees are connected to their system and then visit to our website, they will be automatically logged in our website without entering username and password.
I have no knownledge about Azure AD SSO and still get confused even I did some search on google. Can someone give me some advice or hints?
Using Msal with Angular you can implement the Azure AD SSO login. There are multiple code samples and microsoft documents available to achieve your requirement.
Please go through the documentation and code Sample.
In the Angular sample there is a function as mentioned below which verifies the user credentials if the user is already logged in or not.
checkoutAccount() {
this.loggedIn = !!this.authService.getAccount();
}

Bypass the Azure AD SSO "choose an account" prompt and automatically login cookie stored user?

We have configured our enterprise web application to be protected by Azure AD SSO. It works great. The first time the user navigates to the enterprise web application page, they are redirected to the https://login.microsoft.com login page and prompted to enter their username#company.com and then they are authenticated using the Windows credentials through Kerberos (or at least I think it's Kerberos. It doesn't require a password). They are now signed into our enterprise web application.
Now the user closes their browser, which closes the session with our enterprise application, then opens it again.
They go back to the enterprise web application page. It redirects to https://login.microsoft.com, and this time it remembers who they are, because it has the username#company.com in the "Choose an account" dialog. But it didn't automatically sign them in, making for a very unfriendly user experience.
The user now has to click on their account from the "Choose an account" screen, and there is always only just the 1 account there. It still doesn't require a password, but still it breaks the seamless flow of things.
How can we make the Azure AD SAML SSO set up so that it automatically logs in the user without having to click the account in the "Choose an account" dialog?
I wasn't getting response here so I cross-posted on MSDN (sorry). I got a prompt response here: https://social.msdn.microsoft.com/Forums/azure/en-US/f9e7c013-fbdc-4bbb-9e9c-22bf187f6c79/bypass-the-azure-ad-sso-8220choose-an-account8221-prompt-and-automatically-login-cookie-stored?forum=WindowsAzureAD
You have to pass the domain hint in order to achieve this. This
happening primarily because of realm discovery and domain hint will
help you skip this.
Ref:
https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/configure-authentication-for-federated-users-portal

Is it possible to remove the password field on the WAAD sign-in page when SSO is in use?

We have a Windows Azure Active Directory, configured with a custom domain, linked to an on-premise ADFS (2.0) server for federated authentication.
When I go to https://manage.windowsazure.net in a clean browser session, I'm prompted by https://login.microsoft.online.com for just an email address. This asks for Organizational vs. Microsoft account, and if I select Organizational, I'm redirected to our ADFS server - all good.
On the other hand, on our own ASP.NET MVC applications which use ADAL, the login page (again login.microsoftonline.com) shows both a username and password box. If you type a username, then focus on to the password box, you then get redirect at that point to ADFS.
This can be a rather confusing user experience - often you've started typing your password by the time the redirect happens, then hit enter, and of course get an authentication failure.
Possibly a better demonstration in this screen recording:
http://www.youtube.com/watch?v=hZYPltSmcn8&feature=youtu.be
Is there any way of using the username-only page rather than username + password, or better yet, skipping the WAAD page and redirecting straight to ADFS? (Since all users will be using that for SSO anyway.)
The Azure portal has the email-only screen mostly because it needs to disambiguate between Azure AD accounts (organizational accounts) and Microsoft accounts (personal accounts, formerly LiveIDs).
If you provide the email address as the login_hint parameter in the OAuth 2.0 authorization request, Azure AD will do the lookup to find out if it's a federated domain, and if so, immediately redirect to ADFS.
With ADAL, you can provide this using AuthenticationContext.AcquireToken(String, String, Uri, String) to specify loginHint:
AuthenticationResult authResult =
authContext.AquireToken(resource, clientId, returnUri, loginHint);
You will, however, have to build your own page to collect the email address.

Resources