Skip to content

Commit

Permalink
remove redundant fields and track refresh tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Christinarlong committed Oct 17, 2024
1 parent 17650e2 commit 5a5821f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/sentry/mediators/token_exchange/refresher.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ def call(self):
{
"user_id": self.user.id,
"install_id": self.install.id,
"client_id": self.client_id,
"org_id": self.install.organization_id,
"sentry_app_id": self.sentry_app.id,
"sentry_app_slug": self.sentry_app.slug,
"application_id": self.application.id,
"refreh_token": self.refresh_token[-4:],
},
)

self._validate()
self._delete_token()
self._create_new_token()
token = self._create_new_token()

sentry_sdk.set_context(
"token-exchange.refresh", {"new_refresh_token": token.refresh_token[-4:]}
)
return token

def record_analytics(self):
analytics.record(
Expand Down
5 changes: 3 additions & 2 deletions src/sentry/sentry_apps/token_exchange/grant_exchanger.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ def run(self):
{
"user_id": self.user.id,
"install_id": self.install.id,
"client_id": self.client_id,
"org_id": self.install.organization_id,
"sentry_app_id": self.sentry_app.id,
"sentry_app_slug": self.sentry_app.slug,
"application_id": self.application.id,
"grant_id": self.grant.id,
},
)
self._validate()
token = self._create_token()
sentry_sdk.set_context(
"token-exchange.refresh", {"new_refresh_token": token.refresh_token[-4:]}
)

# Once it's exchanged it's no longer valid and should not be
# exchangeable, so we delete it.
Expand Down

0 comments on commit 5a5821f

Please sign in to comment.