Re: request.META['REMOTE_USER'] with django runserver

2014-09-24 Thread Tom Evans
On Mon, Sep 22, 2014 at 5:36 PM, Robbie Edwards
 wrote:
> Hi,
>
> On my production server, I'm using REMOTE_USER to provide SSO for an
> internal service.  It works great on the production server.  However, when
> running 'runserver' on the development side, this variable is not set so
> authentication in this manner doesn't work.  Is there a way to config this
> on the development side so I can develop as if it were in place?
>
> thanks

Add middleware on your dev site that sets the appropriate value for
development, eg:

class DevAddRemoteUserMiddleware(object):
  def process_request(self, request):
request.META['REMOTE_USER'] = 'bob'

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1JbT%3Dbhaf4TMz%2BpbDfhwPG_wO-Z8-Fk1QWzBhAai-Dtgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: request.META['REMOTE_USER'] with django runserver

2014-09-23 Thread Jürgen Kofler

Hi,

you can add 'django.contrib.auth.backends.ModelBackend' to the 
AUTHENTICATION_BACKENDS and use a local user.


or
if you like to use the "REMOTE_USER" set up nginx  with auth_basic and 
proxy  on your local instance:


location / {
auth_basic "Restricted";
auth_basic_user_file /...PATH.../.htpasswd;
proxy_set_header REMOTE_USER $remote_user;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8000;
}

in this case you get the  user in "HTTP_REMOTE_USER"

if you like you can make the same configuration with uwsgi and nginx :

uwsgi_pass  unix:///tmp/demo.sock;
include uwsgi_params;
uwsgi_param REMOTE_USER $remote_user;

and in this case you get the correct header parameter "REMOTE_USER"


Cheers
Jürgen

Am 22.09.2014 um 18:36 schrieb Robbie Edwards:

Hi,

On my production server, I'm using REMOTE_USER 
 to 
provide SSO for an internal service.  It works great on the production 
server.  However, when running 'runserver' on the development side, 
this variable is not set so authentication in this manner doesn't 
work.  Is there a way to config this on the development side so I can 
develop as if it were in place?


thanks

--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0568f70f-9186-49f5-b845-ec9039e11681%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54218930.1090306%40kofler.bz.it.
For more options, visit https://groups.google.com/d/optout.


request.META['REMOTE_USER'] with django runserver

2014-09-22 Thread Robbie Edwards
Hi,

On my production server, I'm using REMOTE_USER 
 to provide 
SSO for an internal service.  It works great on the production server. 
 However, when running 'runserver' on the development side, this variable 
is not set so authentication in this manner doesn't work.  Is there a way 
to config this on the development side so I can develop as if it were in 
place?

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0568f70f-9186-49f5-b845-ec9039e11681%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: request.META['REMOTE_USER']

2009-10-14 Thread Daniel Roseman

On Oct 14, 10:39 am, luca72  wrote:
> Thanks but have you got idea why i get this error, request.user return
> the correct value, but for my understanding also the META
> ['REMOTE_USER'] has to give the same value.

No, that's not true, and the documentation doesn't say it does. The
values in META are the headers which are passed by the web server.
They are set before anything gets into Django, so things like the
Django authentication framework don't affect them at all. The
REMOTE_USER header would be set, if at all, by any webserver-based
authentication, such as Apache's.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: request.META['REMOTE_USER']

2009-10-14 Thread robin nanola
read the explanation here
http://docs.djangoproject.com/en/dev/howto/auth-remote-user/

On Wed, Oct 14, 2009 at 5:39 PM, luca72  wrote:

>
> Thanks but have you got idea why i get this error, request.user return
> the correct value, but for my understanding also the META
> ['REMOTE_USER'] has to give the same value.
>
> On 14 Ott, 11:34, robin nanola  wrote:
> > try request.user
> >
> > you get a key error coz there is no  'REMOTE_USER' key in META.
> >
> > On Wed, Oct 14, 2009 at 5:29 PM, luca72  wrote:
> >
> > > Hello if i use request.META['REMOTE_USER'] i get key error, but if i
> > > use 'REMOTE_HOST' not
> > > can you tell me how to get the user that is authenticate
> > > I use the decorator @login_required and so the user is authenticated
> > > correct?
> >
> > > Regards
> >
> > > Luca
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: request.META['REMOTE_USER']

2009-10-14 Thread Bayuadji

hi,

imho request.user.is_authenticated and request.user.is_anonymous

-djibon-

On 10/14/09, robin nanola  wrote:
> try request.user
>
> you get a key error coz there is no  'REMOTE_USER' key in META.
>
> On Wed, Oct 14, 2009 at 5:29 PM, luca72  wrote:
>
>>
>> Hello if i use request.META['REMOTE_USER'] i get key error, but if i
>> use 'REMOTE_HOST' not
>> can you tell me how to get the user that is authenticate
>> I use the decorator @login_required and so the user is authenticated
>> correct?
>>
>> Regards
>>
>> Luca
>> >
>>
>
> >
>


-- 
--
http://www.tumbletooth.org
my linkedin profile : http://www.linkedin.com/in/bayuadji
--

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: request.META['REMOTE_USER']

2009-10-14 Thread luca72

Thanks but have you got idea why i get this error, request.user return
the correct value, but for my understanding also the META
['REMOTE_USER'] has to give the same value.

On 14 Ott, 11:34, robin nanola  wrote:
> try request.user
>
> you get a key error coz there is no  'REMOTE_USER' key in META.
>
> On Wed, Oct 14, 2009 at 5:29 PM, luca72  wrote:
>
> > Hello if i use request.META['REMOTE_USER'] i get key error, but if i
> > use 'REMOTE_HOST' not
> > can you tell me how to get the user that is authenticate
> > I use the decorator @login_required and so the user is authenticated
> > correct?
>
> > Regards
>
> > Luca
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: request.META['REMOTE_USER']

2009-10-14 Thread Tom Evans

On Wed, 2009-10-14 at 02:29 -0700, luca72 wrote:
> Hello if i use request.META['REMOTE_USER'] i get key error, but if i
> use 'REMOTE_HOST' not
> can you tell me how to get the user that is authenticate
> I use the decorator @login_required and so the user is authenticated
> correct?
> 
> Regards
> 
> Luca

Simply look at request.user. See [1].

Cheers

Tom

[1]
http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.user



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: request.META['REMOTE_USER']

2009-10-14 Thread robin nanola
try request.user

you get a key error coz there is no  'REMOTE_USER' key in META.

On Wed, Oct 14, 2009 at 5:29 PM, luca72  wrote:

>
> Hello if i use request.META['REMOTE_USER'] i get key error, but if i
> use 'REMOTE_HOST' not
> can you tell me how to get the user that is authenticate
> I use the decorator @login_required and so the user is authenticated
> correct?
>
> Regards
>
> Luca
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: request.META['REMOTE_USER']

2009-10-14 Thread Daniel Roseman

On Oct 14, 10:29 am, luca72  wrote:
> Hello if i use request.META['REMOTE_USER'] i get key error, but if i
> use 'REMOTE_HOST' not
> can you tell me how to get the user that is authenticate
> I use the decorator @login_required and so the user is authenticated
> correct?
>
> Regards
>
> Luca

request.user
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



request.META['REMOTE_USER']

2009-10-14 Thread luca72

Hello if i use request.META['REMOTE_USER'] i get key error, but if i
use 'REMOTE_HOST' not
can you tell me how to get the user that is authenticate
I use the decorator @login_required and so the user is authenticated
correct?

Regards

Luca
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---