How can I use NTLM SSPI authentication with aiohttp? - aiohttp

How to use Python requests to perform NTLM SSPI authentication? describes how to use the requests-negotiate-sspi package with the requests package for NTLM SSPI authentication. Is there a package that provides similar functionality that I can use it with the aiohttp package for asynchronous HTTP requests on a Windows domain?

Related

How to use Kerberos for samba authentication

I have WS 2016 running as AD/DC on which NTLM/NTLMv2 is disabled (Kerberos is a way to go). I have successfully joined Ubuntu machine to it, using this tutorial "Integrate Ubuntu with AD". Everything if working correctly (except Samba), can view users and groups on AD and can login to Ubuntu machine using AD user.
Now when I try to login with AD user to samba share I get NT_STATUS_NTLM_BLOCKED, which is expected, sense NTLM is blocked by AD.
Now my question is how to setup (force) Samba to use kerberos instead NTLM ?
It sounds like you're thinking that the SMB server just receives your password and then uses either NTLM or Kerberos to validate it. That's not how it works.
In SMB, it's the client which speaks NTLM or Kerberos when connecting to the server. You cannot force the server to use Kerberos because that is not the server's decision; it can either offer Kerberos or not, but it cannot make the client support Kerberos if the client doesn't support it.
Most mobile SMB client libraries do not have any Kerberos support (due to complexity); they will only use NTLM.
My "solution" to this issue was simply to exclude specific server from NTLM restriction policy.
There are two policies, on active directory server, in "Local Group Policy/Computer Configuration/Windows Settings/Security Settings/Local Policies/Security options":
Network security: Restrict NTLM: Add server exceptions in this domain
Network security: Restrict NTLM: Add remote server exceptions for NTLM authentication
So servers that are defined under those two policies are able to use NTLM.
Not a solution, but for now it's a workaround.

Compatibility of ADAL with Azure SQL DB

Customer is triyng establish the connectivity to the DWH using SSO login from databricks cluster. If we go to this document: https://learn.microsoft.com/en-us/azure/sql-database/sql-database-spark-connector, it talks about SLQ DB github repository but this link: https://github.com/AzureAD/azure-activedirectory-library-for-java mentions that MSAL4J is the new authentication library to be used with the Microsoft identity platform, so we need confirmation if ADAL will work or we need to upgrade to MSAL4J?
You can acquire tokens for Azure SQL DB with ADAL by using the resource:
https://database.windows.net/
If you used MSAL, you'd use this scope:
https://database.windows.net/.default
The main difference between MSAL and ADAL is that ADAL uses the older "v1" endpoint of Azure AD.
You can acquire tokens for any API using either ADAL or MSAL, v2 and MSAL do not allow calling more APIs etc.
While it is generally recommended to use MSAL now, ADAL should also work fine for you.

What's the difference between NTLMv2 and Kerberos?

