2023-08-25 09:03:42 +00:00
|
|
|
package auth
|
|
|
|
|
|
|
|
import (
|
2023-09-05 11:20:55 +00:00
|
|
|
"github.com/google/uuid"
|
2023-08-25 09:03:42 +00:00
|
|
|
)
|
|
|
|
|
2024-03-25 11:32:45 +00:00
|
|
|
// Determines whether a given user name is a service principal.
|
|
|
|
// This function uses a heuristic: if the user name is a UUID, then we assume
|
2023-09-05 11:20:55 +00:00
|
|
|
// it's a service principal. Unfortunately, the service principal listing API is too
|
|
|
|
// slow for our purposes. And the "users" and "service principals get" APIs
|
|
|
|
// only allow access by workspace admins.
|
2024-03-25 11:32:45 +00:00
|
|
|
func IsServicePrincipal(userName string) bool {
|
|
|
|
_, err := uuid.Parse(userName)
|
2023-09-05 11:20:55 +00:00
|
|
|
return err == nil
|
2023-08-25 09:03:42 +00:00
|
|
|
}
|