Table of Contents

Class ServerAccessRules

Namespace
McServerLauncher.Services
Assembly
McServerLauncher.dll

Who can do what on a shared server, and who may change whose access.

public static class ServerAccessRules
Inheritance
ServerAccessRules
Inherited Members

Remarks

Pure functions of the data in ServerGrant, with no network and no screen. The app uses them to decide what to show; the cloud has to reach the same answers on its own, because a button that is hidden stops nobody who talks to the API directly. That is why ServerAccessTests reads like a specification.

Every rule below compares permission sets instead of roles. A role is only a starting point, and "an admin who was also given free commands" is a different person from "an admin" without a second code path to say so.

Fields

FormerOwnerGrant

What the previous owner is afterwards: an admin, so they are not locked out of their own server.

public static readonly ServerGrant FormerOwnerGrant

Field Value

ServerGrant

NewOwnerGrant

The new owner's grant. Always a bare owner: nothing from before carries over.

public static readonly ServerGrant NewOwnerGrant

Field Value

ServerGrant

Methods

CanTransferOwnership(ServerGrant)

Whether actor may hand the server over to somebody else.

public static bool CanTransferOwnership(ServerGrant actor)

Parameters

actor ServerGrant

Returns

bool

Check(ServerGrant, ServerGrant?, ServerGrant)

Whether actor may give somebody the access in proposed.

public static GrantDenial Check(ServerGrant actor, ServerGrant? existing, ServerGrant proposed)

Parameters

actor ServerGrant

The person making the change.

existing ServerGrant

The target's current grant, or null when inviting a new member.

proposed ServerGrant

What the target would hold afterwards.

Returns

GrantDenial

Remarks

The checks run in this order, so the answer is the first reason that applies:

  1. Only someone with ManageMembers changes access.
  2. The owner's access is not changed here, and nobody is made owner here.
  3. The target must not be able to do anything the actor cannot — nobody edits their betters. Equals are allowed.
  4. A critical permission the target does not already have needs the owner to give it.
  5. Nobody can hand out more than they hold.

Effective(ServerGrant)

What a grant really lets its holder do.

public static ServerPermission Effective(ServerGrant grant)

Parameters

grant ServerGrant

Returns

ServerPermission

Remarks

The role's preset, plus Added, minus Removed — so removing wins.

Two things are not up to the overrides. The owner has everything and nothing can take it away, so a stored override on an owner is ignored. Everybody keeps ViewStatus: a member who cannot even see the server is simply not a member, and should be removed instead. OwnerActions never comes from an override.

Has(ServerGrant, ServerPermission)

Whether a grant includes every permission in permission.

public static bool Has(ServerGrant grant, ServerPermission permission)

Parameters

grant ServerGrant
permission ServerPermission

Returns

bool