In this example we are going to see how NTLM authentication is handled with Membrane API Gateway.
- Setup IIS server on the Windows machine.
- Let the IIS server listen on port
8111
. - Configure the IIS server to use NTLM authentication.
- Let the IIS server listen on port
- Have cURL or another HTTP client ready (e.g. insomnia - https://insomnia.rest/download/).
- (optional) Configure additional Windows credentials for usage with this example.
To run the example execute the following steps:
-
Start Membrane API Gateway proxy by running the
service-proxy.[bat|sh]
in this folder. -
Look at the console window and wait until
'Membrane ... up and running!'
. This window will remain open -
Call http://localhost from your HTTP client (example -
curl -v localhost
). -
Observe a
401 Unauthorized
error message. -
Call http://localhost again but set the
X-Username
andX-Password
headers to your Windows credentials (example -curl -v -H "X-Username: $USERNAME" -H "X-Password: $PASSWORD" localhost
). -
Observe a '200 Ok' success message.
Have a look at the configuration in the proxies.xml
of this example.
<router>
<serviceProxy port="80">
<ntlm user="X-Username" pass="X-Password" />
<target host="localhost" port="8111"/>
</serviceProxy>
</router>
-
Membrane is configured as a simple virtual endpoint listening on port
80
. -
When connecting the request is routed through the NTLM interceptor to start the authentication process.
-
For that the windows credentials of a valid user are needed.
-
The NTLM interceptor (by default) fetches those from custom headers - here called
X-Username
andX-Password
. -
When the authentication process has finished the original call is routed to the target server specified in the target element.
The here given configuration for NTLM can be extended to encompass all four NTLM parameters.
The following items are a list of attributes that map an NTLM parameter to a custom header for usage by the NTLM interceptor.
- user - (Windows username)
- pass - (Corresponding password for username
- domain - (Domain the Windows server is residing in)
- workstation - (Workstation the user is assigned to)
See:
- ntlm reference