Skip to content

Conversation

jasonyuezhang
Copy link
Owner

Create an audit log entry for when internal integration tokens are created or revoked.

Closes https://linear.app/getsentry/issue/RTC-29/audit-log-log-token-createsrevokes-on-custom-integrations


Copied from getsentry#101041
Original PR: getsentry#101041

Copy link

Add Audit Log Entries for Internal Integration Token Creation and Deletion

This PR introduces audit logging for the creation and revocation of internal integration tokens in Sentry. Audit entries are now generated when internal integration tokens are added or removed, ensuring changes to tokens are properly tracked within the organization's audit log. The implementation modifies token creation and deletion flows to invoke the audit logging utility, and updates automated tests to verify that audit entries are produced as expected.

Key Changes

• Added calls to create_audit_entry for both token creation (INTERNAL_INTEGRATION_ADD_TOKEN) and token deletion (INTERNAL_INTEGRATION_REMOVE_TOKEN) in internal integration token endpoints.
• Propagated the new generate_audit=True option to SentryAppInstallationTokenCreator to enable audit logging during token creation.
• Updated the call signature for create_audit_entry to use organization_id instead of organization parameter, ensuring consistency.
• Extended automated test cases in test_sentry_internal_app_token_details.py and test_sentry_internal_app_tokens.py to verify that audit log entries are recorded for both token creation and deletion actions.

Affected Areas

src/sentry/sentry_apps/api/endpoints/sentry_internal_app_token_details.py
src/sentry/sentry_apps/api/endpoints/sentry_internal_app_tokens.py
src/sentry/sentry_apps/installations.py
tests/sentry/sentry_apps/api/endpoints/test_sentry_internal_app_token_details.py
tests/sentry/sentry_apps/api/endpoints/test_sentry_internal_app_tokens.py

This summary was automatically generated by @propel-code-bot

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.

2 participants