Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 531663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:19:27+00:00 2026-05-13T09:19:27+00:00

I found a form of information leakage when using the @login_required decorator and setting

  • 0

I found a form of information leakage when using the @login_required decorator and setting the LOGIN_URL variable.

I have a site that requires a mandatory login for all content. The problem is that you get redirected to the login page with the next variable set when it’s a existing page.

So when not logged in and asking for:

 http://localhost:8000/validurl/

You see this:

 http://localhost:8000/login/?next=/validurl/

And when requesting an non existing page:

 http://localhost:8000/faultyurl/

You see this:

 http://localhost:8000/login/

Which reveals some information that I dont want. I thought of overriding the login method, forcing the next to empty and calling ‘super’ on this subclassed method.

An additional problem is that some of my tests fail without the LOGIN_URL set. they redirect to ‘/accounts/login/’ instead of ‘/login/’. Hence why I’d like to use the LOGIN_URL but disable the ‘auto next’ feature.

Anybody that can shed some light on the subject?

Thanx a lot.

Gerard.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:19:28+00:00Added an answer on May 13, 2026 at 9:19 am

    You can include this line as the last pattern in your urls.py file. It will re-route urls that do not match any other pattern to the login page.

    urlpatterns = patterns('',
    
        ...
    
        (r'^(?P<path>.+)$', 'django.views.generic.simple.redirect_to', {
            'url': '/login/?next=/%(path)s', 
            'permanent': False
        }),
    )
    

    EDIT: To keep raising 404 pages to authenticated users, do the following:

    from django.http import Http404, HttpResponseRedirect
    def fake_redirect(request, path):
        if request.user.is_authenticated:
            raise Http404()
        else:
            return HttpResponseRedirect('/login/?next=/%s' % path)
    
    urlpatterns = patterns('',
    
        ...
    
        (r'^(?P<path>.+)$', fake_redirect),
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that requires billing and shipping information. As you can imagine,
I currently have this useful code that I found elsewhere on StackOverflow: form.DrawToBitmap(bmp, new
I have found a lot of information about adding form helper methods (see one
I have found the Form.TopMost property but it puts the form on top of
Hi everyone I was using the jQuery form plugin to process form submission (found
I'm porting a app to FreePasal/Lazarus & found that their form converter is not
I found out that HTML form supports only two enctype types. They are application/x-www-form-urlencoded
I want to submit a form without page refresh using jQuery. I found some
I have a form created which an unbound datagridview that has three columns. Position,
I have a form to edit employee information. If the user wishes to enter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.