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 855365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:03:46+00:00 2026-05-15T08:03:46+00:00

I would like to have both form and basic authentication. If the request comes

  • 0

I would like to have both form and basic authentication.

If the request comes like https://username:password@mysite.com/ basic authentication is used.
If the request comes like https://mysite.com form authentication is used.

Is that possible?

  • 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-15T08:03:47+00:00Added an answer on May 15, 2026 at 8:03 am

    Yes, this is possible.

    Assuming you are using namespace configuration, this is really pretty easy. By default, they are both enabled if you use auto config on the http element. See section 2.2 of the springsecurity3 reference docs. You can set a custom realm for the basic auth by using the realm attribute on the http element. Both form and basic auth will use whatever authentication-provider is configured.

    If you aren’t using auto config on the http element, you just need to add an <http-basic /> tag as a child to the http element to enable basic auth. Odds are good you aren’t interested in the default config for the form authentication, so that tag can be a little more complicated.

    Mine looks like this:

        <form-login login-page="/login.html"
            default-target-url="/home.html" always-use-default-target="true"
            authentication-success-handler-ref="authenticationSuccessHandler"
            authentication-failure-handler-ref="authenticationFailureHandler"
            login-processing-url="/j_spring_security_check" />
    

    Obviously, it is necessary to allow anonymous access to the /login.html path. That page needs to render a form which submits to /j_spring_security_check, which the filter will intercept, find the username and password, and authenticate against the authentication provider which is configured. If you dig into the rest of the namespace, you’ll find it is possible to override the names of the fields, etc.

    I’m not sure if spring always defaults to using form auth unless an Authorization header is supplied in the request and it is lacking a valid username/password pair, or if it defaults to the first filter or the last, or what. But experimentation should allow you to figure that out easily enough. Looking at the last section of chapter 8 and the first of chapter 9, it looks as though it will send all unauthenticated users to the form entry point unless there is an Authorization header in the request, in which case, a failure to authenticate will result in a basic auth required response to the client. Chapters 8 and 9 are also where you’ll look if you want to manually configure everything instead of using the namespace.

    The authentication-success-handler and authentication-failure-handler must implement the AuthenticationSuccessHandler and AuthenticationFailureHandler and allow you to customize how the filter will respond to successful and failed authentication attempts. They are not required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 494k
  • Answers 494k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer sealed is the word you're looking for, and a link… May 16, 2026 at 10:57 am
  • Editorial Team
    Editorial Team added an answer RubyMine, WebStorm, PhpStorm and IntelliJ IDEA from JetBrains all do… May 16, 2026 at 10:57 am
  • Editorial Team
    Editorial Team added an answer Dot Net Framework 3.0 Redistributable http://www.microsoft.com/downloads/details.aspx?FamilyID=10cc340b-f857-4a14-83f5-25634c3bf043&displaylang=en Or the latest in… May 16, 2026 at 10:57 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a multipart form that takes basic user information at the beginning with
Is this feasible? I would like to have the .git directory on another drive
I would like to design webapps (eg. games) that have low latency. I presume
I have two arrays of products, both formatted exactly the same, like so: $products
I have to build a rather large form with many controls. The controls are
I want to bounce an idea around. I have been building web services and
I have implemented what I thought was a pretty decent representation of MVC in
We have an administrative portal that our teachers constantly forget to download their latest
Is it possible to paqckage multiple rpms into one file. I have got two
This is a C# winforms app. Preface: I am creating a form that will

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.