TokenCommandModule
A static class in TavernLib, TavernLib.ModulePorts.
TavernLib's token console module for named console tokens: whoami, list, create, edit, revoke, rotate, show and log. Server; only the owner token manages tokens.
- Listed in TavernLib.ModulePorts
- Nested types
LogLines,TokenInfo,TokenList - Attributes
ServerOnly,Module - Documented in Console, Internals
Fields
| Member | What it is |
|---|---|
const string ModuleName | The module's name, token. Named tokens can never be given anything under it except token whoami. |
5 private and internal fields
Methods
18 private and internal methods
| Member | What it is |
|---|---|
private static string CallerTokenId() | The named token id the calling console logged in with, or null for the owner. |
private static string Create(string name, string access, int days = 0, string preset = "custom") | token create: owner token only, makes a named token with a name, access list, lifetime and preset, and shows its text. |
private static string Date(DateTime? value, string none) | Formats a date as yyyy-MM-dd HH:mm, or returns the given text when there is none. |
private static string Edit(string id, string access, int days = -1, string preset = null) | token edit: owner token only, changes a named token's access, expiry or preset. |
private static TokenCommandModule.TokenInfo Info(ConsoleToken token) | Builds the TokenInfo shown for a token. |
private static HashSet<string> KnownPaths() | Collects the paths of every module and command this server has. |
private static object List() | token list: owner token only, lists every named token. |
private static object Log(string id = "", int count = 50) | token log: owner token only, returns the newest console log lines, for one token or all, up to 500. |
private static string NewId(List<ConsoleToken> existing) | Makes a random 8 character token id not used by an existing token. |
private static string OwnerOnly() | Returns a refusal text if the caller is a named token, else null. |
private static string ParseAccess(string access, string preset, out string label, out List<string> paths) | Checks an access string and preset and returns an error text, or null with the preset label and path list filled in. |
private static string Revoke(string id) | token revoke: owner token only, stops a named token for good and closes its sessions. |
private static string Rotate(string id) | token rotate: owner token only, gives a named token or the owner token new text and closes its sessions. |
private static string RotateOwner() | Rotates the owner token, writes it to console_token.txt and closes the other owner sessions. |
private static string Show(string id) | token show: owner token only, shows a named token's text again. |
private static string Store(Func<ConsoleTokenList, bool> change) | Runs a change to console_tokens.json and returns a refusal text if it can't be read or written, else null. |
private static bool ValidName(string name, int maxLength) | True for a non-empty name of letters, digits, spaces, hyphens and underscores within the length limit. |
private static object WhoAmI() | token whoami: returns which token this console logged in with and what it may run. |