Просмотр исходного кода

Rename function to SanitizeSSHUserPrincipal

Mariano Cano 7 лет назад
Родитель
Сommit
41b97372e6
2 измененных файлов с 6 добавлено и 6 удалено
  1. 1 1
      authority/provisioner/oidc.go
  2. 5 5
      authority/provisioner/provisioner.go

+ 1 - 1
authority/provisioner/oidc.go

@@ -307,7 +307,7 @@ func (o *OIDC) authorizeSSHSign(claims *openIDPayload) ([]SignOption, error) {
 	if o.IsAdmin(claims.Email) {
 		signOptions = append(signOptions, &sshCertificateOptionsValidator{})
 	} else {
-		name := SanitizeSSHPrincipal(claims.Email)
+		name := SanitizeSSHUserPrincipal(claims.Email)
 		if !sshUserRegex.MatchString(name) {
 			return nil, errors.Errorf("invalid principal '%s' from email address '%s'", name, claims.Email)
 		}

+ 5 - 5
authority/provisioner/provisioner.go

@@ -165,11 +165,11 @@ func (l *List) UnmarshalJSON(data []byte) error {
 
 var sshUserRegex = regexp.MustCompile("^[a-z][-a-z0-9_]*$")
 
-// SanitizeSSHPrincipal grabs an email or a string with the format local@domain
-// and returns a sanitized version of the local, valid to be used as a user
-// name. If the email starts with a letter between a and z, the resulting string
-// will match the regular expression `^[a-z][-a-z0-9_]*$`.
-func SanitizeSSHPrincipal(email string) string {
+// SanitizeSSHUserPrincipal grabs an email or a string with the format
+// local@domain and returns a sanitized version of the local, valid to be used
+// as a user name. If the email starts with a letter between a and z, the
+// resulting string will match the regular expression `^[a-z][-a-z0-9_]*$`.
+func SanitizeSSHUserPrincipal(email string) string {
 	if i := strings.LastIndex(email, "@"); i >= 0 {
 		email = email[:i]
 	}