-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cookie auth don't work? #145
Comments
For future visitors For some reason, the documentation is not really clear on this auth thingy. There are basically two ways to authenticate per my little experience using nano:
const nano = require('nano');
const COUCHDB_URL = process.env.COUCHDB_URL || 'http:https://localhost:5984';
var couchServer = nano({ url: COUCHDB_URL });
couchServer.auth(
'admin',
'admin',
function (err, response, headers) {
console.log(err, response, headers)
// set cookie to the returned headers cookie
couchServer = nano({ url: COUCHDB_URL, cookie: headers['set-cookie'] })
// do authenticated work here
couchServer.db.create('test1', function (err) {
if (err) {
console.error(err);
}
});
})
const nano = require('nano');
const COUCHDB_URL = process.env.COUCHDB_URL || 'http:https://localhost:5984';
var couchServer = nano({ url: COUCHDB_URL, requestDefaults: { auth: { username: 'admin', password: 'admin' } } });
// do authenticated work here
couchServer.db.list().then(console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can't get session details from couch db (cookies don't set)
Expected Behavior
Request with cookies.
Current Behavior
Request without cookies.
Session response with null name
Possible Solution
?
Steps to Reproduce (for bugs)
`const nano = require('nano')({ url: 'http:https://localhost:5984', requestDefaults: { jar: true } })
const username = 'jan'
const userpass = 'apple'
export function dbtestauth () {
nano.auth(username, userpass).then((body) => {
console.log('Body - ' + JSON.stringify(body))
})
}
//Body - {"ok":true,"name":"jan","roles":[]}
export function dbtestsession () {
nano.session().then((body) => {
console.log(JSON.stringify(body))
})
}
//{"ok":true,"userCtx":{"name":null,"roles":[]},"info":{"authentication_db":"_users","authentication_handlers":["cookie","default"]}}
`
Context
Your Environment
The text was updated successfully, but these errors were encountered: