mirror of
https://github.com/pretix/pretix.git
synced 2026-08-23 12:51:59 +00:00
SSO Providers: Use redacted field for secret key
This commit is contained in:
@@ -58,7 +58,8 @@ from pretix.api.models import WebHook
|
|||||||
from pretix.api.webhooks import get_all_webhook_events
|
from pretix.api.webhooks import get_all_webhook_events
|
||||||
from pretix.base.customersso.oidc import oidc_validate_and_complete_config
|
from pretix.base.customersso.oidc import oidc_validate_and_complete_config
|
||||||
from pretix.base.forms import (
|
from pretix.base.forms import (
|
||||||
I18nMarkdownTextarea, I18nModelForm, PlaceholderValidator, SettingsForm,
|
SECRET_REDACTED, I18nMarkdownTextarea, I18nModelForm, PlaceholderValidator,
|
||||||
|
SecretKeySettingsField, SettingsForm,
|
||||||
)
|
)
|
||||||
from pretix.base.forms.questions import (
|
from pretix.base.forms.questions import (
|
||||||
NamePartsFormField, WrappedPhoneNumberPrefixWidget, get_country_by_locale,
|
NamePartsFormField, WrappedPhoneNumberPrefixWidget, get_country_by_locale,
|
||||||
@@ -958,7 +959,7 @@ class SSOProviderForm(I18nModelForm):
|
|||||||
label=pgettext_lazy('sso_oidc', 'Client ID'),
|
label=pgettext_lazy('sso_oidc', 'Client ID'),
|
||||||
required=False,
|
required=False,
|
||||||
)
|
)
|
||||||
config_oidc_client_secret = forms.CharField(
|
config_oidc_client_secret = SecretKeySettingsField(
|
||||||
label=pgettext_lazy('sso_oidc', 'Client secret'),
|
label=pgettext_lazy('sso_oidc', 'Client secret'),
|
||||||
required=False,
|
required=False,
|
||||||
)
|
)
|
||||||
@@ -1015,7 +1016,13 @@ class SSOProviderForm(I18nModelForm):
|
|||||||
if self.instance and self.instance.method == method:
|
if self.instance and self.instance.method == method:
|
||||||
f.initial = self.instance.configuration.get(suffix)
|
f.initial = self.instance.configuration.get(suffix)
|
||||||
|
|
||||||
|
def _unmask_secret_fields(self):
|
||||||
|
for k, v in self.cleaned_data.items():
|
||||||
|
if isinstance(self.fields.get(k), SecretKeySettingsField) and self.cleaned_data.get(k) == SECRET_REDACTED:
|
||||||
|
self.cleaned_data[k] = self.fields[k].initial
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
self._unmask_secret_fields()
|
||||||
data = self.cleaned_data
|
data = self.cleaned_data
|
||||||
if not data.get("method"):
|
if not data.get("method"):
|
||||||
return data
|
return data
|
||||||
|
|||||||
Reference in New Issue
Block a user