outposts: add API for default config
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
21ea527623
commit
e5ff416c2d
|
@ -31,7 +31,6 @@ from authentik.flows.transfer.common import DataclassEncoder
|
|||
from authentik.flows.transfer.exporter import FlowExporter
|
||||
from authentik.flows.transfer.importer import FlowImporter
|
||||
from authentik.flows.views import SESSION_KEY_PLAN
|
||||
from authentik.lib.utils.urls import redirect_with_qs
|
||||
from authentik.lib.views import bad_request_message
|
||||
|
||||
LOGGER = get_logger()
|
||||
|
|
|
@ -9,7 +9,7 @@ from rest_framework.serializers import JSONField, ModelSerializer, Serializer
|
|||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from authentik.core.api.providers import ProviderSerializer
|
||||
from authentik.outposts.models import Outpost
|
||||
from authentik.outposts.models import Outpost, default_outpost_config
|
||||
|
||||
|
||||
class OutpostSerializer(ModelSerializer):
|
||||
|
@ -32,6 +32,18 @@ class OutpostSerializer(ModelSerializer):
|
|||
]
|
||||
|
||||
|
||||
class OutpostDefaultConfigSerializer(Serializer):
|
||||
"""Global default outpost config"""
|
||||
|
||||
config = JSONField(read_only=True)
|
||||
|
||||
def create(self, validated_data: dict) -> Model:
|
||||
raise NotImplementedError
|
||||
|
||||
def update(self, instance: Model, validated_data: dict) -> Model:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class OutpostHealthSerializer(Serializer):
|
||||
"""Outpost health status"""
|
||||
|
||||
|
@ -78,3 +90,9 @@ class OutpostViewSet(ModelViewSet):
|
|||
}
|
||||
)
|
||||
return Response(OutpostHealthSerializer(states, many=True).data)
|
||||
|
||||
@swagger_auto_schema(responses={200: OutpostDefaultConfigSerializer(many=False)})
|
||||
@action(detail=False, methods=["GET"])
|
||||
def default_settings(self, request: Request) -> Response:
|
||||
"""Global default outpost config"""
|
||||
return Response({"config": default_outpost_config(request._request.get_host())})
|
||||
|
|
|
@ -80,9 +80,9 @@ class OutpostType(models.TextChoices):
|
|||
PROXY = "proxy"
|
||||
|
||||
|
||||
def default_outpost_config():
|
||||
def default_outpost_config(host: Optional[str] = None):
|
||||
"""Get default outpost config"""
|
||||
return asdict(OutpostConfig(authentik_host=""))
|
||||
return asdict(OutpostConfig(authentik_host=host or ""))
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
49
swagger.yaml
49
swagger.yaml
|
@ -4496,6 +4496,48 @@ paths:
|
|||
tags:
|
||||
- outposts
|
||||
parameters: []
|
||||
/outposts/outposts/default_settings/:
|
||||
get:
|
||||
operationId: outposts_outposts_default_settings
|
||||
description: Global default outpost config
|
||||
parameters:
|
||||
- name: providers__isnull
|
||||
in: query
|
||||
description: ''
|
||||
required: false
|
||||
type: string
|
||||
- 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
|
||||
responses:
|
||||
'200':
|
||||
description: ''
|
||||
schema:
|
||||
$ref: '#/definitions/OutpostDefaultConfig'
|
||||
'403':
|
||||
description: Authentication credentials were invalid, absent or insufficient.
|
||||
schema:
|
||||
$ref: '#/definitions/GenericError'
|
||||
tags:
|
||||
- outposts
|
||||
parameters: []
|
||||
/outposts/outposts/{uuid}/:
|
||||
get:
|
||||
operationId: outposts_outposts_read
|
||||
|
@ -15658,6 +15700,13 @@ definitions:
|
|||
_config:
|
||||
title: config
|
||||
type: object
|
||||
OutpostDefaultConfig:
|
||||
type: object
|
||||
properties:
|
||||
config:
|
||||
title: Config
|
||||
type: object
|
||||
readOnly: true
|
||||
OutpostHealth:
|
||||
type: object
|
||||
properties:
|
||||
|
|
|
@ -71,7 +71,7 @@ export class GroupForm extends Form<Group> {
|
|||
label=${gettext("Members")}
|
||||
?required=${true}
|
||||
name="users">
|
||||
<select name="users" class="pf-c-form-control" multiple>
|
||||
<select class="pf-c-form-control" multiple>
|
||||
${until(new CoreApi(DEFAULT_CONFIG).coreUsersList({}).then(users => {
|
||||
return users.results.map(user => {
|
||||
const selected = Array.from(this.group?.users || []).some(su => {
|
||||
|
|
Reference in New Issue