Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: auth method order of list idp #1408

Merged
merged 4 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions src/bk-user/bkuser/apps/data_source/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class DataSourcePlugin(models.Model):
description = models.TextField("描述", default="", blank=True)
logo = models.TextField("Logo", null=True, blank=True, default="")

class Meta:
ordering = ["created_at"]


class DataSourceManager(models.Manager):
"""数据源管理器类"""
Expand Down
4 changes: 4 additions & 0 deletions src/bk-user/bkuser/apps/idp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class IdpPlugin(models.Model):
description = models.TextField("描述", default="", blank=True)
logo = models.TextField("Logo", null=True, blank=True, default="")

class Meta:
ordering = ["created_at"]


class Idp(AuditedModel):
"""认证源"""
Expand All @@ -49,6 +52,7 @@ class Idp(AuditedModel):
allow_bind_scopes = models.JSONField("允许范围", default=list)

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