Need help in Configuring access to Azure users to existing SSO - azure

Currently we are a Service Provider (SP) which is currently using SSO Authentication using OpenAM and we are using Spring security to achieve this.
We have a login interface where user enter user name and password and authentication happens.
Now we have a requirement to allow users from an external identity provider (Azure) to access the SP in addition to the existing Open AM SSO. We are trying to use SAML 2.0 to achieve this.
For this we changed the login interface, to accept the user name and based on the user name, we either provide the password option (for local users ) or redirect to the azure portal (for idp users) to authenticate the user.
As part of this requirement, we added a variable userType into httprequest cookie and try to redirect to the respective authentication provider. But we always get redirected to azure even though the user is a local one.
We have gone through many examples from github to implement this but no luck.
Any pointers on this would really be helpful.

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

Spring security support multiple authentication types

I need to support 3 way of authentication at the same time in the application: LDAP, Azure AD, Basic.
After few hours of googling i found that the best way to do it would be to implement 3 authentication providers and then register them with AuthenticationManagerBuilder. But the issue i stumbled into is, that i dont know how the make the Azure Ad provider. For LDAP i found an online example i can use, and based on the LDAP i could probably also make the Basic username and password provider, but havent found anything similar on Azure AD. All i have found is that, i need to add 2-3 dependencies to the project for the Azure AD and then it automagically works.
I dont understand spring security that much, so im stumped atm. Can i just trust the automagic to do everything correctly, or are there some resouces on how to create AzureADAuthenticationProvider i could use with AuthenticationManagerBuilder?
An authentication provider is an abstraction for accessing user information from LDAP, custom third-party source, database etc. it validates the user credentials.
Spring security with azure ad:
Firstly, azure ad is integrated with Spring security for secure your application.
User login through their credential and get validate by azure AD.
From azure graph API you have to access token and membership information.
Membership for role based authorization.
LDAP Authentication:
Unique LDAP or DN ,you can perform search in directory unless you know username to DNS is known in advance.
You can authenticate the user by binding that user.
Load the Number of authorities for the user.
Custom Authentication Provider:
Create own authentication (custom) with the help of authentication provider interface in which you can use
authenticate method and implementing it and make authentication object with username and password of user
Then after you can configure these authentication in spring security configuration.
Here is the Reference Link regarding Spring Security

How do I programmatically login or get the JWT token of a logged in Google user in Azure AD?

I already setup the Google Identity Provider in Azure Active Directory and can invite users to my application. After the Google user accepts the invitation, I can see their user object in Active Directory. What I would like to do next is to programmatically login the user using the Google federation or get the JWT token of the logged in Google user.
For user objects created in AD, I can programmatically login the users using ROPC. I understand this is not possible for external users authenticated using Google federation.
• Kindly please take note of this that Azure AD does not support ROPC flow method of credential authentication for federated accounts. Also, when you are using ROPC method, your credentials are at risk of compromise as they are passed directly in the body of API authentication request. Thus, I would suggest you use client credential flow for this purpose as it can access the data from both sides.
• Since you want to programmatically login using the Google federated user to some application or SaaS platform, I would suggest you refer the below link which describes sufficiently how you can use the federated domain’s user login credentials to login to an application or a SaaS platform. In this link, it is stated that you should configure the Azure Policy regarding the Home realm discovery to false and configure the federated domain as its preferred domain for logging in. Also, if you want to retrieve the access token only, then you can use the ‘Postman’ application or ‘https://jwt.ms’ as the redirect URI for that purpose.
https://medium.com/#amanmcse/ropc-username-password-flow-fails-with-aadsts50126-invalid-username-or-password-for-federated-90c666b4808d

Azure AD Auth allow login without domain in username

I have a web app that is using an Azure AD to hold user accounts and allow authentication. The app has some internal users that are able to authenticate, but I also want to allow external users into the app (customers external to the company).
I am able to do this, but only by creating users that have "#mydomain.onmicrosoft.com" in the username. That is fine I guess.. but can I at configure the sign-on page somehow to not require the username to type this in??
Ex: if a username is "joe.bob#mydomain.onmicrosoft.com" I want them to be able to login with a username of "joe.bob" and that's it!
Full disclosure there is another question like this: Logging into Azure Active Directory without a Domain Name and I've posted a comment asking if anything has change since the question was active (2014). So if this is a duplicate question, then so be it, but I am wanting to know if there are any new developments (pun intended) regarding this.
Based on the description, you want to collaborate to work with external users. However you were create a account in the tenant directly. There are some difference between the Azure AD user and external user, more detail refer this link.
And AFAIK, Azure Active Directory still doesn't support to login with the username without domain name at present.
However the Azure AD B2C also provides the feature to work with external users and it allows Local Accounts login-in with (email address and password, or username and password).(refer here). You may consider to use Azure AD B2C if you want to login without the domain name.
And below link also helpful about to learn the difference between B2B collaboration and B2C:
Compare B2B collaboration and B2C in Azure Active Directory
In-addition, if you have any idea or feedback about Azure AD, you can submit them from here.

Integrate with LDAP in Azure

Our application store some user information(username, password) in LDAP, and because we cannot change the authenticate code, so we would like to setup a LDAP server in Azure, but I do not see Azure provide such service.
is it possible?
Curently, we have LDAP, DataBase, Application(java,tomcat). DataBase is used to store some business information, LDAP is used to store user credentials.
If user want to use our service, he should sign up, then we will store his credentials to LDAP and when he login, we will compare the credential.
LDAP works within the bounds of a domain, but your browser will not present your credentials to sites out on the internet.
I have two suggestions, I haven't tested either of them.
Option 1:
Use Windows Azure Connect to add the Azure boxes to your own domain, thus allowing users within the domain to authenticate.
Option 2:
Install AD FS 2.0 on your companie's intranet or DMZ, and then add it as an identity provider in the Access Control Service. You then add the Access Control Service as an identity provider in your application. When a user attempts to use your application, they will be redirected to the AD FS server (via the ACS) to authenticate with their local credentials.

Resources