Documentation
¶
Index ¶
- func AccessLevel(ctx context.Context, user *user_model.User, repo *repo_model.Repository) (perm_model.AccessMode, error)
- func AccessLevelUnit(ctx context.Context, user *user_model.User, repo *repo_model.Repository, ...) (perm_model.AccessMode, error)
- func CanBeAssigned(ctx context.Context, user *user_model.User, repo *repo_model.Repository, ...) (bool, error)
- func CheckRepoUnitUser(ctx context.Context, repo *repo_model.Repository, user *user_model.User, ...) bool
- func GetUserIDsWithUnitAccess(ctx context.Context, repo *repo_model.Repository, mode perm_model.AccessMode, ...) (container.Set[int64], error)
- func GetUsersWithUnitAccess(ctx context.Context, repo *repo_model.Repository, mode perm_model.AccessMode, ...) (users []*user_model.User, err error)
- func HasAccessUnit(ctx context.Context, user *user_model.User, repo *repo_model.Repository, ...) (bool, error)
- func HasAnyUnitAccess(ctx context.Context, userID int64, repo *repo_model.Repository) (bool, error)
- func IsUserRealRepoAdmin(ctx context.Context, repo *repo_model.Repository, user *user_model.User) (bool, error)
- func IsUserRepoAdmin(ctx context.Context, repo *repo_model.Repository, user *user_model.User) (bool, error)
- func RecalculateAccesses(ctx context.Context, repo *repo_model.Repository) error
- func RecalculateTeamAccesses(ctx context.Context, repo *repo_model.Repository, ignTeamID int64) (err error)
- func RecalculateUserAccess(ctx context.Context, repo *repo_model.Repository, uid int64) (err error)
- type Access
- type Permission
- func GetActionsUserRepoPermission(ctx context.Context, repo *repo_model.Repository, actionsUser *user_model.User, ...) (perm Permission, err error)
- func GetUserRepoPermission(ctx context.Context, repo *repo_model.Repository, user *user_model.User) (perm Permission, err error)
- func PermissionNoAccess() Permission
- func (p *Permission) CanAccess(mode perm_model.AccessMode, unitType unit.Type) bool
- func (p *Permission) CanAccessAny(mode perm_model.AccessMode, unitTypes ...unit.Type) bool
- func (p *Permission) CanRead(unitType unit.Type) bool
- func (p *Permission) CanReadAny(unitTypes ...unit.Type) bool
- func (p *Permission) CanReadIssuesOrPulls(isPull bool) bool
- func (p *Permission) CanWrite(unitType unit.Type) bool
- func (p *Permission) CanWriteIssuesOrPulls(isPull bool) bool
- func (p *Permission) GetFirstUnitRepoID() int64
- func (p *Permission) HasAnyUnitAccess() bool
- func (p *Permission) HasAnyUnitAccessOrPublicAccess() bool
- func (p *Permission) HasAnyUnitPublicAccess() bool
- func (p *Permission) HasUnits() bool
- func (p *Permission) IsAdmin() bool
- func (p *Permission) IsOwner() bool
- func (p *Permission) LogString() string
- func (p *Permission) ReadableUnitTypes() []unit.Type
- func (p *Permission) SetUnitsWithDefaultAccessMode(units []*repo_model.RepoUnit, mode perm_model.AccessMode)
- func (p *Permission) UnitAccessMode(unitType unit.Type) perm_model.AccessMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessLevel ¶
func AccessLevel(ctx context.Context, user *user_model.User, repo *repo_model.Repository) (perm_model.AccessMode, error)
AccessLevel returns the Access a user has to a repository. Will return NoneAccess if the user does not have access.
func AccessLevelUnit ¶
func AccessLevelUnit(ctx context.Context, user *user_model.User, repo *repo_model.Repository, unitType unit.Type) (perm_model.AccessMode, error)
AccessLevelUnit returns the Access a user has to a repository's. Will return NoneAccess if the user does not have access.
func CanBeAssigned ¶
func CanBeAssigned(ctx context.Context, user *user_model.User, repo *repo_model.Repository, _ bool) (bool, error)
CanBeAssigned return true if user can be assigned to issue or pull requests in repo Currently any write access (code, issues or pr's) is assignable, to match assignee list in user interface.
func CheckRepoUnitUser ¶
func CheckRepoUnitUser(ctx context.Context, repo *repo_model.Repository, user *user_model.User, unitType unit.Type) bool
CheckRepoUnitUser check whether user could visit the unit of this repository
func GetUserIDsWithUnitAccess ¶
func GetUserIDsWithUnitAccess(ctx context.Context, repo *repo_model.Repository, mode perm_model.AccessMode, unitType unit.Type) (container.Set[int64], error)
func GetUsersWithUnitAccess ¶
func GetUsersWithUnitAccess(ctx context.Context, repo *repo_model.Repository, mode perm_model.AccessMode, unitType unit.Type) (users []*user_model.User, err error)
func HasAccessUnit ¶
func HasAccessUnit(ctx context.Context, user *user_model.User, repo *repo_model.Repository, unitType unit.Type, testMode perm_model.AccessMode) (bool, error)
HasAccessUnit returns true if user has testMode to the unit of the repository
func HasAnyUnitAccess ¶
func HasAnyUnitAccess(ctx context.Context, userID int64, repo *repo_model.Repository) (bool, error)
HasAnyUnitAccess see the comment of "perm.HasAnyUnitAccess"
func IsUserRealRepoAdmin ¶
func IsUserRealRepoAdmin(ctx context.Context, repo *repo_model.Repository, user *user_model.User) (bool, error)
IsUserRealRepoAdmin check if this user is real repo admin
func IsUserRepoAdmin ¶
func IsUserRepoAdmin(ctx context.Context, repo *repo_model.Repository, user *user_model.User) (bool, error)
IsUserRepoAdmin return true if user has admin right of a repo
func RecalculateAccesses ¶
func RecalculateAccesses(ctx context.Context, repo *repo_model.Repository) error
RecalculateAccesses recalculates all accesses for repository.
func RecalculateTeamAccesses ¶
func RecalculateTeamAccesses(ctx context.Context, repo *repo_model.Repository, ignTeamID int64) (err error)
RecalculateTeamAccesses recalculates new accesses for teams of an organization except the team whose ID is given. It is used to assign a team ID when remove repository from that team.
func RecalculateUserAccess ¶
func RecalculateUserAccess(ctx context.Context, repo *repo_model.Repository, uid int64) (err error)
RecalculateUserAccess recalculates new access for a single user Usable if we know access only affected one user
Types ¶
type Access ¶
type Access struct {
ID int64 `xorm:"pk autoincr"`
UserID int64 `xorm:"UNIQUE(s)"`
RepoID int64 `xorm:"UNIQUE(s)"`
Mode perm.AccessMode
}
Access represents the highest access level of a user to the repository. The only access type that is not in this table is the real owner of a repository. In case of an organization repository, the members of the owners team are in this table.
type Permission ¶
type Permission struct {
AccessMode perm_model.AccessMode
// contains filtered or unexported fields
}
Permission contains all the permissions related variables to a repository for a user
func GetActionsUserRepoPermission ¶
func GetActionsUserRepoPermission(ctx context.Context, repo *repo_model.Repository, actionsUser *user_model.User, taskID int64) (perm Permission, err error)
GetActionsUserRepoPermission returns the actions user permissions to the repository
func GetUserRepoPermission ¶
func GetUserRepoPermission(ctx context.Context, repo *repo_model.Repository, user *user_model.