Compare commits
3 Commits
openapi-ge
...
outpost-fo
Author | SHA1 | Date | |
---|---|---|---|
bf9ac25740 | |||
95cd7ec904 | |||
3985725550 |
@ -4,7 +4,8 @@ from dacite.core import from_dict
|
|||||||
from dacite.exceptions import DaciteError
|
from dacite.exceptions import DaciteError
|
||||||
from django_filters.filters import ModelMultipleChoiceFilter
|
from django_filters.filters import ModelMultipleChoiceFilter
|
||||||
from django_filters.filterset import FilterSet
|
from django_filters.filterset import FilterSet
|
||||||
from drf_spectacular.utils import extend_schema
|
from drf_spectacular.types import OpenApiTypes
|
||||||
|
from drf_spectacular.utils import OpenApiResponse, extend_schema
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
from rest_framework.fields import BooleanField, CharField, DateTimeField, SerializerMethodField
|
from rest_framework.fields import BooleanField, CharField, DateTimeField, SerializerMethodField
|
||||||
@ -29,9 +30,11 @@ from authentik.outposts.models import (
|
|||||||
OutpostType,
|
OutpostType,
|
||||||
default_outpost_config,
|
default_outpost_config,
|
||||||
)
|
)
|
||||||
|
from authentik.outposts.tasks import outpost_send_update
|
||||||
from authentik.providers.ldap.models import LDAPProvider
|
from authentik.providers.ldap.models import LDAPProvider
|
||||||
from authentik.providers.proxy.models import ProxyProvider
|
from authentik.providers.proxy.models import ProxyProvider
|
||||||
from authentik.providers.radius.models import RadiusProvider
|
from authentik.providers.radius.models import RadiusProvider
|
||||||
|
from authentik.rbac.decorators import permission_required
|
||||||
|
|
||||||
|
|
||||||
class OutpostSerializer(ModelSerializer):
|
class OutpostSerializer(ModelSerializer):
|
||||||
@ -200,3 +203,18 @@ class OutpostViewSet(UsedByMixin, ModelViewSet):
|
|||||||
"""Global default outpost config"""
|
"""Global default outpost config"""
|
||||||
host = self.request.build_absolute_uri("/")
|
host = self.request.build_absolute_uri("/")
|
||||||
return Response({"config": default_outpost_config(host)})
|
return Response({"config": default_outpost_config(host)})
|
||||||
|
|
||||||
|
@permission_required(None, ["authentik_outposts.refresh_outpost"])
|
||||||
|
@extend_schema(
|
||||||
|
request=OpenApiTypes.NONE,
|
||||||
|
responses={
|
||||||
|
204: OpenApiResponse(description="Successfully refreshed outpost"),
|
||||||
|
400: OpenApiResponse(description="Bad request"),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
@action(detail=True, methods=["POST"])
|
||||||
|
def force_refresh(self, request: Request, pk: int) -> Response:
|
||||||
|
"""Force an outpost to refresh its configuration. Will also clear its cache."""
|
||||||
|
outpost: Outpost = self.get_object()
|
||||||
|
outpost_send_update(outpost)
|
||||||
|
return Response(status=204)
|
||||||
|
21
authentik/outposts/migrations/0022_alter_outpost_options.py
Normal file
21
authentik/outposts/migrations/0022_alter_outpost_options.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Generated by Django 5.0.6 on 2024-07-04 15:55
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("authentik_outposts", "0021_alter_outpost_type"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name="outpost",
|
||||||
|
options={
|
||||||
|
"permissions": [("refresh_outpost", "Trigger an outpost refresh")],
|
||||||
|
"verbose_name": "Outpost",
|
||||||
|
"verbose_name_plural": "Outposts",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
@ -424,6 +424,10 @@ class Outpost(SerializerModel, ManagedModel):
|
|||||||
verbose_name = _("Outpost")
|
verbose_name = _("Outpost")
|
||||||
verbose_name_plural = _("Outposts")
|
verbose_name_plural = _("Outposts")
|
||||||
|
|
||||||
|
permissions = [
|
||||||
|
("refresh_outpost", _("Trigger an outpost refresh")),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class OutpostState:
|
class OutpostState:
|
||||||
|
28
schema.yml
28
schema.yml
@ -9432,6 +9432,34 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/GenericError'
|
$ref: '#/components/schemas/GenericError'
|
||||||
description: ''
|
description: ''
|
||||||
|
/outposts/instances/{uuid}/force_refresh/:
|
||||||
|
post:
|
||||||
|
operationId: outposts_instances_force_refresh_create
|
||||||
|
description: Force an outpost to refresh its configuration. Will also clear
|
||||||
|
its cache.
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: uuid
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: A UUID string identifying this Outpost.
|
||||||
|
required: true
|
||||||
|
tags:
|
||||||
|
- outposts
|
||||||
|
security:
|
||||||
|
- authentik: []
|
||||||
|
responses:
|
||||||
|
'204':
|
||||||
|
description: Successfully refreshed outpost
|
||||||
|
'400':
|
||||||
|
description: Bad request
|
||||||
|
'403':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/GenericError'
|
||||||
|
description: ''
|
||||||
/outposts/instances/{uuid}/health/:
|
/outposts/instances/{uuid}/health/:
|
||||||
get:
|
get:
|
||||||
operationId: outposts_instances_health_list
|
operationId: outposts_instances_health_list
|
||||||
|
@ -158,7 +158,29 @@ export class OutpostListPage extends TablePage<Outpost> {
|
|||||||
${msg("View Deployment Info")}
|
${msg("View Deployment Info")}
|
||||||
</button>
|
</button>
|
||||||
</ak-outpost-deployment-modal>`
|
</ak-outpost-deployment-modal>`
|
||||||
: html``}`,
|
: html``}
|
||||||
|
<ak-forms-confirm
|
||||||
|
successMessage=${msg("Successfully refreshed outpost")}
|
||||||
|
errorMessage=${msg("Failed to refresh outpost")}
|
||||||
|
action=${msg("Refresh configuration")}
|
||||||
|
.onConfirm=${() => {
|
||||||
|
return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesForceRefreshCreate({
|
||||||
|
uuid: item.pk,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span slot="header"> ${msg("Refresh outpost")} </span>
|
||||||
|
<p slot="body">
|
||||||
|
${msg(
|
||||||
|
`Are you sure you want to refresh this outpost?
|
||||||
|
This will cause the outpost cache to be cleared.`,
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
<button slot="trigger" class="pf-c-button pf-m-secondary" type="button">
|
||||||
|
${msg("Refresh configuration")}
|
||||||
|
</button>
|
||||||
|
<div slot="modal"></div>
|
||||||
|
</ak-forms-confirm> `,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user