Hi all, Newbie sort of question here: My Rails app needs to exist within an existing authentication framework, one which sets the HTTP request REMOTE_USER variable. If I were doing JSP, I''d just say request.getRemoteUser() and I''d be done. I''ve noodled around with a couple of likely ideas (well, they seemed likely to me at the time), but can''t figure out how to grab the appropriate object and query it in Rails. REMOTE_USER is one of the CGI environment variables that should be an attribute of a CGI object, according to the docs for class CGI. But I dunno how to obtain that object! Thanks, rw
On Aug 19, 2005, at 4:02 PM, Rick Wayne wrote:> Hi all, > > Newbie sort of question here: My Rails app needs to exist within an > existing authentication framework, one which sets the HTTP request > REMOTE_USER variable. > > If I were doing JSP, I''d just say request.getRemoteUser() and I''d > be done. I''ve noodled around with a couple of likely ideas (well, > they seemed likely to me at the time), but can''t figure out how to > grab the appropriate object and query it in Rails. REMOTE_USER is > one of the CGI environment variables that should be an attribute of > a CGI object, according to the docs for class CGI. But I dunno how > to obtain that object!All environment variables are always accessible via the ''env'' property of the request: request.env[''REMOTE_USER''] There may be a more convenient method for REMOTE_USER, specifically, but I don''t know it offhand. - Jamis
On 8/19/05, Rick Wayne <fewayne-63mtpxcE9Cs@public.gmane.org> wrote:> Hi all, > > Newbie sort of question here: My Rails app needs to exist within an > existing authentication framework, one which sets the HTTP request > REMOTE_USER variable. > > If I were doing JSP, I''d just say request.getRemoteUser() and I''d be > done. I''ve noodled around with a couple of likely ideas (well, they > seemed likely to me at the time), but can''t figure out how to grab > the appropriate object and query it in Rails. REMOTE_USER is one of > the CGI environment variables that should be an attribute of a CGI > object, according to the docs for class CGI. But I dunno how to > obtain that object! >I think @request.remote_user might do it. Chris
> Newbie sort of question here: My Rails app needs to exist within an > existing authentication framework, one which sets the HTTP request > REMOTE_USER variable. > From: Jamis Buck <jamis-uHoyYlH2B+GakBO8gow8eQ@public.gmane.org>> All environment variables are always accessible via the ''env'' > property of the request: > > request.env[''REMOTE_USER''] > > There may be a more convenient method for REMOTE_USER, specifically, > but I don''t know it offhand. > From: snacktime <snacktime-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > I think @request.remote_user might do it.This looks like it''s going to work. I''ll report back with more once I''ve actually got the Rails app surrounded with the auth framework (our university is using Pubcookie). I tried something like @request.remote_user before, but (major duhh coming) didn''t have the auth set up and so the string was empty. Oh, the pain, the pain... Anyway, thanks, this should give me what I need to plunge ahead. The "env" method definitely works with variables such as HTTP_HOST and REMOTE_HOST. -- First they laugh at you, then they ignore you, then they fight you. Then you win. -- M.K. Gandhi