Rename function to SanitizeSSHUserPrincipal
This commit is contained in:
parent
53f62f871c
commit
41b97372e6
2 changed files with 6 additions and 6 deletions
|
@ -307,7 +307,7 @@ func (o *OIDC) authorizeSSHSign(claims *openIDPayload) ([]SignOption, error) {
|
||||||
if o.IsAdmin(claims.Email) {
|
if o.IsAdmin(claims.Email) {
|
||||||
signOptions = append(signOptions, &sshCertificateOptionsValidator{})
|
signOptions = append(signOptions, &sshCertificateOptionsValidator{})
|
||||||
} else {
|
} else {
|
||||||
name := SanitizeSSHPrincipal(claims.Email)
|
name := SanitizeSSHUserPrincipal(claims.Email)
|
||||||
if !sshUserRegex.MatchString(name) {
|
if !sshUserRegex.MatchString(name) {
|
||||||
return nil, errors.Errorf("invalid principal '%s' from email address '%s'", name, claims.Email)
|
return nil, errors.Errorf("invalid principal '%s' from email address '%s'", name, claims.Email)
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,11 +165,11 @@ func (l *List) UnmarshalJSON(data []byte) error {
|
||||||
|
|
||||||
var sshUserRegex = regexp.MustCompile("^[a-z][-a-z0-9_]*$")
|
var sshUserRegex = regexp.MustCompile("^[a-z][-a-z0-9_]*$")
|
||||||
|
|
||||||
// SanitizeSSHPrincipal grabs an email or a string with the format local@domain
|
// SanitizeSSHUserPrincipal grabs an email or a string with the format
|
||||||
// and returns a sanitized version of the local, valid to be used as a user
|
// local@domain and returns a sanitized version of the local, valid to be used
|
||||||
// name. If the email starts with a letter between a and z, the resulting string
|
// as a user name. If the email starts with a letter between a and z, the
|
||||||
// will match the regular expression `^[a-z][-a-z0-9_]*$`.
|
// resulting string will match the regular expression `^[a-z][-a-z0-9_]*$`.
|
||||||
func SanitizeSSHPrincipal(email string) string {
|
func SanitizeSSHUserPrincipal(email string) string {
|
||||||
if i := strings.LastIndex(email, "@"); i >= 0 {
|
if i := strings.LastIndex(email, "@"); i >= 0 {
|
||||||
email = email[:i]
|
email = email[:i]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue