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

ROX-28388: Log the event of an API token creation #14526

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

parametalol
Copy link
Contributor

@parametalol parametalol commented Mar 6, 2025

Description

  • Add message to the central log
  • Issue the according administration event

User-facing documentation

  • CHANGELOG is updated OR update is not needed
  • documentation PR is created and is linked above OR is not needed

Testing and quality

  • the change is production ready: the change is GA or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

Unit tests.

Log message:

apitoken/creation: 2025/03/06 13:21:53.626725 log.go:27: Warn: An API token has been created {"err_code": "token-created", "api_token_name": "Log Token Creation Test", "api_token_id": "3c4f0797-74fd-4ac9-9c5e-dee2a011ef22", "roles": ["Configuration Controller"], "user_id": "sso:4df1b98c-24ed-4073-a9ad-356aec6bb62d:admin", "user_auth_provider": "basic Login with username/password"}

Administration event

image

@parametalol parametalol requested a review from a team as a code owner March 6, 2025 10:52
@rhacs-bot
Copy link
Contributor

rhacs-bot commented Mar 6, 2025

Images are ready for the commit at 2a5880c.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.8.x-159-g2a5880c595.

Copy link

codecov bot commented Mar 6, 2025

Codecov Report

Attention: Patch coverage is 76.47059% with 4 lines in your changes missing coverage. Please review.

Project coverage is 49.11%. Comparing base (d124712) to head (2a5880c).
Report is 22 commits behind head on master.

Files with missing lines Patch % Lines
central/apitoken/expiration/expiration.go 0.00% 2 Missing ⚠️
central/apitoken/service/service_impl.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #14526      +/-   ##
==========================================
+ Coverage   49.08%   49.11%   +0.02%     
==========================================
  Files        2522     2523       +1     
  Lines      184227   184284      +57     
==========================================
+ Hits        90434    90510      +76     
+ Misses      86585    86568      -17     
+ Partials     7208     7206       -2     
Flag Coverage Δ
go-unit-tests 49.11% <76.47%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@parametalol parametalol requested a review from rukletsov March 6, 2025 12:36
@rukletsov rukletsov requested a review from rhybrillou March 6, 2025 15:09
@parametalol
Copy link
Contributor Author

/retest

@@ -17,7 +17,8 @@ var (
hints = map[string]map[string]map[string]string{
authenticationDomain: {
adminResources.APIToken: {
"": `An API token is about to expire. See the details on the expiration time within the event message.
codes.TokenCreated: `An API token has been created.`,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
codes.TokenCreated: `An API token has been created.`,
codes.TokenCreated: `An API token has been created; consider using machine-to-machine authentication instead.`,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants