couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Holcomb <w...@dhappy.org>
Subject authentication issues
Date Wed, 14 May 2014 14:36:24 GMT
I have a couch server running and I am attempting to access it from a web
application server from port 80. I am having difficulty authenticating.

The code I am using to test is:

var host = 'http://localhost:5984'
var url = host + "/wells/"
var username = 'will'
var password = 'secret'

// Succeeds
$.post(
    host + "/_session",
    { name: username, password: password },
    function() {
        console.log( 'cookie', document.cookie ) // doesn't include
AuthSession
        $.get( url ) // Fails 401 unauthorized
    }
)

var hostParts = host.split( '://' )
var hostWithAuth = hostParts[1] + "://" + username + ":" + password + "@" +
hostParts[2]
$.get( hostWithAuth ) // Fails unauthorized, credentials removed from url

// Fails unauthorized
$.ajax( {
    url: url,
    username: username,
    password: password,
    success: function() {
        console.log( arguments )
    },
    xhrFields: { withCredentials: true },
    headers: {
        Authorization: "Basic " + btoa( username + ":" + password )
    }
} )

// Fails unauthorized
var xmlHttp = new XMLHttpRequest()
xmlHttp.open( 'GET', url, false, username, password )
xmlHttp.send( null )
console.log( xmlHttp.responseText )

It seems as though my credentials are being removed when I try to pass them
in the url and none of the other methods work.

-Will

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message