diff --git a/authentik/core/api/tokens.py b/authentik/core/api/tokens.py index a109a684e..c4f8e0b7c 100644 --- a/authentik/core/api/tokens.py +++ b/authentik/core/api/tokens.py @@ -25,12 +25,12 @@ class TokenSerializer(ManagedSerializer, ModelSerializer): user = UserSerializer(required=False) - def validate(self, data: dict[Any, str]) -> dict[Any, str]: + def validate(self, attrs: dict[Any, str]) -> dict[Any, str]: """Ensure only API or App password tokens are created.""" - data.setdefault("intent", TokenIntents.INTENT_API) - if data.get("intent") not in [TokenIntents.INTENT_API, TokenIntents.INTENT_APP_PASSWORD]: - raise ValidationError(f"Invalid intent {data.get('intent')}") - return data + attrs.setdefault("intent", TokenIntents.INTENT_API) + if attrs.get("intent") not in [TokenIntents.INTENT_API, TokenIntents.INTENT_APP_PASSWORD]: + raise ValidationError(f"Invalid intent {attrs.get('intent')}") + return attrs class Meta: diff --git a/authentik/flows/transfer/common.py b/authentik/flows/transfer/common.py index fb42282ad..031a43e2d 100644 --- a/authentik/flows/transfer/common.py +++ b/authentik/flows/transfer/common.py @@ -25,6 +25,8 @@ def get_attrs(obj: SerializerModel) -> dict[str, Any]: "component", "flow_set", "promptstage_set", + "policybindingmodel_ptr_id", + "export_url", ) for to_remove_name in to_remove: if to_remove_name in data: diff --git a/web/src/pages/stages/identification/IdentificationStageForm.ts b/web/src/pages/stages/identification/IdentificationStageForm.ts index dd9b67097..b29ad8688 100644 --- a/web/src/pages/stages/identification/IdentificationStageForm.ts +++ b/web/src/pages/stages/identification/IdentificationStageForm.ts @@ -156,11 +156,20 @@ export class IdentificationStageForm extends ModelForm { return sources.results.map((source) => { - const selected = Array.from( + let selected = Array.from( this.instance?.sources || [], ).some((su) => { return su == source.pk; }); + // Creating a new instance, auto-select built-in source + // Only when no other sources exist + if ( + !this.instance && + source.component === "" && + sources.results.length < 2 + ) { + selected = true; + } return html`