What I understand:
NTLMv1/v2 is a shorthand for Net-NTLMv1/v2 and hence are the same thing.
NTLM (without v1/v2) means something completely different.
NTLM hashes are stored in the Security Account Manager (SAM) database and in Domain Controller's NTDS.dit database.
Net-NTLM hashes are used for network authentication (they are derived from a challenge/response algorithm and are based on the user's NT hash).
Kerberos uses tickets to authenticate
My questions:
Why use NTLMv2 when you can use Kerberos instead for authentication (ie SMB)
Why does the account you want to log in needs an SPN for Kerberos? Can't you just use Kerberos for logging in any account?
Is NTLMv2 used for simply logging in accounts?
Is NTLMv2 used in SMB?
Kerberos is used in LDAP, right?
Heard Kerberos is used to retrieve resources from the domain controller, what are some resources?
Why is NTLMv2 still used, and where
Where is Kerberos used other than logging into accounts with SPNs
What does Kerberos really log you in? A shell? Account?
What does NTLMv2 really log you in? A shell? Account? File share?
What are SPNs, what are used for and where
There are far too many questions here to answer individually, so here is a better way to think about it.
NTLM is a p2p authentication protocol. The client sends a ticket directly to the server and the server can validate it directly or send it off to a a Domain Controller to validate. This is why workgroup PC to workgroup PC can succeed with just a username and password. However, with NTLM you have no way to prove the server you've sent the ticket to is actually the server you want to send it to. This means no server authentication, and therefore means no mutual authentication.
Kerberos always relies on a third server to authenticate you and the server you're trying to authenticate to. You do this by first authenticating to the KDC (Domain Controller), and then with that resultant ticket request a new ticket to the target service. The KDC uses the SPN to find the details of the target service in the directory and encrypts the identity to a key only the target service knows.
Then the client sends the new ticket to the target service, the service decrypts the ticket, and then encrypts a response to the client with a key shared in the encrypted ticket. Since only the named server can decrypt the ticket (and therefore see the shared encryption key), the client has evidence it's talking to the service with the given SPN. That provides server authentication, and therefore mutual authentication. If you don't have an SPN you can't ask the KDC to create a ticket that only the server knows.
If you don't have an SPN, there is a lesser known flow of Kerberos called user-to-user, which requires an out of band process to exchange additional tickets. This is rarely used because it's more complicated and just shifts the server auth problem.
This explains why both protocols exist. NTLM exists where there isn't a KDC, or the service isn't configured with an SPN. The downside is NTLM is less secure.
In Windows-land NTLM and Kerberos are mostly interchangeable because they're wrapped in a separate protocol called SPNEGO, which is an authentication negotiation protocol. Kerberos is usually tried first, and falls back to NTLM if Kerberos fails. In the majority of cases SPNEGO is used in place of Kerberos or NTLM so whether something uses Kerberos or NTLM is entirely dependent on whether the client can get a Kerberos ticket.
Kerberos is generally always attempted. When you log into your domain-joined machine Kerberos is always used. NTLM can be used without additional work because it is an artifact of the credentials you typed in.
Refer to the
https://learn.microsoft.com/en-us/dotnet/framework/network-programming/ntlm-and-kerberos-authentication
Kerberos: https://learn.microsoft.com/en-us/windows-server/security/kerberos/kerberos-authentication-overview
NTLM: https://learn.microsoft.com/en-us/windows-server/security/kerberos/ntlm-overview
What is NTLM?: It is an Authentication Protocol that is used in older versions of Windows. But it is still being used today world. If for any reason Kerberos fails to, NTLM will be used instead. NTLM stands for New Technology LAN Manager
What is Kerberos?: It is also an Authentication Protocol, it is a default authentication protocol on Windows version above Win2K, to replace the NTLM Auth protocol.
No
Kerberos
NTLM
1
Kerberos is an Open Source software and offers free services
NTLM is the proprietary Microsoft authentication protocol
2
Kerberos supports delegation of authentication in multi-tier application
NTLM does not support delegation of authentication
3
Kerberos supports two factor authentication such as smart card logon
NTLM does not support smart card logon
4
Kerberos has the feature of mutual authentication
NTLM does not have future of mutual authentication
5
It provides high security
While NTLM is less secured as compared to Kerberos
6
Kerberos is supported in Windows 2000, XP and later versions
NTLM is also supported in earlier windows versions of Windows 95, 98 ME, and NT 4.0
NTLM Authentication Illustration:
Kerberos Authentication Illustration:

Explanation of IdentityServer4 logout spec

We are using IdentityServer4. We have a Windows 2016 server running ADFS (Active Directory Federation Services) version 4.0. This version of ADFS has OpenID Connect endpoints to do active directory authentication. We set this up as an external oidc provider in IdentityServer4. The authentication works fine. What I'm having an issue with is the logout. The current logout correctly disposes of the identity server and client cookies, but doesn't log the user out of the external provider (ADFS). I upgraded the ADFS server so the metadata endpoint exposes end_session_endpoint, frontchannel_logout_supported, and frontchannel_logout_session_supported properties.
What is the proper way to have our identityserver4 implementation also ask the external provider to perform a logout when it does? I'm a little confused by the spec.
http://docs.identityserver.io/en/release/topics/signout_external_providers.html
http://docs.identityserver.io/en/release/topics/signout.html#refsignout
I'm not sure if the front-channel or back-channel is what I should be looking at in this scenario or if this is even related. The spec also mentions a idp value at authentication time that would indicate to the identity server that a external provider needs a logout as well. Is this what I should be looking at? Little lost. Looking for guidance. Thanks!

Is it possible to athenticate using Kerberos against a Kerberos enabled domain controller?

We are configuring a Siebel to authenticate against a Microsoft Active Directory with Kerberos enabled.
Kerberos authentication is not enabled in Siebel under Unix so we're planning to use simple authentication.
It is possible to authenticate to a Microsoft Active Directory without Kerberos when Kerberos is enabled in the domain controller?
Best regards,
Yes, you can authenticate to a Microsoft Active Directory without Kerberos, using either NTLM or LDAP. NTLM though, is disabled by default in AD 2008 and above. LDAP authentication through bind calls can be used as well by application servers who can't do ether NTLM or Kerberos. Classically, LDAP is meant as a directory lookup protocol and not really meant as an authentication protocol. Typically, these scenarios involve application servers running on non-Microsoft platforms. Be advised that Kerberos is the most secure protocol of the three and is the industry standard for authentication.

Resources