Skip to content
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

Merged
merged 8 commits into from
Dec 20, 2023
Merged

Conversation

dbauszus-glx
Copy link
Member

@dbauszus-glx dbauszus-glx commented Dec 18, 2023

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 the fromACL.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 the fromACL 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.

@dbauszus-glx
Copy link
Member Author

The remote_address check has been updated
to prevent Unexpected constant truthiness on the left-hand side of a || expression.

  const remote_address = /^[A-Za-z0-9.,_-\s]*$/.test(req.headers['x-forwarded-for'])
   ? req.headers['x-forwarded-for'] : undefined;

@dbauszus-glx dbauszus-glx linked an issue Dec 18, 2023 that may be closed by this pull request
@dbauszus-glx dbauszus-glx changed the title authentication header authentication Basic authorization header Dec 18, 2023
Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@RobAndrewHurst RobAndrewHurst left a 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 👍

@RobAndrewHurst RobAndrewHurst merged commit e5dad41 into GEOLYTIX:main Dec 20, 2023
5 checks passed
@dbauszus-glx dbauszus-glx deleted the api-key branch January 29, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User [API] key generation
2 participants