organization

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2018 License: BSD-3-Clause Imports: 11 Imported by: 5

Documentation

Index

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 InitModels

func InitModels()

InitModels initialize models in mongo, if required.

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 Invitation struct {
	Created db.DateTime `json:"created"`
	Role    string      `json:"role"`
	User    string      `json:"user"`
}

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

func (m *Last2FAManager) GetLast2FA(globalID string, username string) (db.DateTime, error)

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

type LocalizedInfoText struct {
	LangKey string `json:"langkey"`
	Text    string `json:"text"`
}

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 (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 (m *LogoManager) RemoveLogo(globalID string) error

RemoveLogo Removes the logo from an organization

func (m *LogoManager) SaveLogo(globalID string, logo string) (*mgo.ChangeInfo, error)

SaveLogo save or update logo

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is used to store organizations

func NewManager

func NewManager(r *http.Request) *Manager

NewManager creates and initializes a new Manager

func (*Manager) AddDNS

func (m *Manager) AddDNS(organization *Organization, dnsName string) error

func (*Manager) AddIncludeSubOrgOf added in v0.9.10

func (m *Manager) AddIncludeSubOrgOf(globalId, orgMemberId string) error

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

func (m *Manager) AllByUserChain(username string) ([]string, error)

AllByUserChain returns all organizations where the user is involved, explicitly or implicit

func (*Manager) CountByOrganization

func (m *Manager) CountByOrganization(organization string) (int, error)

CountByOrganization counts the amount of organizations where the organization is an owner

func (*Manager) CountByUser

func (m *Manager) CountByUser(username string) (int, error)

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

func (m *Manager) DeleteRequiredScope(globalId string, requiredScope string) error

DeleteRequiredScope deletes a required scope

func (*Manager) Exists

func (m *Manager) Exists(globalID string) bool

Exists checks if an organization exists.

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

func (m *Manager) GetValidity(globalID string) (int, error)

GetValidity gets the 2FA validity duration in seconds

func (*Manager) IsInOrgs added in v1.0.0

func (m *Manager) IsInOrgs(username string, globalIDs ...string) ([]string, error)

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

func (m *Manager) IsMember(globalID, username string) (result bool, err error)

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

func (m *Manager) IsOwner(globalID, username string) (isowner bool, err error)

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

func (m *Manager) OrganizationIsMember(globalID, organization string) (ismember bool, err error)

OrganizationIsMember checks if organization2 is a member of organization1

func (*Manager) OrganizationIsOwner

func (m *Manager) OrganizationIsOwner(globalID, organization string) (isowner bool, err error)

OrganizationIsOwner checks if organization2 is an owner of organization1

func (*Manager) OrganizationIsPartOf

func (m *Manager) OrganizationIsPartOf(globalID, organization string) (bool, error)

OrganizationIsPartOf checks if organization2 is a member or an owner of organization1

func (*Manager) Remove

func (m *Manager) Remove(globalid string) error

Remove removes the organization

func (*Manager) RemoveDNS

func (m *Manager) RemoveDNS(organization *Organization, dns string) error

RemoveDNS remove DNS

func (*Manager) RemoveIncludeSubOrgOf added in v0.9.10

func (m *Manager) RemoveIncludeSubOrgOf(globalId, orgMemberId string) error

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

func (m *Manager) RemoveOrganization(globalID string, organization string) error

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

func (m *Manager) RemoveUser(globalID string, username string) error

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 (m *Manager) SetValidity(globalID string, secondsDuration int) error

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 MissingScope struct {
	Organization string   `json:"organization"`
	Scopes       []string `json:"scopes"`
}

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 struct {
	Globalid string `json:"globalid"`
}

type OrganizationUser

type OrganizationUser struct {
	Username      string   `json:"username"`
	Role          string   `json:"role"`
	MissingScopes []string `json:"missingscopes"`
}

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

type UserLast2FALogin

type UserLast2FALogin struct {
	Globalid string      `json:"globalid"`
	Username string      `json:"username"`
	Last2FA  db.DateTime `json:"last2fa"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL