forked from lukefx/rack-ntlm
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Removing net/ntlm and adding as dependency * Creating files to bundle it as a gem * Using net/ldap to search for user on AD
- Loading branch information
Showing
8 changed files
with
193 additions
and
831 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
## MAC OS | ||
.DS_Store | ||
|
||
## TEXTMATE | ||
*.tmproj | ||
tmtags | ||
|
||
## EMACS | ||
*~ | ||
\#* | ||
.\#* | ||
|
||
## VIM | ||
*.swp | ||
|
||
## PROJECT::GENERAL | ||
coverage | ||
rdoc | ||
pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
= Rack-ntlm | ||
|
||
== Description | ||
|
||
Rack middleware for transparent authentication with NTLM. | ||
|
||
This is a fork from lukefx/rack-ntlm on Github. This makes the Rack middleware a gem and uses net/ldap to search the user against an ActiveDirectory server. | ||
|
||
This is work in progress, so contributions are welcome. | ||
|
||
== Known Limitations (TO-DOs): | ||
|
||
* Due to the user-provided password not being available on the NTLM Type3 message, this middleware is only verifying the existence of the user on AD, and not binding as that user (which would require password) | ||
* Failure on the NTLM authentication or LDAP search will simply return 401 with a response body saying "You are not authorized to see this page" | ||
|
||
== Dependencies | ||
|
||
* rubyntlm (gem install rubyntlm) | ||
* net/ldap (gem install net-ldap) | ||
== Usage (with Rails): | ||
|
||
On your config/environment.rb: | ||
|
||
config.gem 'rubyntlm', :lib => 'net/ntlm' | ||
config.gem 'net-ldap', :lib => 'net/ldap' | ||
config.gem 'rack-ntlm' | ||
|
||
config.middleware.use "Rack::Ntlm", { | ||
:uri_pattern => /\/login/ # (default = /\//) (any URL) | ||
:host => '<Active Directory hostname>', | ||
:port => 389, # default = 389 | ||
:base => 'Base namespace for LDAP search', | ||
:search_filter => '(dn=%1)' # default = (sAMAccountName=%1) | ||
:auth => { | ||
:username => '<username to bind to LDAP>', | ||
:password => '<password to bind to LDAP>' | ||
} | ||
} | ||
|
||
Then run: | ||
|
||
rake gems:install | ||
rake gems:unpack (optional, if you want to vendor the gem) | ||
|
||
== Example | ||
|
||
When a client needs to authenticate itself to a proxy or server using the NTLM scheme then the following 4-way handshake takes place (only parts of the request and status line and the relevant headers are shown here; "C" is the client, "S" the server): | ||
|
||
1: C --> S GET ... | ||
|
||
2: C <-- S 401 Unauthorized | ||
WWW-Authenticate: NTLM | ||
|
||
3: C --> S GET ... | ||
Authorization: NTLM <base64-encoded type-1-message> | ||
|
||
4: C <-- S 401 Unauthorized | ||
WWW-Authenticate: NTLM <base64-encoded type-2-message> | ||
|
||
5: C --> S GET ... | ||
Authorization: NTLM <base64-encoded type-3-message> | ||
|
||
6: C <-- S 200 Ok | ||
|
||
== Copyright | ||
|
||
Copyright (c) 2009-2010 [Rack-Ntlm], released under the MIT license |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.