Impersonate user with admin credentials in ApacheDS - ldap

I want to implement FORGOT password and I need to set the new password for the user without knowing the original one. Because of that I cannot authenticate to LDAP (ApacheDS) with the user credentials. However, when I change the password using the admin credentials the password policy is not applied.
So, I'm trying to see if I can authenticate as the admin but act as the user. Is there any way to implement this functionality against ApacheDS.

Consider using the Proxied Authorization Control as defined in RFC 4370. I am not an Apache DS expert, but I could find the following control on their site.
The ldap.com site also has an example on how to use this control (Scroll down to the section called The Proxied Authorization Request Controls. The code snippet is using the UnboundID LDAP SDK for Java)
I hope this helps.

Related

User account change password with keycloak IDP

I am developping a vue application protected by keycloak using keycloak-js.
I have a requirement that each user have an account page in my app to change their password.
.
However it seems that keycloak has no endpoint to check old password.
How can i achieve this ?
I am wondering if this is the appropriate way to do with keycloak or not ...
I already tried the update password action that send an email with magic link to the user so they can change their password. However it is not compliant with owasp recommendation that advise to force user to type their old password each time.
An alternative approach is for you to create a Keycloak client with Direct Access Grants enabled (i.e., Resource Owner Password Credentials Grant in OAuth2 terminology).
Then you can use the token endpoint and exchange the username and password for an access token. If the password is correct you get a token, otherwise it fails. Consequently, you can use this to infer if the user has inserted the old password.
In this GitHub repo you can see an example of how the call to the aforementioned endpoint would look like.

How can I verify if username and password is correct despite of Multifactor authentication is enabled with Azure AD?

I am wondering if there is anyway to check if the entered username and password is correct despite of enforcing multi factor authentication in Azure Active Directory?
I have set up an app with application permission(with admin consent) as well as delegated permission and is able to test both approach using ConfidentialClient and PublicClient using MSAL library.
I am not able to run my web form app in IIS with the PublicClient approach which is interactive and displays you a popup for the Microsoft login. So, the only approach I see here is to use app-only authentication.(https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-authenticate-an-ews-application-by-using-oauth )
I can use the confidential client(app only) since I have all the required admin consents granted to get the OAuth token and then impersonate the user to access to EWS managed api.
But the requirement is the user should enter their outlook password in the webform app before loading their emails(from EWS Managed API which needs OAuth token).
At this point I am not sure what to do next. Please help. Also let me know if you need more information.
For more reference why I am no able to use delegated authentication: Why app is throwing error in test environment but working fine in local machine using ASP.NET Web Forms and MSAL?
Per my understanding, you want to check the username and password by Azure AD first and using the confidential client to call APIs on behalf of the user.
This way is something hacking, but I think it works for this scenario. Just try the request below:
POST https://login.microsoftonline.com/<tenant id>/oauth2/v2.0/token
Request Body:
client_id=<confidential client app id>
&Client_secret=<confidential client app sec>
&grant_type=password
&scope=https://graph.microsoft.com/user.read
&username=<username>
&password=<password>
If the user typed the wrong user name and password, the response would be:
If username and password are all right, the response report the MFA related info:

Using Flask Login with LDAP safe and secure

I am creating a login page with an authentication using LDAP. I could see LDAP3 packages for flask with login forms as well. I am looking for a form where the developer of the portal(say me or anyone in our team) should not be able to add any print statements and sniff the username and password when someone log in...
The flask form is exposing the password variable as a plain string. Even if it doesn't expose , it is possible to put a print statement in the flask_form validate function.
Is there any option available like the form is bundled as binary or c-python module where the developer has no option to sniff the credentials at all..
If not possible or no options available as they know off, any other framework like django helps for these usecase?
By design, server-side LDAP authentication requires the server receive the username & password from the user and relay that information to the LDAP server. This means a developer could insert a line that logs all credentials out somewhere, grab the passwords from process traces, dump memory, etc. If you don't want any of the developers or system administrators to have access to user passwords, use some type of federated authentication instead of LDAP.
In a federated authentication scheme, the user auths against some other source (e.g. ADFS) and your app checks a token that essentially says "this trusted other auth source says the person is Lisa".

MVC authorize not authenticate using AD

I have scoured this and many other sites to find an answer but have come up short every single time. If this is a duplicate, I am very happy to accept direction to the original question with an answer:
I have built an MVC 4 site and I am using the Authorize tag where needed and this is working as expected.
My issue is that I require a mechanism by which to prompt the user (already logged in or some other valid user in the domain) to enter their windows credentials on one page in order to confirm/authorize that user. This is not what the authorize filter is doing. The authorize filter is actually authenticating the user. Thus changing the User.Identity information accordingly.
Is it possible to just authorize a user (not authenticate) without actually changing the User object?
Just returning the 401 response forces the windows prompt but that, in turn, does an authentication, not an authorize.
While a solution could be achieved with a custom action that accepts username/password input, my requirement specifically calls for the native browser windows prompt to be displayed.
The site is using IIS Express and is set up for windows authentication and every aspect of this does what I need. Except for the issue of "true" authorization mentioned above. The browser has to be IE9. Currently running on Windows 10.
No. You're currently using Windows Authentication, and this is how it works. There is no need to login because the user is already logged into Windows, that's the point.
To do what you want, you would need to use an individual auth library like Identity. Which will give you the login capability. However, that doesn't work with AD out of the box, but you can add that in yourself. In otherwords, instead of using the Identity functionality to look a user up by username and password to authenticate, you'd connect to AD over LDAP, and verify the credentials there. You'd also need to use the LDAP connection to add the user's groups in AD to the their roles in Identity. Then, you can utilize the Authorize attribute as normal.
Long and short, if you want to actually allow the user to login as any AD user, then you're pretty much on your own. There's no builtin functionality for that. It's relatively straight-forward, if not entirely easy, to set something up yourself for that that, but again, that's on you.

Authenticating the user

I am developing an asp.net application in 3.5 where authentication is done using cookies. On the default page I am authenticating the user and setting some value in cookie.
Whenever I need to authenticate the user I just verify it from the cookie. If the user is not authorized then I redirect him to the default page for authentication.
Is this the correct way to do?
If you want to authenticate users using Usernames & Passwords with roles and the like, I suggest using .NET's Forms Authentication: http://www.asp.net/Learn/Security/.
This is a great question on practice. I have done authentication using session variables before without any major issues. I do recommend using Forms Authentication and using the Membership class.
MSDN Forms Authentication