From 3d45956f155e8221df9607456c39079fef1cd7b4 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 20 Mar 2021 19:05:10 +0100 Subject: [PATCH] web: fix display of scopes Signed-off-by: Jens Langhammer --- authentik/admin/api/metrics.py | 4 +- authentik/providers/oauth2/api/tokens.py | 2 + swagger.yaml | 46 ++++----------------- web/src/elements/charts/AdminLoginsChart.ts | 2 +- web/src/elements/oauth/UserCodeList.ts | 4 +- web/src/elements/oauth/UserRefreshList.ts | 4 +- 6 files changed, 16 insertions(+), 46 deletions(-) diff --git a/authentik/admin/api/metrics.py b/authentik/admin/api/metrics.py index 9ed67ff75..ad3943e16 100644 --- a/authentik/admin/api/metrics.py +++ b/authentik/admin/api/metrics.py @@ -13,7 +13,7 @@ from rest_framework.permissions import IsAdminUser from rest_framework.request import Request from rest_framework.response import Response from rest_framework.serializers import Serializer -from rest_framework.viewsets import ReadOnlyModelViewSet +from rest_framework.viewsets import ViewSet from authentik.events.models import Event, EventAction @@ -81,7 +81,7 @@ class LoginMetricsSerializer(Serializer): raise NotImplementedError -class AdministrationMetricsViewSet(ReadOnlyModelViewSet): +class AdministrationMetricsViewSet(ViewSet): """Login Metrics per 1h""" permission_classes = [IsAdminUser] diff --git a/authentik/providers/oauth2/api/tokens.py b/authentik/providers/oauth2/api/tokens.py index 8f9ebc4ba..f8ec0d79a 100644 --- a/authentik/providers/oauth2/api/tokens.py +++ b/authentik/providers/oauth2/api/tokens.py @@ -1,5 +1,6 @@ """OAuth2Provider API Views""" from rest_framework import mixins +from rest_framework.fields import CharField, ListField from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import GenericViewSet @@ -14,6 +15,7 @@ class ExpiringBaseGrantModelSerializer(ModelSerializer, MetaNameSerializer): user = UserSerializer() provider = OAuth2ProviderSerializer() + scope = ListField(child=CharField()) class Meta: diff --git a/swagger.yaml b/swagger.yaml index ea14438dd..f13d22513 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -24,27 +24,7 @@ paths: get: operationId: admin_metrics_list description: Login Metrics per 1h - parameters: - - name: ordering - in: query - description: Which field to use when ordering the results. - required: false - type: string - - name: search - in: query - description: A search term. - required: false - type: string - - name: page - in: query - description: Page Index - required: false - type: integer - - name: page_size - in: query - description: Page Size - required: false - type: integer + parameters: [] responses: '200': description: Login Metrics per 1h @@ -53,21 +33,6 @@ paths: tags: - admin parameters: [] - /admin/metrics/{id}/: - get: - operationId: admin_metrics_read - description: Login Metrics per 1h - parameters: [] - responses: - '200': - description: '' - tags: - - admin - parameters: - - name: id - in: path - required: true - type: string /admin/system_tasks/: get: operationId: admin_system_tasks_list @@ -11718,6 +11683,7 @@ definitions: required: - provider - user + - scope type: object properties: pk: @@ -11737,9 +11703,11 @@ definitions: type: string format: date-time scope: - title: Scope - type: string - readOnly: true + description: '' + type: array + items: + type: string + minLength: 1 Outpost: description: Outpost Serializer required: diff --git a/web/src/elements/charts/AdminLoginsChart.ts b/web/src/elements/charts/AdminLoginsChart.ts index bf0449240..9411597d3 100644 --- a/web/src/elements/charts/AdminLoginsChart.ts +++ b/web/src/elements/charts/AdminLoginsChart.ts @@ -8,7 +8,7 @@ import { DEFAULT_CONFIG } from "../../api/Config"; export class AdminLoginsChart extends AKChart { apiRequest(): Promise { - return new AdminApi(DEFAULT_CONFIG).adminMetricsList({}); + return new AdminApi(DEFAULT_CONFIG).adminMetricsList(); } getDatasets(data: LoginMetrics): Chart.ChartDataSets[] { diff --git a/web/src/elements/oauth/UserCodeList.ts b/web/src/elements/oauth/UserCodeList.ts index 9da3f80e6..ff7c99dff 100644 --- a/web/src/elements/oauth/UserCodeList.ts +++ b/web/src/elements/oauth/UserCodeList.ts @@ -35,9 +35,9 @@ export class UserOAuthCodeList extends Table { row(item: ExpiringBaseGrantModel): TemplateResult[] { return [ - html`${item.provider}`, + html`${item.provider.name}`, html`${item.expires?.toLocaleString()}`, - html`${item.scope}`, + html`${item.scope.join(", ")}`, html` { row(item: ExpiringBaseGrantModel): TemplateResult[] { return [ - html`${item.provider}`, + html`${item.provider.name}`, html`${item.expires?.toLocaleString()}`, - html`${item.scope}`, + html`${item.scope.join(", ")}`, html`