diff --git a/authentik/core/api/tokens.py b/authentik/core/api/tokens.py index 0133506f9..5be8478da 100644 --- a/authentik/core/api/tokens.py +++ b/authentik/core/api/tokens.py @@ -49,5 +49,7 @@ class TokenViewSet(ModelViewSet): if not tokens.exists(): raise Http404 token = tokens.first() - Event.new(EventAction.SECRET_VIEW, token=token).from_http(request) + Event.new( # noqa # nosec + EventAction.SECRET_VIEW, secret=token + ).from_http(request) return Response(TokenViewSerializer({"key": token.key}).data) diff --git a/authentik/events/migrations/0013_auto_20210209_1657.py b/authentik/events/migrations/0013_auto_20210209_1657.py index abd909a44..57a9af700 100644 --- a/authentik/events/migrations/0013_auto_20210209_1657.py +++ b/authentik/events/migrations/0013_auto_20210209_1657.py @@ -10,9 +10,13 @@ def token_view_to_secret_view(apps: Apps, schema_editor: BaseDatabaseSchemaEdito db_alias = schema_editor.connection.alias Event = apps.get_model("authentik_events", "Event") - Event.objects.using(db_alias).filter(action="token_view").update( - action=EventAction.SECRET_VIEW - ) + events = Event.objects.using(db_alias).filter(action="token_view") + + for event in events: + event.context["secret"] = event.context.pop("token") + event.action = EventAction.SECRET_VIEW + + Event.objects.using(db_alias).bulk_update(events, ["context", "action"]) class Migration(migrations.Migration): diff --git a/web/src/pages/events/EventInfo.ts b/web/src/pages/events/EventInfo.ts index bd5632ad5..a540398ca 100644 --- a/web/src/pages/events/EventInfo.ts +++ b/web/src/pages/events/EventInfo.ts @@ -91,8 +91,8 @@ export class EventInfo extends LitElement { ${this.defaultResponse()}`; case "secret_view": return html` -

${gettext("Token:")}

- ${this.getModelInfo(this.event.context.token as EventContext)}`; +

${gettext("Secret:")}

+ ${this.getModelInfo(this.event.context.secret as EventContext)}`; case "property_mapping_exception": return html`