Custom Basic Authentication

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Custom Basic Authentication


    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Hello all, I want to be able to use Basic Authentication without the need
    of specific accounts in my server machine. What I want is to be able to get
    the browser sent user and password, and use that to do custom
    authentication (checking them with a database, etc.).

    Is that possible? The only thing I can do manually is to request the popup,
    but the AUTH_USER and AUTH_PASSWORD never get to me (I think IIS is simply
    trying to authenticate, and its never returning to my app).

    Any help, very appreciated.

    Regards,
    Pablo
    - --
    Remember, drive defensively! And of course, the best defense is a good
    offense!


    -----BEGIN PGP SIGNATURE-----
    Version: PGP 8.0.2

    iQA/AwUBQCFEz76KEogX0AkqEQK05ACgqVsJwrkXDKSNg+EB8N5YC/47xNYAnRvb
    gxJTvkyUMdh06SPuqwfQ84yP
    =XOY5
    -----END PGP SIGNATURE-----

    Pablo Montilla Guest

  2. Similar Questions and Discussions

    1. Basic authentication re-direct
      Hello, I have basic authentication turned on for a directory. Is it possible to re-direct a failed login to another page? -- Thanks in...
    2. sso/basic authentication
      We are interested in using basic authentication (with https) to implement Single Sign On (SSO) with Internet Explorer clients. Does anyone have...
    3. ASP.Net Forms authentication with basic authentication popup
      Relatively new to ASP.Net but have a strange problem. My site uses forms authentication for a large administration section however after the user...
    4. Basic Access Authentication
      I found this article http://www.dotnet247.com/247reference/msgs/22/113795.aspx, but unfortunatly it no longer exists here, so I'm re-opening it. ...
    5. Basic Authentication, WebService
      I did the following to add http basic authentication for calling a webservice: chz11086.HelloAuthTestService service = new...
  3. #2

    Default Re: Custom Basic Authentication

    You should be able to do this with an HttpModule without too much trouble.

    Essentially, you would want IIS set to anonymous (Basic unchecked) so that
    it wouldn't try to process the headers. Then, you would just look for the
    HTTP_AUTHORIZATION header on each request.

    If the header was there, you would parse it out to get the user name and
    password and perform your authentication as needed. If the header was not
    there, you would just set the correct www-authenticate header.

    I think the code might look something like this, but I haven't tested this:

    authHeader = req.ServerVariables("HTTP_AUTHORIZATION")
    realm = req.Url.Host

    If (authHeader Is Nothing OrElse authHeader.Equals(String.Empty)) Then
    challengeHeader = String.Format("Basic realm=""{0}""", realm)
    res.AddHeader("www-authenticate", challengeHeader)
    res.StatusCode = 401
    'might want to stick some HTML in the response too...
    con.ApplicationInstance.CompleteRequest()
    Else
    'parse out the header and authenticate
    End If

    HTH,

    Joe K.

    "Pablo Montilla" <melkor@adinet.com.uy> wrote in message
    news:uA5KDN16DHA.1632@TK2MSFTNGP12.phx.gbl...

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Hello all, I want to be able to use Basic Authentication without the need
    of specific accounts in my server machine. What I want is to be able to get
    the browser sent user and password, and use that to do custom
    authentication (checking them with a database, etc.).

    Is that possible? The only thing I can do manually is to request the popup,
    but the AUTH_USER and AUTH_PASSWORD never get to me (I think IIS is simply
    trying to authenticate, and its never returning to my app).

    Any help, very appreciated.

    Regards,
    Pablo
    - --
    Remember, drive defensively! And of course, the best defense is a good
    offense!


    -----BEGIN PGP SIGNATURE-----
    Version: PGP 8.0.2

    iQA/AwUBQCFEz76KEogX0AkqEQK05ACgqVsJwrkXDKSNg+EB8N5YC/47xNYAnRvb
    gxJTvkyUMdh06SPuqwfQ84yP
    =XOY5
    -----END PGP SIGNATURE-----


    Joe Kaplan \(MVP - ADSI\) Guest

  4. #3

    Default Re: Custom Basic Authentication


    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Thanks for your answer, I've tried using a custom HttpModule and handling
    the Application_Authenticate event, but while I receive the event whenever
    I input a valid Windows account, I never receive it if I use whatever
    username and password (the ones I want to authenticate in a custom way).

    I've tried different combinations of the flags for the authentication
    methods, but none had worked. Am I missing something?

    Anyway, thanks for your reply,
    Pablo
    - --
    If you share a path with an elephant, no matter who stumbles, you lose.


    -----BEGIN PGP SIGNATURE-----
    Version: PGP 8.0.2

    iQA/AwUBQCzvcL6KEogX0AkqEQJdMgCgvavD0OjD0wRH3+njBHQToC xpDPkAnjva
    W0Drs5oubyq3WcI0IKshBTNt
    =aXdy
    -----END PGP SIGNATURE-----

    Pablo Montilla Guest

  5. #4

    Default Re: Custom Basic Authentication


    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Obviously I didn't tried enough, I've removed all but anonymous and it
    works like charm.

    Many, many thanks,
    Pablo
    - --
    If at first you don't exceed, try, try again.


    -----BEGIN PGP SIGNATURE-----
    Version: PGP 8.0.2

    iQA/AwUBQCz1dL6KEogX0AkqEQL+6QCg+KhMOiK23vCEJKMJ9P7DIH eCZl8Ani1n
    Z7564VWsT5bz00ggiudWDY2/
    =Aqto
    -----END PGP SIGNATURE-----

    Pablo Montilla Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139