Skip to content

include backfill method and exact function run - #1751

Merged
dsweber2 merged 4 commits into
devfrom
APIKeyBackfill
Aug 3, 2026
Merged

include backfill method and exact function run#1751
dsweber2 merged 4 commits into
devfrom
APIKeyBackfill

Conversation

@dsweber2

@dsweber2 dsweber2 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary:

Adds a backfill method to the API script in case the script is ever turned off

Prerequisites:

  • Unless it is a documentation hotfix it should be merged against the dev branch
  • Branch is up-to-date with the branch to be merged with, i.e. dev
  • Build is successful
  • Code is cleaned up and formatted

Comment thread src/server/admin/api_key_form_script.js Fixed
Comment thread src/server/endpoints/admin.py Fixed
Comment thread src/server/admin/api_key_form_script.js Fixed
Comment thread src/server/endpoints/admin.py Outdated
return make_response("No user found with that email address", 404)
existing_roles = {role.name for role in user.roles}
User.update_user(user=user, api_key=user_api_key, email=user_email, roles=existing_roles, session=session)
return make_response(f"Successfully replaced API key for {user_email}", 200, {"Content-Type": "text/plain"})
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

var latestResponse = allResponses[allResponses.length - 1];

var user_api_key = Math.random().toString(16).substr(2, 18);
var user_api_key = Utilities.getUuid().replace(/-/g, '');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a core change to the key gen algorithm. Is that intended?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was mollifying sonarcloud

@dshemetov dshemetov Jul 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...so we're changing our user key gen algo to appease a linter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a linter, its a security check, and it is right about it. I don't think this is a big deal to change

noReply: true,
body: `
API Key was not generated.
Logger.log('Email already registered, replacing key for %s', user_email);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): this code block is reused a couple times that it might be worth turning it into a function, where the email body is an argument. And then you could mock that function out for dry run testing, if needed

@dshemetov

dshemetov commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This sonarcloud code analysis is way too loud and noisy for the level of comments it generates (const var vs var is really not a code red emergency). If you find some way to be able to read a gh pr diff without that stuff inline, I'd be happy to hear about it

@nolangormley nolangormley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dsweber2
dsweber2 merged commit e573174 into dev Aug 3, 2026
7 of 8 checks passed
@dsweber2
dsweber2 deleted the APIKeyBackfill branch August 3, 2026 17:57
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.

4 participants