Skip to content

Commit

Permalink
feat: auth method order of list idp (#1408)
Browse files Browse the repository at this point in the history
  • Loading branch information
nannan00 authored Nov 21, 2023
1 parent f3cac33 commit 1ee5c3c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/bk-user/bkuser/apis/web/idp/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
import re
from typing import Any, Dict, List

from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -75,8 +76,21 @@ def _validate_duplicate_idp_name(name: str, tenant_id: str, idp_id: str = "") ->
return name


SOURCE_FIELD_REGEX = re.compile(r"^[a-zA-Z][a-zA-Z0-9_-]{1,30}[a-zA-Z0-9]$")


def _validate_source_field(value):
"""校验认证源字段命名规则"""
if not re.fullmatch(SOURCE_FIELD_REGEX, value):
raise ValidationError(
_(
"{} 不符合认证源字段的命名规范: 由3-32位字母、数字、下划线(_)、连接符(-)字符组成,以字母开头并以字母或数字结尾" # noqa: E501
).format(value),
)


class FieldCompareRuleSLZ(serializers.Serializer):
source_field = serializers.CharField(help_text="认证源原始字段")
source_field = serializers.CharField(help_text="认证源原始字段", validators=[_validate_source_field])
target_field = serializers.CharField(help_text="匹配的数据源字段")


Expand Down
1 change: 1 addition & 0 deletions src/bk-user/bkuser/apps/idp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Idp(AuditedModel):
allow_bind_scopes = models.JSONField("允许范围", default=list)

class Meta:
ordering = ["created_at"]
unique_together = [
("name", "owner_tenant_id"),
]
Expand Down

0 comments on commit 1ee5c3c

Please sign in to comment.