Documentation ¶
Index ¶
- func ConvertIdentifierToUsername(identifier string, valMgr *validation.Manager) (string, error)
- func ConvertUsernameToIdentifier(username string, usrMgr *user.Manager, valMgr *validation.Manager) (string, error)
- func ConvertUsernamesToIdentifiers(usernames []string, valMgr *validation.Manager) ([]string, error)
- func InitModels()
- func MapUsernamesToIdentifiers(usernames []string, valMgr *validation.Manager) (map[string]string, error)
- type DescriptionManager
- func (m *DescriptionManager) DeleteDescription(globalId, langKey string) error
- func (m *DescriptionManager) GetDescription(globalId string) (OrganizationInfoText, error)
- func (m *DescriptionManager) Remove(globalid string) error
- func (m *DescriptionManager) SaveDescription(globalId string, text LocalizedInfoText) error
- func (m *DescriptionManager) UpdateDescription(globalId string, text LocalizedInfoText) error
- type GetOrganizationUsersResponseBody
- type Invitation
- type Last2FAManager
- func (m *Last2FAManager) Exists(globalID string, username string) bool
- func (m *Last2FAManager) GetLast2FA(globalID string, username string) (db.DateTime, error)
- func (m *Last2FAManager) RemoveByOrganization(globalid string) error
- func (m *Last2FAManager) RemoveByUser(username string) error
- func (m *Last2FAManager) RemoveLast2FA(globalID string, username string) error
- func (m *Last2FAManager) SetLast2FA(globalID string, username string) error
- type LocalizedInfoText
- type LogoManager
- func (m *LogoManager) Create(organization *Organization) error
- func (m *LogoManager) Exists(globalID string) bool
- func (m *LogoManager) GetByName(globalID string) (organization *Organization, err error)
- func (m *LogoManager) GetLogo(globalID string) (string, error)
- func (m *LogoManager) Remove(globalid string) error
- func (m *LogoManager) RemoveLogo(globalID string) error
- func (m *LogoManager) SaveLogo(globalID string, logo string) (*mgo.ChangeInfo, error)
- type Manager
- func (m *Manager) AddDNS(organization *Organization, dnsName string) error
- func (m *Manager) AddIncludeSubOrgOf(globalId, orgMemberId string) error
- func (m *Manager) AddRequiredScope(globalId string, requiredScope RequiredScope) error
- func (m *Manager) AllByOrg(globalID string) ([]Organization, error)
- func (m *Manager) AllByOrgs(globalIDs []string) ([]Organization, error)
- func (m *Manager) AllByUser(username string) ([]Organization, error)
- func (m *Manager) AllByUserChain(username string) ([]string, error)
- func (m *Manager) CountByOrganization(organization string) (int, error)
- func (m *Manager) CountByUser(username string) (int, error)
- func (m *Manager) Create(organization *Organization) error
- func (m *Manager) DeleteRequiredScope(globalId string, requiredScope string) error
- func (m *Manager) Exists(globalID string) bool
- func (m *Manager) Get(id string) (*Organization, error)
- func (m *Manager) GetByName(globalID string) (organization *Organization, err error)
- func (m *Manager) GetOrganizations(organizationIDs []string) ([]Organization, error)
- func (m *Manager) GetSubOrganizations(globalID string) ([]Organization, error)
- func (m *Manager) GetSubOrganizationsMultiple(globalIDs []string) ([]Organization, error)
- func (m *Manager) GetValidity(globalID string) (int, error)
- func (m *Manager) IsInOrgs(username string, globalIDs ...string) ([]string, error)
- func (m *Manager) IsMember(globalID, username string) (result bool, err error)
- func (m *Manager) IsOwner(globalID, username string) (isowner bool, err error)
- func (m *Manager) ListByUserOrGlobalID(username string, globalIds []string) (error, []Organization)
- func (m *Manager) OrganizationIsMember(globalID, organization string) (ismember bool, err error)
- func (m *Manager) OrganizationIsOwner(globalID, organization string) (isowner bool, err error)
- func (m *Manager) OrganizationIsPartOf(globalID, organization string) (bool, error)
- func (m *Manager) Remove(globalid string) error
- func (m *Manager) RemoveDNS(organization *Organization, dns string) error
- func (m *Manager) RemoveIncludeSubOrgOf(globalId, orgMemberId string) error
- func (m *Manager) RemoveMember(organization *Organization, username string) error
- func (m *Manager) RemoveOrgMember(organization *Organization, organizationID string) error
- func (m *Manager) RemoveOrgOwner(organization *Organization, organizationID string) error
- func (m *Manager) RemoveOrganization(globalID string, organization string) error
- func (m *Manager) RemoveOwner(organization *Organization, owner string) error
- func (m *Manager) RemoveUser(globalID string, username string) error
- func (m *Manager) SaveMember(organization *Organization, username string) error
- func (m *Manager) SaveOrgMember(organization *Organization, organizationID string) error
- func (m *Manager) SaveOrgOwner(organization *Organization, organizationID string) error
- func (m *Manager) SaveOwner(organization *Organization, owner string) error
- func (m *Manager) SetValidity(globalID string, secondsDuration int) error
- func (m *Manager) SplitOwnedOrgs(globalIDs []string, username string) (ownedOrgs []string, memberOrgs []string, err error)
- func (m *Manager) UpdateDNS(organization *Organization, oldDNSName string, newDNSName string) error
- func (m *Manager) UpdateMembership(globalid string, username string, oldrole string, newrole string) error
- func (m *Manager) UpdateOrgMembership(globalid string, organization string, oldrole string, newrole string) error
- func (m *Manager) UpdateRequiredScope(globalId string, oldRequiredScope string, newRequiredScope RequiredScope) error
- type MissingScope
- type Organization
- type OrganizationInfoText
- type OrganizationLogo
- type OrganizationUser
- type OrganizationView
- type RequiredScope
- type UserLast2FALogin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertIdentifierToUsername ¶ added in v0.9.15
func ConvertIdentifierToUsername(identifier string, valMgr *validation.Manager) (string, error)
ConvertIdentifierToUsername converts an identifier to a username.
func ConvertUsernameToIdentifier ¶ added in v0.9.15
func ConvertUsernameToIdentifier(username string, usrMgr *user.Manager, valMgr *validation.Manager) (string, error)
ConvertUsernameToIdentifier converts a username into an identifier. It tries validated email addresses first. If there are none, attempt to use validated phone numbers. If the user also doesn't have any of those, keep the username
func ConvertUsernamesToIdentifiers ¶ added in v0.9.15
func ConvertUsernamesToIdentifiers(usernames []string, valMgr *validation.Manager) ([]string, error)
ConvertUsernamesToIdentifiers converts a list of usernames to a list of user identifiers
func MapUsernamesToIdentifiers ¶ added in v0.9.15
func MapUsernamesToIdentifiers(usernames []string, valMgr *validation.Manager) (map[string]string, error)
MapUsernamesToIdentifiers returns a map with as key the validated information (identifier) and as value the username
Types ¶
type DescriptionManager ¶
type DescriptionManager struct {
// contains filtered or unexported fields
}
DescriptionManager is used to store info texts for an organization
func NewDescriptionManager ¶
func NewDescriptionManager(r *http.Request) *DescriptionManager
NewDescriptionManager creates and initializes a new DescriptionManager
func (*DescriptionManager) DeleteDescription ¶
func (m *DescriptionManager) DeleteDescription(globalId, langKey string) error
DeleteDescription deletes a (translated) description for an organization
func (*DescriptionManager) GetDescription ¶
func (m *DescriptionManager) GetDescription(globalId string) (OrganizationInfoText, error)
GetDescription get all descriptions for an organization
func (*DescriptionManager) Remove ¶
func (m *DescriptionManager) Remove(globalid string) error
Remove removes the organization descriptions
func (*DescriptionManager) SaveDescription ¶
func (m *DescriptionManager) SaveDescription(globalId string, text LocalizedInfoText) error
SaveDescription saves a description for an organization
func (*DescriptionManager) UpdateDescription ¶
func (m *DescriptionManager) UpdateDescription(globalId string, text LocalizedInfoText) error
UpdateDescription updates a description for an organization
type GetOrganizationUsersResponseBody ¶
type GetOrganizationUsersResponseBody struct { HasEditPermissions bool `json:"haseditpermissions"` Users []OrganizationUser `json:"users"` }
type Invitation ¶
type Last2FAManager ¶
type Last2FAManager struct {
// contains filtered or unexported fields
}
Last2FAManager is used to save the date for the last 2FA login for an organization through the authorization code grant flow
func NewLast2FAManager ¶
func NewLast2FAManager(r *http.Request) *Last2FAManager
NewLast2FAManager creates and initializes a new Last2FAManager
func (*Last2FAManager) Exists ¶
func (m *Last2FAManager) Exists(globalID string, username string) bool
Exists checks if an organization - user combination entry exists.
func (*Last2FAManager) GetLast2FA ¶
GetLast2FA Gets the date of the last successful 2FA login, if no failed login attempts have occurred since then
func (*Last2FAManager) RemoveByOrganization ¶
func (m *Last2FAManager) RemoveByOrganization(globalid string) error
Remove the Last2FA entries for this organization
func (*Last2FAManager) RemoveByUser ¶
func (m *Last2FAManager) RemoveByUser(username string) error
Remove the Last2FA entries for this user
func (*Last2FAManager) RemoveLast2FA ¶
func (m *Last2FAManager) RemoveLast2FA(globalID string, username string) error
RemoveLast2FA Removes the entry of the last successful 2FA login for this organization - user combination
func (*Last2FAManager) SetLast2FA ¶
func (m *Last2FAManager) SetLast2FA(globalID string, username string) error
SetLast2FA Set the last successful 2FA time
type LocalizedInfoText ¶
LocalizedInfoText is a key-value pair that binds a (translated) text to a language
type LogoManager ¶
type LogoManager struct {
// contains filtered or unexported fields
}
LogoManager is used to save the logo for an organization
func NewLogoManager ¶
func NewLogoManager(r *http.Request) *LogoManager
NewLogoManager creates and initializes a new LogoManager
func (*LogoManager) Create ¶
func (m *LogoManager) Create(organization *Organization) error
Create a new organization entry in the organization logo collection
func (*LogoManager) Exists ¶
func (m *LogoManager) Exists(globalID string) bool
Exists checks if an organization and logo entry exists.
func (*LogoManager) GetByName ¶
func (m *LogoManager) GetByName(globalID string) (organization *Organization, err error)
func (*LogoManager) GetLogo ¶
func (m *LogoManager) GetLogo(globalID string) (string, error)
GetLogo Gets the logo from an organization
func (*LogoManager) Remove ¶
func (m *LogoManager) Remove(globalid string) error
Remove the organization logo
func (*LogoManager) RemoveLogo ¶
func (m *LogoManager) RemoveLogo(globalID string) error
RemoveLogo Removes the logo from an organization
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is used to store organizations
func NewManager ¶
NewManager creates and initializes a new Manager
func (*Manager) AddIncludeSubOrgOf ¶ added in v0.9.10
AddIncludeSubOrgOf adds an organization to the list of orgs who's suborgs are included in the owner/member hierarchy
func (*Manager) AddRequiredScope ¶
func (m *Manager) AddRequiredScope(globalId string, requiredScope RequiredScope) error
AddRequiredScope adds a required scope
func (*Manager) AllByOrg ¶
func (m *Manager) AllByOrg(globalID string) ([]Organization, error)
AllByOrg get organizations where certain organization is a member/owner.
func (*Manager) AllByOrgs ¶ added in v1.0.0
func (m *Manager) AllByOrgs(globalIDs []string) ([]Organization, error)
AllByOrgs get organizations where at least one organization of those provided is an owner or member
func (*Manager) AllByUser ¶
func (m *Manager) AllByUser(username string) ([]Organization, error)
AllByUser get organizations for certain user.
func (*Manager) AllByUserChain ¶ added in v0.9.10
AllByUserChain returns all organizations where the user is involved, explicitly or implicit
func (*Manager) CountByOrganization ¶
CountByOrganization counts the amount of organizations where the organization is an owner
func (*Manager) CountByUser ¶
CountByUser counts the amount of organizations by user
func (*Manager) Create ¶
func (m *Manager) Create(organization *Organization) error
Create a new organization.
func (*Manager) DeleteRequiredScope ¶
DeleteRequiredScope deletes a required scope
func (*Manager) Get ¶
func (m *Manager) Get(id string) (*Organization, error)
Get organization by ID.
func (*Manager) GetByName ¶
func (m *Manager) GetByName(globalID string) (organization *Organization, err error)
GetByName gets an organization by Name.
func (*Manager) GetOrganizations ¶
func (m *Manager) GetOrganizations(organizationIDs []string) ([]Organization, error)
GetOrganizations gets a list of organizations.
func (*Manager) GetSubOrganizations ¶
func (m *Manager) GetSubOrganizations(globalID string) ([]Organization, error)
GetSubOrganizations returns all organizations which have {globalID} as parent (including the organization with {globalID} as globalid) TODO: validate globalID since it is appended in the query
func (*Manager) GetSubOrganizationsMultiple ¶ added in v1.0.0
func (m *Manager) GetSubOrganizationsMultiple(globalIDs []string) ([]Organization, error)
GetSubOrganizationsMultiple loads all suborganizations of the input organizations
func (*Manager) GetValidity ¶
GetValidity gets the 2FA validity duration in seconds
func (*Manager) IsInOrgs ¶ added in v1.0.0
IsInOrgs checks if a user is somehow in the provided orgs returns a list of all the orgs where the user is an owner or member
func (*Manager) IsMember ¶
IsMember checks if a specific user is in the members list of an organization or belongs to an organization that is in the member list it also checks this for the parentorganization
func (*Manager) IsOwner ¶
IsOwner checks if a specific user is in the owners list of an organization or belongs to an organization that is in the owner list It also checks this for the parentorganizations
func (*Manager) ListByUserOrGlobalID ¶
func (m *Manager) ListByUserOrGlobalID(username string, globalIds []string) (error, []Organization)
func (*Manager) OrganizationIsMember ¶
OrganizationIsMember checks if organization2 is a member of organization1
func (*Manager) OrganizationIsOwner ¶
OrganizationIsOwner checks if organization2 is an owner of organization1
func (*Manager) OrganizationIsPartOf ¶
OrganizationIsPartOf checks if organization2 is a member or an owner of organization1
func (*Manager) RemoveDNS ¶
func (m *Manager) RemoveDNS(organization *Organization, dns string) error
RemoveDNS remove DNS
func (*Manager) RemoveIncludeSubOrgOf ¶ added in v0.9.10
RemoveIncludeSubOrgOf removes an organization from the list of orgs who's suborgs are included in the owner/member hierarchy
func (*Manager) RemoveMember ¶
func (m *Manager) RemoveMember(organization *Organization, username string) error
RemoveMember remove member
func (*Manager) RemoveOrgMember ¶
func (m *Manager) RemoveOrgMember(organization *Organization, organizationID string) error
RemoveOrgMember remove organization member
func (*Manager) RemoveOrgOwner ¶
func (m *Manager) RemoveOrgOwner(organization *Organization, organizationID string) error
RemoveOrgOwner remove owner
func (*Manager) RemoveOrganization ¶
RemoveOrganization Removes an organization as member or owner from another organization
func (*Manager) RemoveOwner ¶
func (m *Manager) RemoveOwner(organization *Organization, owner string) error
RemoveOwner remove owner
func (*Manager) RemoveUser ¶
RemoveUser Removes a user from an organization
func (*Manager) SaveMember ¶
func (m *Manager) SaveMember(organization *Organization, username string) error
SaveMember save or update member
func (*Manager) SaveOrgMember ¶
func (m *Manager) SaveOrgMember(organization *Organization, organizationID string) error
SaveOrgMember save or update organization member
func (*Manager) SaveOrgOwner ¶
func (m *Manager) SaveOrgOwner(organization *Organization, organizationID string) error
SaveOrgOwner save or update owners
func (*Manager) SaveOwner ¶
func (m *Manager) SaveOwner(organization *Organization, owner string) error
SaveOwner save or update owners
func (*Manager) SetValidity ¶
func (*Manager) SplitOwnedOrgs ¶ added in v1.0.0
func (m *Manager) SplitOwnedOrgs(globalIDs []string, username string) (ownedOrgs []string, memberOrgs []string, err error)
SplitOwnedOrgs removes the organizations of which the user is an owner from the input lists and moves them into a separate list which is returned
func (*Manager) UpdateDNS ¶
func (m *Manager) UpdateDNS(organization *Organization, oldDNSName string, newDNSName string) error
func (*Manager) UpdateMembership ¶
func (m *Manager) UpdateMembership(globalid string, username string, oldrole string, newrole string) error
UpdateMembership Updates a user his role in an organization
func (*Manager) UpdateOrgMembership ¶
func (m *Manager) UpdateOrgMembership(globalid string, organization string, oldrole string, newrole string) error
UpdateOrgMembership Updates an organization role in another organization
func (*Manager) UpdateRequiredScope ¶
func (m *Manager) UpdateRequiredScope(globalId string, oldRequiredScope string, newRequiredScope RequiredScope) error
UpdateRequiredScope updates a required scope
type MissingScope ¶
type Organization ¶
type Organization struct { DNS []string `json:"dns"` Globalid string `json:"globalid"` Members []string `json:"members"` Owners []string `json:"owners"` PublicKeys []string `json:"publicKeys"` SecondsValidity int `json:"secondsvalidity"` OrgOwners []string `json:"orgowners"` //OrgOwners are other organizations that are owner of this organization OrgMembers []string `json:"orgmembers"` //OrgMembers are other organizations that are member of this organization RequiredScopes []RequiredScope `json:"requiredscopes"` IncludeSubOrgsOf []string `json:"includesuborgsof"` }
Organization represents an ItsYou.online organization
func (*Organization) ConvertToView ¶ added in v0.9.15
func (org *Organization) ConvertToView(usrMgr *user.Manager, valMgr *validation.Manager) (*OrganizationView, error)
ConvertToView converts an organization from the DB to a view served by the API
func (*Organization) IsValid ¶
func (org *Organization) IsValid() bool
IsValid performs basic validation on the content of an organizations fields
func (*Organization) IsValidSubOrganization ¶ added in v0.9.9
func (org *Organization) IsValidSubOrganization() bool
IsValidSubOrganization checks if the organization is a suborganization
type OrganizationInfoText ¶
type OrganizationInfoText struct { Globalid string `json:"globalid"` InfoTexts []LocalizedInfoText `json:"infotexts"` }
OrganizationInfoText stores all the (translations of) the information text on the signin/signup page for an given organization
type OrganizationLogo ¶
type OrganizationUser ¶
type OrganizationView ¶ added in v0.9.15
type OrganizationView struct { DNS []string `json:"dns"` Globalid string `json:"globalid"` Members []string `json:"members"` Owners []string `json:"owners"` PublicKeys []string `json:"publicKeys"` SecondsValidity int `json:"secondsvalidity"` OrgOwners []string `json:"orgowners"` //OrgOwners are other organizations that are owner of this organization OrgMembers []string `json:"orgmembers"` //OrgMembers are other organizations that are member of this organization RequiredScopes []RequiredScope `json:"requiredscopes"` IncludeSubOrgsOf []string `json:"includesuborgsof"` }
OrganizationView represents an overview of an organization
type RequiredScope ¶
type RequiredScope struct { Scope string `json:"scope"` AccessScopes []string `json:"accessscopes"` }
func (*RequiredScope) IsAuthorized ¶
func (requiredScope *RequiredScope) IsAuthorized(authorization user.Authorization) bool
func (RequiredScope) IsValid ¶
func (requiredScope RequiredScope) IsValid() bool