mirror of https://github.com/harness/drone.git
put anonymous into illegal principal uids
parent
0ff77052f7
commit
71ea1947b2
|
@ -39,6 +39,10 @@ var (
|
||||||
// illegalRootSpaceIdentifiers is the list of space identifier we are blocking for root spaces
|
// illegalRootSpaceIdentifiers is the list of space identifier we are blocking for root spaces
|
||||||
// as they might cause issues with routing.
|
// as they might cause issues with routing.
|
||||||
illegalRootSpaceIdentifiers = []string{"api", "git"}
|
illegalRootSpaceIdentifiers = []string{"api", "git"}
|
||||||
|
|
||||||
|
// illegalPrincipalUID is the UID we are blocking for principals
|
||||||
|
// as they might cause issues with system generated values.
|
||||||
|
illegalPrincipalUID = "anonymous"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -74,6 +78,10 @@ var (
|
||||||
ErrIllegalRepoSpaceIdentifierSuffix = &ValidationError{
|
ErrIllegalRepoSpaceIdentifierSuffix = &ValidationError{
|
||||||
fmt.Sprintf("Space and repository identifiers cannot end with %q.", illegalRepoSpaceIdentifierSuffix),
|
fmt.Sprintf("Space and repository identifiers cannot end with %q.", illegalRepoSpaceIdentifierSuffix),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrIllegalPrincipalUID = &ValidationError{
|
||||||
|
fmt.Sprintf("Principal UID is not allowed to be %q.", illegalPrincipalUID),
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// DisplayName checks the provided display name and returns an error if it isn't valid.
|
// DisplayName checks the provided display name and returns an error if it isn't valid.
|
||||||
|
@ -143,7 +151,15 @@ type PrincipalUID func(uid string) error
|
||||||
|
|
||||||
// PrincipalUIDDefault performs the default Principal UID check.
|
// PrincipalUIDDefault performs the default Principal UID check.
|
||||||
func PrincipalUIDDefault(uid string) error {
|
func PrincipalUIDDefault(uid string) error {
|
||||||
return Identifier(uid)
|
if err := Identifier(uid); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if uid == illegalPrincipalUID {
|
||||||
|
return ErrIllegalPrincipalUID
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SpaceIdentifier is an abstraction of a validation method that returns true
|
// SpaceIdentifier is an abstraction of a validation method that returns true
|
||||||
|
|
Loading…
Reference in New Issue