-
Notifications
You must be signed in to change notification settings - Fork 25
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
Basic authorization header #1039
Conversation
The remote_address check has been updated const remote_address = /^[A-Za-z0-9.,_-\s]*$/.test(req.headers['x-forwarded-for'])
? req.headers['x-forwarded-for'] : undefined; |
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one!
I tested this out using this small script
import axios from 'axios';
const url = 'http://localhost:3000/latest/api/user/key';
const username = 'myUser';
const password = 'myPassword';
const auth = {
username: username,
password: password
};
axios.get(url, { auth })
.then(response => {
console.log('Response:', response.data);
})
.catch(error => {
console.error('Error:', error.message);
});
Works well 👍
It should be possible to provide a base64 encoded authentication header
--user
with a request.eg.
curl http://localhost:3000/api/user/key --user "[email protected]:mypassword"
The
auth.js
module will short circuit and await thefromACL.js
response which is either a user object or error.The
fromACL.js
module is taken from the post method from the login module which now requires thefromACL
module.The ACL module itself has been formatted to return the ACL query method.
The ACL module can now be required without having to be executed.