mirror of https://github.com/vernonkeenan/lib
101 lines
2.9 KiB
Go
101 lines
2.9 KiB
Go
package app
|
|
|
|
import (
|
|
"code.tnxs.net/vernonkeenan/lib/api/members/members_models"
|
|
"github.com/go-openapi/runtime"
|
|
)
|
|
|
|
// UserActivityWrapper wraps the object with workflow params
|
|
type UserActivityWrapper struct {
|
|
Obj members_models.User
|
|
APIKey string
|
|
SagaID string
|
|
SagaType string
|
|
}
|
|
|
|
// User is a first class object type
|
|
type User struct {
|
|
ID string
|
|
AboutMe string
|
|
AccountID string
|
|
Address *Address
|
|
Alias string
|
|
APIKey string
|
|
Auth runtime.ClientAuthInfoWriter
|
|
Auth0UserID string
|
|
CommunityNickname string
|
|
CompanyName string
|
|
ContactID string
|
|
CreatedByID string
|
|
CreatedDate string
|
|
DelegatedApproverID string
|
|
Department string
|
|
Division string
|
|
Email string
|
|
EmployeeNumber string
|
|
EndOfDay string
|
|
Environment string
|
|
Extension string
|
|
FabricAPIKey string
|
|
Fax string
|
|
FirstName string
|
|
ForecastEnabled bool
|
|
FullPhotoURL string
|
|
IsActive bool
|
|
IsPortalEnabled bool
|
|
IsProfilePhotoActive bool
|
|
IsSystemControlled bool
|
|
LastIP string
|
|
LastLogin string
|
|
LastModifiedByID string
|
|
LastModifiedDate string
|
|
LastName string
|
|
LoginCount int64
|
|
ManagerID string
|
|
MobilePhone string
|
|
Name string
|
|
OutOfOfficeMessage string
|
|
Phone string
|
|
PortalRole string
|
|
PrincipalKey string
|
|
PrincipalType string
|
|
ProfileID string
|
|
ReceivesAdminEmails bool
|
|
ReceivesAdminInfoEmails bool
|
|
ReceivesInfoEmails bool
|
|
SenderEmail string
|
|
SenderName string
|
|
Signature string
|
|
Scopes []string
|
|
SmallPhotoURL string
|
|
StartOfDay string
|
|
ExternalAccount string
|
|
TenantID string
|
|
TenantUsers []*TenantUser
|
|
TimeZone string
|
|
Title string
|
|
Username string
|
|
UserRoles []*UserRole
|
|
UserRoleID string
|
|
UserType string
|
|
}
|
|
|
|
// HasScope reports whether a native service principal has an exact mesh
|
|
// authorization scope. Legacy user principals have no scopes.
|
|
func (u *User) HasScope(scope string) bool {
|
|
if u == nil || u.PrincipalType != "service" {
|
|
return false
|
|
}
|
|
for _, granted := range u.Scopes {
|
|
if granted == scope {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// IsServicePrincipal matches stable machine identity, never a bearer secret.
|
|
func (u *User) IsServicePrincipal(principalKey string) bool {
|
|
return u != nil && u.PrincipalType == "service" && u.PrincipalKey == principalKey
|
|
}
|