In C# I can get the current user of a web app using the HttpContext, however, I can\'t figure out how to do this in Ruby. Is there any way of doing this?
FOR
[RUBY ON RAILS ONLY]
This is what worked for me but there are some limitations:
If you don't care about these issues, go ahead:
In your rails application, add Rekado's gem to your Gemfile: gem 'ntlm-sso', '=0.0.1'
Create an initialiser config/initializers/ntlm-sso.rb
with:
require 'rack'
require 'rack/auth/ntlm-sso'
class NTLMAuthentication
def initialize(app)
@app = app
end
def call(env)
auth = Rack::Auth::NTLMSSO.new(@app)
return auth.call(env)
end
end
On your application.rb
file, add the line: config.middleware.use "NTLMAuthentication"
Call request.env["REMOTE_USER"]
on your view or controller to get current username.
PS: Let me know if you find anyway to make it work on Chrome or to validate user credentials.