{"modulePath":"github.com/CTO2BPublic/passage-server","version":"v0.3.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package models\n\n## Constants\n\n```go\nconst (\n\tAccessRequestPending  = \"Pending\"\n\tAccessRequestApproved = \"Approved\"\n\tAccessRequestDenied   = \"Denied\"\n\tAccessRequestExpired  = \"Expired\"\n\tProviderStatusGranted = \"Granted\"\n\tProviderStatusRevoked = \"Revoked\"\n\tProviderStatusError   = \"Error\"\n)\n```\nAccess request status constants\n\n## Types\n\n```go\ntype AccessRequest struct {\n\tId        string               `gorm:\"primaryKey\" json:\"id\"`\n\tCreatedAt time.Time            `gorm:\"index\" swaggerignore:\"true\" json:\"createdAt\"`\n\tUpdatedAt time.Time            `swaggerignore:\"true\" json:\"updatedAt\"`\n\tDeletedAt *time.Time           `gorm:\"index\" swaggerignore:\"true\" json:\"deletedAt,omitempty\"`\n\tRoleRef   AccessRoleRef        `gorm:\"embedded;embeddedPrefix:roleRef_\" json:\"roleRef\"`\n\tDetails   AccessRequestDetails `gorm:\"embedded;embeddedPrefix:details_\" json:\"details\"`\n\tStatus    AccessRequestStatus  `swaggerignore:\"true\" gorm:\"embedded;embeddedPrefix:status_\" json:\"status\"`\n}\n```\nAccess request\n\n```go\nfunc (a *AccessRequest) Admit() *AccessRequest\n```\n\n```go\nfunc (s *AccessRequest) GetApprovalRule() ApprovalRule\n```\n\n```go\nfunc (s *AccessRequest) GetProviderUsername(provider string) string\n```\n\n```go\nfunc (s *AccessRequest) GetRole(roles []AccessRole) (AccessRole, error)\n```\n\n```go\nfunc (s *AccessRequest) HasPermissions(user string, groups []string, utype string) bool\n```\n\n```go\nfunc (s *AccessRequest) SetApprovalRule(rule ApprovalRule) *AccessRequest\n```\n\n```go\nfunc (s *AccessRequest) SetExpiration(ctx context.Context) *AccessRequest\n```\n\n```go\nfunc (s *AccessRequest) SetProviderStatusError(provider string, details string, err string) *AccessRequest\n```\n\n```go\nfunc (s *AccessRequest) SetProviderStatusGranted(provider string, details string, err string) *AccessRequest\n```\n\n```go\nfunc (s *AccessRequest) SetProviderStatusRevoked(provider string, details string, err string) *AccessRequest\n```\n\n```go\nfunc (s *AccessRequest) SetProviderUsername(provider string, value string) *AccessRequest\n```\n\n```go\nfunc (s *AccessRequest) SetProviderUsernames(usernames map[string]string) *AccessRequest\n```\n\n```go\nfunc (a *AccessRequest) SetRequester(requester string) *AccessRequest\n```\n\n```go\nfunc (a *AccessRequest) SetStatusApprove(approvedBy string) *AccessRequest\n```\nMethod to approve the access request\n\n```go\nfunc (a *AccessRequest) SetStatusDenied(approvedBy string) *AccessRequest\n```\nMethod to deny the access request\n\n```go\nfunc (a *AccessRequest) SetStatusExpired() *AccessRequest\n```\nMethod to expire the access request\n\n```go\nfunc (a *AccessRequest) SetStatusPending() *AccessRequest\n```\nMethod to set the access request to pending\n\n```go\nfunc (s *AccessRequest) SetTraceId(ctx context.Context) *AccessRequest\n```\n\n```go\ntype AccessRequestDetails struct {\n\tJustification string                 `json:\"justification\" example:\"Need to access k8s namespace\"`\n\tAttributes    map[string]interface{} `json:\"attributes\" gorm:\"serializer:json\"`\n\tTTL           string                 `json:\"ttl\" example:\"72h\"`\n}\n```\n\n```go\ntype AccessRequestStatus struct {\n\tStatus            string                    `json:\"status\"`\n\tApprovedBy        string                    `json:\"approvedBy\"`\n\tRequestedBy       string                    `json:\"requestedBy\"`\n\tApprovalRule      ApprovalRule              `json:\"approvalRule\" gorm:\"serializer:json\"`\n\tProviderUsernames map[string]string         `json:\"providerUsernames\" gorm:\"serializer:json\"`\n\tProviderStatuses  map[string]ProviderStatus `json:\"providerStatuses\" gorm:\"serializer:json\"`\n\tExpiresAt         *time.Time\n\tTrace             string `json:\"trace\"`\n}\n```\n\n```go\ntype AccessRole struct {\n\tId              string            `gorm:\"primaryKey\" json:\"id,omitempty\" example:\"3b7af992-5a30-4ce1-821b-cac8194a230b\"`\n\tName            string            `json:\"name\"`\n\tDescription     string            `json:\"description\"`\n\tTags            []string          `json:\"tags\" gorm:\"serializer:json\"`\n\tAnnotations     map[string]string `json:\"annotations\" gorm:\"serializer:json\"`\n\tProviders       []ProviderConfig  `json:\"providers\" gorm:\"serializer:json\"` // Multiple access mappings for the role\n\tApprovalRuleRef ApprovalRuleRef   `json:\"approvalRuleRef\" gorm:\"embedded;embeddedPrefix:approvalRuleRef_\"`\n}\n```\nAccess role\n\n```go\nfunc (a *AccessRole) GetApprovalRule(rules []ApprovalRule) ApprovalRule\n```\n\n```go\nfunc (a *AccessRole) HasAccessRolePermissions(user string, groups []string, rules []ApprovalRule) bool\n```\nHasApprovalPermission checks if a user is allowed to approve based on the approval rule.\n\n```go\ntype AccessRoleRef struct {\n\tName string `json:\"name\" example:\"SRE-PU-ACCESS\"`\n}\n```\n\n```go\ntype ActivityLog struct {\n\tID         string    `gorm:\"primaryKey\" json:\"id\" example:\"0d2dab7cdcb4cf1d\"`\n\tDate       time.Time `gorm:\"index\" json:\"date\"`\n\tSeverity   string    `json:\"severity\"`\n\tRaisedBy   string    `json:\"raisedBy\"`\n\tApprovedBy string    `json:\"approvedBy\"`\n\tType       string    `json:\"type\"`\n\tRole       string    `json:\"role\"`\n\tMessage    string    `json:\"message\"`\n\tRequestID  string    `json:\"requestId\"`\n\tEventID    string    `json:\"eventId\"`\n}\n```\n\n```go\nfunc NewActivityLogFromEvent(e Event) (*ActivityLog, error)\n```\n\n```go\ntype ApprovalRule struct {\n\tName             string   `json:\"string\"`\n\tAuthorCanApprove bool     `json:\"authorCanApprove\"`\n\tUsers            []string `json:\"users\"`\n\tGroups           []string `json:\"groups\"`\n}\n```\n\n```go\ntype ApprovalRuleRef struct {\n\tName string `json:\"name\"`\n}\n```\n\n```go\ntype ClaimsMap struct {\n\tClaims                map[string]interface{} `json:\"-\"`\n\t*jwt.RegisteredClaims `swaggerignore:\"true\"`\n}\n```\nClaimsMap wraps a map\\[string]interface{} to represent dynamic claims\n\n```go\nfunc NewClaimsMap() ClaimsMap\n```\n\n```go\nfunc NewUnauthenticatedUserClaims() ClaimsMap\n```\n\n```go\nfunc (c ClaimsMap) GetMap(key string) map[string]interface{}\n```\nGetMap extracts a map\\[string]interface{} field from the claims map\n\n```go\nfunc (c ClaimsMap) GetProviderUsernamesFromClaim(claim string) map[string]string\n```\n\n```go\nfunc (c ClaimsMap) GetString(key string) string\n```\n\n```go\nfunc (c ClaimsMap) GetStringSlice(key string) []string\n```\nGetStringSlice extracts a string slice from ClaimsMap.\n\n```go\nfunc (c ClaimsMap) MarshalJSON() ([]byte, error)\n```\n\n```go\nfunc (c *ClaimsMap) UnmarshalJSON(data []byte) error\n```\n\n```go\nfunc (c ClaimsMap) Valid() error\n```\nValid implements the jwt.Claims interface\n\n```go\ntype Credential struct {\n\tName       string               `json:\"name\"`\n\tFromSecret CredentialFromSecret `json:\"fromSecret\"`\n\tData       map[string]string    `json:\"data\" gorm:\"serializer:json\"`\n}\n```\n\n```go\nfunc (c *Credential) GetString(key string) string\n```\n\n```go\ntype CredentialFromSecret struct {\n\tName string `json:\"name\"`\n}\n```\n\n```go\ntype CredentialRef struct {\n\tName string `json:\"name,omitempty\"`\n}\n```\n\n```go\ntype Event struct {\n\tID            string            `gorm:\"primaryKey\" json:\"id\" example:\"0d2dab7cdcb4cf1d\"` // Pod ID\n\tCreatedAt     time.Time         `swaggerignore:\"true\" json:\"createdAt,omitempty\"`\n\tUpdatedAt     time.Time         `swaggerignore:\"true\" json:\"updatedAt,omitempty\"`\n\tTransactionID string            `gorm:\"index\" json:\"transactionId\" example:\"0d2dab7cdcb4cf1d\"`\n\tParentID      string            `gorm:\"index\" swaggerignore:\"true\" json:\"parentId\"`\n\tParentType    EventParentType   `gorm:\"index\" swaggerignore:\"true\" json:\"parentType\"`\n\tTenant        string            `gorm:\"index\" swaggerignore:\"true\" json:\"tenant\"`\n\tAttributes    EventAttributes   `gorm:\"embedded;embeddedPrefix:attributes_\" json:\"attributes\"`\n\tMessage       string            `json:\"message\"`\n\tData          datatypes.JSONMap `swaggerignore:\"true\" json:\"data\"`\n}\n```\n\n```go\ntype EventAttributes struct {\n\tSource string    `gorm:\"index\" example:\"sview-hook\" json:\"source\"`\n\tType   string    `gorm:\"index\" example:\"gitlab-mr\" json:\"type\"`\n\tDate   time.Time `gorm:\"index\" example:\"2022-02-28 18:03:49.750647+00\" json:\"date\"`\n\tAuthor string    `gorm:\"index\" example:\"john.doe\" json:\"author\"`\n}\n```\n\n```go\nfunc (a *EventAttributes) UnmarshalJSON(data []byte) error\n```\n\n```go\ntype EventParentType string\n```\n\n```go\nconst (\n\tEventParentApplication EventParentType = \"application\"\n\tEventParentParameter   EventParentType = \"parameter\"\n\tEventParentSystem      EventParentType = \"system\"\n\tEventParentSecurity    EventParentType = \"security\"\n)\n```\n\n```go\ntype Health struct {\n\tHealthy bool `json:\"healthy\"`\n}\n```\n\n```go\ntype ProviderConfig struct {\n\tName          string            `json:\"name\"`\n\tRunAsync      bool              `json:\"runAsync\"`\n\tProvider      string            `json:\"provider\"`\n\tCredentialRef CredentialRef     `json:\"credentialRef\" gorm:\"embedded;embeddedPrefix:credentialRef_\"`\n\tParameters    map[string]string `json:\"parameters\" gorm:\"serializer:json\"`\n}\n```\n\n```go\ntype ProviderStatus struct {\n\tAction  string `json:\"action\" example:\"Granted\"`\n\tDetails string `json:\"details\" example:\"Group: sre-pu-sers\"`\n\tError   string `json:\"error\" example:\"Group does not exist\"`\n}\n```\n\n```go\ntype ProviderUsernames struct {\n\tProviderUsernames map[string]string `json:\"providerUsernames\" gorm:\"serializer:json\"`\n}\n```\n\n```go\ntype User struct {\n\tId       string   `gorm:\"primaryKey\" json:\"id\"`\n\tUsername string   `json:\"username\"`\n\tRoles    []string `json:\"roles,omitempty\"`\n}\n```\n\n```go\ntype UserProfile struct {\n\tId       string              `gorm:\"primaryKey\" json:\"id\"`\n\tUsername string              `json:\"username\"`\n\tSettings UserProfileSettings `json:\"settings\" gorm:\"embedded;embeddedPrefix:settings_\"`\n}\n```\n\n```go\nfunc (p *UserProfile) GetUser() User\n```\n\n```go\nfunc (p *UserProfile) Validate() error\n```\n\n```go\ntype UserProfileSettings struct {\n\tProviderUsernames\n}\n```\n\n","path":"github.com/CTO2BPublic/passage-server/pkg/models","name":"models","synopsis":"","isRedistributable":true}
