Ruby: Get currently logged in user on windows

前端 未结 6 1480
不思量自难忘°
不思量自难忘° 2021-01-13 04:20

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

6条回答
  •  不要未来只要你来
    2021-01-13 04:51

    I think what you mean is how you can retrieve the username that the user used to login to the web application. That will differ depending on what authentication mechanism you're using. Some Apache authentication modules, for example, will pass REMOTE_USER (e.g. the Kerberos module), the CAS Single-Sign-On module passes CAS-USER, etc. Standard digest authentication and such uses the Authentication header. You should be able to access these using request.env[HEADER] as someone else pointed out above. Check out the documentation on how your authentication layer is passing on the user in the HTTP request.

提交回复
热议问题