tgstation-server 6.19.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
UserAuthority.cs
Go to the documentation of this file.
1using System;
4using System.Linq;
7
8using GreenDonut;
9
11
16
31
33{
36 {
41
46
51
56
61
66
71
76
81
86
91
102 IDatabaseContext databaseContext,
103 CancellationToken cancellationToken)
104 {
105 ArgumentNullException.ThrowIfNull(ids);
106 ArgumentNullException.ThrowIfNull(databaseContext);
107
108 return databaseContext
109 .Users
110 .AsQueryable()
111 .Where(x => ids.Contains(x.Id!.Value))
112 .ToDictionaryAsync(user => user.Id!.Value, cancellationToken);
113 }
114
122 [DataLoader]
123 public static async ValueTask<ILookup<long, GraphQL.Types.OAuth.OAuthConnection>> GetOAuthConnections(
125 IDatabaseContext databaseContext,
126 CancellationToken cancellationToken)
127 {
128 ArgumentNullException.ThrowIfNull(userIds);
129 ArgumentNullException.ThrowIfNull(databaseContext);
130
131 var list = await databaseContext
133 .AsQueryable()
134 .Where(x => userIds.Contains(x.User!.Id!.Value))
135 .ToListAsync(cancellationToken);
136
137 return list.ToLookup(
139 x => new GraphQL.Types.OAuth.OAuthConnection(x.ExternalUserId!, x.Provider));
140 }
141
149 [DataLoader]
150 public static async ValueTask<ILookup<long, GraphQL.Types.OAuth.OidcConnection>> GetOidcConnections(
152 IDatabaseContext databaseContext,
153 CancellationToken cancellationToken)
154 {
155 ArgumentNullException.ThrowIfNull(userIds);
156 ArgumentNullException.ThrowIfNull(databaseContext);
157
158 var list = await databaseContext
160 .AsQueryable()
161 .Where(x => userIds.Contains(x.User!.Id!.Value))
162 .ToListAsync(cancellationToken);
163
164 return list.ToLookup(
166 x => new GraphQL.Types.OAuth.OidcConnection(x.ExternalUserId!, x.SchemeKey!));
167 }
168
176 {
178 if (userInvalidWithNullName || (model.Name != null && String.IsNullOrWhiteSpace(model.Name)))
179 return BadRequest<UpdatedUser>(ErrorCode.UserMissingName);
180
181 model.Name = model.Name?.Trim();
182 if (model.Name != null && model.Name.Contains(':', StringComparison.InvariantCulture))
183 return BadRequest<UpdatedUser>(ErrorCode.UserColonInName);
184 return null;
185 }
186
204 IDatabaseContext databaseContext,
217 : base(
218 databaseContext,
219 logger)
220 {
232 }
233
245 {
246 if (createRequest.OAuthConnections?.Any(x => x == null) == true)
247 {
248 failResponse = BadRequest<UpdatedUser>(ErrorCode.ModelValidationFailure);
249 return true;
250 }
251
254 var hasOAuthConnections = (createRequest.OAuthConnections?.Count > 0) == true;
257 {
258 failResponse = BadRequest<UpdatedUser>(ErrorCode.UserMismatchPasswordSid);
259 return true;
260 }
261
262 var hasZeroLengthPassword = createRequest.Password?.Length == 0;
264 {
266 {
267 if (createRequest.OAuthConnections == null)
268 throw new InvalidOperationException($"Expected {nameof(UserCreateRequest.OAuthConnections)} to be set here!");
269
270 if (createRequest.OAuthConnections.Count == 0)
271 {
272 failResponse = BadRequest<UpdatedUser>(ErrorCode.ModelValidationFailure);
273 return true;
274 }
275 }
276 else if (hasZeroLengthPassword)
277 {
278 failResponse = BadRequest<UpdatedUser>(ErrorCode.ModelValidationFailure);
279 return true;
280 }
281 }
282
283 if (createRequest.Group != null && createRequest.PermissionSet != null)
284 {
285 failResponse = BadRequest<UpdatedUser>(ErrorCode.UserGroupAndPermissionSet);
286 return true;
287 }
288
289 createRequest.Name = createRequest.Name?.Trim();
290 if (createRequest.Name?.Length == 0)
291 createRequest.Name = null;
292
293 if (!(createRequest.Name == null ^ createRequest.SystemIdentifier == null))
294 {
295 failResponse = BadRequest<UpdatedUser>(ErrorCode.UserMismatchNameSid);
296 return true;
297 }
298
300 return failResponse != null;
301 }
302
305 => new(
307 () => GetIdImpl(claimsPrincipalAccessor.User.RequireTgsUserId(), true, false, cancellationToken));
308
311 => new(
312 () =>
313 {
314 if (id != claimsPrincipalAccessor.User.GetTgsUserId())
316
318 {
319 Flag(AdministrationRights.ReadUsers),
320 };
321 },
323
326 => new(
327 () => Flag(AdministrationRights.ReadUsers),
328 () => ValueTask.FromResult(Queryable(includeJoins, false)));
329
331 public RequirementsGated<AuthorityResponse<GraphQL.Types.OAuth.OAuthConnection[]>> OAuthConnections(long userId, CancellationToken cancellationToken)
332 => new(
333 () => claimsPrincipalAccessor.User.GetTgsUserId() != userId
334 ? Flag(AdministrationRights.ReadUsers)
335 : null,
336 async () => new AuthorityResponse<GraphQL.Types.OAuth.OAuthConnection[]>(
338
340 public RequirementsGated<AuthorityResponse<GraphQL.Types.OAuth.OidcConnection[]>> OidcConnections(long userId, CancellationToken cancellationToken)
341 => new(
342 () => claimsPrincipalAccessor.User.GetTgsUserId() != userId
343 ? Flag(AdministrationRights.ReadUsers)
344 : null,
345 async () => new AuthorityResponse<GraphQL.Types.OAuth.OidcConnection[]>(
347
349#pragma warning disable CA1506 // TODO: Decomplexify
353 CancellationToken cancellationToken)
354#pragma warning restore CA1506
355 => new(
356 () => Flag(AdministrationRights.WriteUsers),
357 async authorizationService =>
358 {
360
362 return failResponse;
363
365 .Users
366 .AsQueryable()
367 .CountAsync(cancellationToken);
368 if (totalUsers >= generalConfigurationOptions.Value.UserLimit)
369 return Conflict<UpdatedUser>(ErrorCode.UserLimitReached);
370
374 if (dbUser == null)
375 return Gone<UpdatedUser>();
376
377 if (createRequest.SystemIdentifier != null)
378 try
379 {
381 if (sysIdentity == null)
382 return Gone<UpdatedUser>();
383 dbUser.Name = sysIdentity.Username;
385 }
387 {
388 Logger.LogTrace(ex, "System identities not implemented!");
390 new ErrorMessageResponse(ErrorCode.RequiresPosixSystemIdentity),
391 HttpFailureResponse.NotImplemented);
392 }
393 else
394 {
395 var hasZeroLengthPassword = createRequest.Password?.Length == 0;
396 var hasOAuthConnections = (createRequest.OAuthConnections?.Count > 0) == true;
397
398 // special case allow PasswordHash to be null by setting Password to "" if OAuthConnections are set
400 {
401 var result = TrySetPassword(dbUser, createRequest.Password!, true);
402 if (result != null)
403 return result;
404 }
405 }
406
408
410
412
413 Logger.LogInformation("Created new user {name} ({id})", dbUser.Name, dbUser.Id);
414
415 var responseTask = UpdatedUserResponse(authorizationService, dbUser, HttpSuccessResponse.Created);
416
418
419 return await responseTask;
420 });
421
423#pragma warning disable CA1502
424#pragma warning disable CA1506 // TODO: Decomplexify
426#pragma warning restore CA1502
427#pragma warning restore CA1506
428 => new(
429 () =>
430 {
432
433 // Ensure they are only trying to edit things they have perms for (system identity change will trigger a bad request)
434 if (model.OidcConnections != null || model.OAuthConnections != null)
435 conditional = Flag(AdministrationRights.EditOwnServiceConnections);
436
437 if (model.Password != null && model.Id == claimsPrincipalAccessor.User.GetTgsUserId())
438 {
439 var newFlag = Flag(AdministrationRights.EditOwnPassword);
440 if (conditional != null)
442 else
444 }
445
446 if (conditional != null)
448 else if (model.Enabled.HasValue
449 || model.Group != null
450 || model.Name != null
451 || model.PermissionSet != null)
453
454 return conditional;
455 },
456 async authorizationService =>
457 {
458 ArgumentNullException.ThrowIfNull(model);
459
460 if (!model.Id.HasValue || model.OAuthConnections?.Any(x => x == null) == true)
461 return BadRequest<UpdatedUser>(ErrorCode.ModelValidationFailure);
462
463 if (model.Group != null && model.PermissionSet != null)
464 return BadRequest<UpdatedUser>(ErrorCode.UserGroupAndPermissionSet);
465
467 .Users
468 .AsQueryable()
469 .Where(x => x.Id == model.Id)
470 .Include(x => x.CreatedBy)
471 .Include(x => x.OAuthConnections)
472 .Include(x => x.OidcConnections)
473 .Include(x => x.Group!)
474 .ThenInclude(x => x.PermissionSet)
475 .Include(x => x.PermissionSet)
476 .FirstOrDefaultAsync(cancellationToken);
477
479
480 if (originalUser == default)
481 return NotFound<UpdatedUser>();
482
484 return Forbid<UpdatedUser>();
485
487 var invalidateSessions = false;
488 if (originalUserHasSid && originalUser.PasswordHash != null)
489 {
490 // cleanup from https://github.com/tgstation/tgstation-server/issues/1528
491 Logger.LogDebug("System user ID {userId}'s PasswordHash is polluted, updating database.", originalUser.Id);
493
494 invalidateSessions = true;
495 }
496
497 if (model.SystemIdentifier != null && model.SystemIdentifier != originalUser.SystemIdentifier)
498 return BadRequest<UpdatedUser>(ErrorCode.UserSidChange);
499
500 if (model.Password != null)
501 {
503 return BadRequest<UpdatedUser>(ErrorCode.UserMismatchPasswordSid);
504
505 var result = TrySetPassword(originalUser, model.Password, false);
506 if (result != null)
507 return result;
508
509 invalidateSessions = true;
510 }
511
512 if (model.Name != null && User.CanonicalizeName(model.Name) != originalUser.CanonicalName)
513 return BadRequest<UpdatedUser>(ErrorCode.UserNameChange);
514
515 if (model.OAuthConnections != null
516 && (model.OAuthConnections.Count != originalUser.OAuthConnections!.Count
517 || !model.OAuthConnections.All(x => originalUser.OAuthConnections.Any(y => y.Provider == x.Provider && y.ExternalUserId == x.ExternalUserId))))
518 {
519 if (securityConfigurationOptions.Value.OidcStrictMode)
520 return BadRequest<UpdatedUser>(ErrorCode.BadUserEditDueToOidcStrictMode);
521
523 return BadRequest<UpdatedUser>(ErrorCode.AdminUserCannotHaveServiceConnection);
524
525 if (model.OAuthConnections.Count == 0 && originalUser.PasswordHash == null && originalUser.SystemIdentifier == null)
526 return BadRequest<UpdatedUser>(ErrorCode.CannotRemoveLastAuthenticationOption);
527
528 DatabaseContext.OAuthConnections.RemoveRange(originalUser.OAuthConnections);
529 originalUser.OAuthConnections.Clear();
530
531 foreach (var updatedConnection in model.OAuthConnections)
532 originalUser.OAuthConnections.Add(new Models.OAuthConnection
533 {
534 Provider = updatedConnection.Provider,
535 ExternalUserId = updatedConnection.ExternalUserId,
536 });
537 }
538
539 if (model.OidcConnections != null
540 && (model.OidcConnections.Count != originalUser.OidcConnections!.Count
541 || !model.OidcConnections.All(x => originalUser.OidcConnections.Any(y => y.SchemeKey == x.SchemeKey && y.ExternalUserId == x.ExternalUserId))))
542 {
543 if (securityConfigurationOptions.Value.OidcStrictMode)
544 return BadRequest<UpdatedUser>(ErrorCode.BadUserEditDueToOidcStrictMode);
545
547 return BadRequest<UpdatedUser>(ErrorCode.AdminUserCannotHaveServiceConnection);
548
549 if (model.OidcConnections.Count == 0 && originalUser.PasswordHash == null && originalUser.SystemIdentifier == null)
550 return BadRequest<UpdatedUser>(ErrorCode.CannotRemoveLastAuthenticationOption);
551
552 DatabaseContext.OidcConnections.RemoveRange(originalUser.OidcConnections);
553 originalUser.OidcConnections.Clear();
554 foreach (var updatedConnection in model.OidcConnections)
555 originalUser.OidcConnections.Add(new Models.OidcConnection
556 {
557 SchemeKey = updatedConnection.SchemeKey,
558 ExternalUserId = updatedConnection.ExternalUserId,
559 });
560 }
561
562 if (model.Group != null)
563 {
564 if (securityConfigurationOptions.Value.OidcStrictMode)
565 return BadRequest<UpdatedUser>(ErrorCode.BadUserEditDueToOidcStrictMode);
566
568 .Groups
569 .AsQueryable()
570 .Where(x => x.Id == model.Group.Id)
571 .Include(x => x.PermissionSet)
572 .FirstOrDefaultAsync(cancellationToken);
573
574 if (originalUser.Group == default)
575 return Gone<UpdatedUser>();
576
577 DatabaseContext.Groups.Attach(originalUser.Group);
578 if (originalUser.PermissionSet != null)
579 {
580 Logger.LogInformation("Deleting permission set {permissionSetId}...", originalUser.PermissionSet.Id);
581 DatabaseContext.PermissionSets.Remove(originalUser.PermissionSet);
583 }
584 }
585 else if (model.PermissionSet != null)
586 {
587 if (securityConfigurationOptions.Value.OidcStrictMode)
588 return BadRequest<UpdatedUser>(ErrorCode.BadUserEditDueToOidcStrictMode);
589
590 if (originalUser.PermissionSet == null)
591 {
592 Logger.LogTrace("Creating new permission set...");
593 originalUser.PermissionSet = new Models.PermissionSet();
594 }
595
598
599 originalUser.Group = null;
601 }
602
603 var fail = CheckValidName(model, false);
604 if (fail != null)
605 return fail;
606
608
609 if (model.Enabled.HasValue)
610 {
611 if (securityConfigurationOptions.Value.OidcStrictMode)
612 return BadRequest<UpdatedUser>(ErrorCode.BadUserEditDueToOidcStrictMode);
613
614 invalidateSessions = originalUser.Require(x => x.Enabled) && !model.Enabled.Value;
615 originalUser.Enabled = model.Enabled.Value;
616 }
617
620
622
623 Logger.LogInformation("Updated user {userName} ({userId})", originalUser.Name, originalUser.Id);
624
626
630 else
631 sessionInvalidationTask = ValueTask.CompletedTask;
632
634
635 return await responseTask;
636 });
637
647 {
648 User? user;
649 if (includeJoins)
650 {
651 var queryable = Queryable(true, true);
652
653 user = await queryable.FirstOrDefaultAsync(
654 dbModel => dbModel.Id == id,
656 }
657 else
658 user = await usersDataLoader.LoadAsync(id, cancellationToken);
659
660 if (user == default)
661 return NotFound<User>();
662
664 return Forbid<User>();
665
666 return new AuthorityResponse<User>(user);
667 }
668
677 Security.IAuthorizationService authorizationService,
678 User user,
680 {
681 // return id only if not a self update and cannot read users
682 var userId = user.Require(u => u.Id);
684 || (await authorizationService.AuthorizeAsync(
685 [Flag(AdministrationRights.ReadUsers)])).Succeeded;
686
689 ? new UpdatedUser(user)
690 : new UpdatedUser(userId),
692 }
693
701 GraphQL.Subscriptions.UserSubscriptions.UserUpdatedTopics(
702 user.Require(x => x.Id))
703 .Select(topic => topicEventSender.SendAsync(
704 topic,
706 CancellationToken.None))); // DCT: Operation should always run
707
715 {
718 .Users
719 .AsQueryable();
720
721 if (!allowSystemUser)
723 .Where(user => user.CanonicalName != tgsUserCanonicalName);
724
725 if (includeJoins)
727 .Include(x => x.CreatedBy)
728 .Include(x => x.OAuthConnections)
729 .Include(x => x.OidcConnections)
730 .Include(x => x.Group!)
731 .ThenInclude(x => x.PermissionSet)
732 .Include(x => x.PermissionSet);
733
734 return queryable;
735 }
736
743 async ValueTask<User> CreateNewUserFromModel(Api.Models.Internal.UserApiBase model, CancellationToken cancellationToken)
744 {
745 Models.PermissionSet? permissionSet = null;
746 UserGroup? group = null;
747 if (model.Group != null)
749 .Groups
750 .AsQueryable()
751 .Where(x => x.Id == model.Group.Id)
752 .Include(x => x.PermissionSet)
753 .FirstOrDefaultAsync(cancellationToken);
754 else
755 permissionSet = new Models.PermissionSet
756 {
758 InstanceManagerRights = model.PermissionSet?.InstanceManagerRights ?? InstanceManagerRights.None,
759 };
760
761 /*
762 var currentUser = new User
763 {
764 Id = claimsPrincipalAccessor.User.GetTgsUserId(),
765 };
766 */
767
768 // Temporary workaround while we work to remove authentication context
769 var currentUser = DatabaseContext.Users.Local.First(
770 user => user.Id == claimsPrincipalAccessor.User.GetTgsUserId());
771
773
774 return new User
775 {
776 CreatedAt = DateTimeOffset.UtcNow,
777 CreatedBy = currentUser,
778 Enabled = model.Enabled ?? false,
779 PermissionSet = permissionSet,
780 Group = group,
781 Name = model.Name,
782 SystemIdentifier = model.SystemIdentifier,
784 .OAuthConnections
785 ?.Select(x => new Models.OAuthConnection
786 {
787 Provider = x.Provider,
788 ExternalUserId = x.ExternalUserId,
789 })
790 .ToList()
791 ?? new List<Models.OAuthConnection>(),
794 ?.Select(x => new Models.OidcConnection
795 {
796 SchemeKey = x.SchemeKey,
797 ExternalUserId = x.ExternalUserId,
798 })
799 .ToList()
800 ?? new List<Models.OidcConnection>(),
801 };
802 }
803
812 {
813 newPassword ??= String.Empty;
814 if (newPassword.Length < generalConfigurationOptions.Value.MinimumPasswordLength)
816 new ErrorMessageResponse(ErrorCode.UserPasswordLength)
817 {
818 AdditionalData = $"Required password length: {generalConfigurationOptions.Value.MinimumPasswordLength}",
819 },
820 HttpFailureResponse.BadRequest);
821 cryptographySuite.SetUserPassword(dbUser, newPassword, newUser);
822 return null;
823 }
824 }
825}
Represents initial credentials used by the server.
static readonly string AdminUserName
The name of the default admin user.
Represents a valid OAuth connection.
Represents a valid OIDC connection.
Represents a set of server permissions.
AdministrationRights? AdministrationRights
The Rights.AdministrationRights for the user.
Represents an error message returned by the server.
Extension methods for the ValueTask and ValueTask<TResult> classes.
static async ValueTask WhenAll(IEnumerable< ValueTask > tasks)
Fully await a given list of tasks .
ILogger< AuthorityBase > Logger
Gets the ILogger for the AuthorityBase.
Evaluates a set of IAuthorizationRequirements to be checked before executing a response.
readonly ISessionInvalidationTracker sessionInvalidationTracker
The ISessionInvalidationTracker for the UserAuthority.
readonly ITopicEventSender topicEventSender
The ITopicEventSender for the UserAuthority.
RequirementsGated< AuthorityResponse< GraphQL.Types.OAuth.OidcConnection[]> > OidcConnections(long userId, CancellationToken cancellationToken)
Gets the GraphQL.Types.OAuth.OidcConnections for the User with a given userId .A RequirementsGated<TR...
readonly IPermissionsUpdateNotifyee permissionsUpdateNotifyee
The IPermissionsUpdateNotifyee for the UserAuthority.
static ? AuthorityResponse< UpdatedUser > CheckValidName(UserUpdateRequest model, bool newUser)
Check if a given model has a valid UserName.Name specified.
AuthorityResponse< UpdatedUser >? TrySetPassword(User dbUser, string newPassword, bool newUser)
Attempt to change the password of a given dbUser .
static Task< Dictionary< long, User > > GetUsers(IReadOnlyList< long > ids, IDatabaseContext databaseContext, CancellationToken cancellationToken)
Implements the usersDataLoader.
readonly IClaimsPrincipalAccessor claimsPrincipalAccessor
The IClaimsPrincipalAccessor for the UserAuthority.
UserAuthority(IDatabaseContext databaseContext, ILogger< UserAuthority > logger, IUsersDataLoader usersDataLoader, IOAuthConnectionsDataLoader oAuthConnectionsDataLoader, IOidcConnectionsDataLoader oidcConnectionsDataLoader, ISystemIdentityFactory systemIdentityFactory, IPermissionsUpdateNotifyee permissionsUpdateNotifyee, ICryptographySuite cryptographySuite, ISessionInvalidationTracker sessionInvalidationTracker, ITopicEventSender topicEventSender, IClaimsPrincipalAccessor claimsPrincipalAccessor, IOptionsSnapshot< GeneralConfiguration > generalConfigurationOptions, IOptions< SecurityConfiguration > securityConfigurationOptions)
Initializes a new instance of the UserAuthority class.
async ValueTask< AuthorityResponse< User > > GetIdImpl(long id, bool includeJoins, bool allowSystemUser, CancellationToken cancellationToken)
Implementation of retrieving a User by ID.
RequirementsGated< AuthorityResponse< User > > Read(CancellationToken cancellationToken)
Gets the currently authenticated user.A RequirementsGated<TResult> User AuthorityResponse<TResult>.
readonly ISystemIdentityFactory systemIdentityFactory
The ISystemIdentityFactory for the UserAuthority.
RequirementsGated< AuthorityResponse< User > > GetId(long id, bool includeJoins, bool allowSystemUser, CancellationToken cancellationToken)
Gets the User with a given id .A RequirementsGated<TResult> User AuthorityResponse<TResult>.
readonly IOptions< SecurityConfiguration > securityConfigurationOptions
The IOptions<TOptions> of SecurityConfiguration for the UserAuthority.
readonly IOptionsSnapshot< GeneralConfiguration > generalConfigurationOptions
The IOptionsSnapshot<TOptions> of GeneralConfiguration for the UserAuthority.
RequirementsGated< IQueryable< User > > Queryable(bool includeJoins)
Gets all registered Users.A RequirementsGated<TResult> IQueryable<T> of Users.
IQueryable< User > Queryable(bool includeJoins, bool allowSystemUser)
Gets all registered Users.
async ValueTask< User > CreateNewUserFromModel(Api.Models.Internal.UserApiBase model, CancellationToken cancellationToken)
Creates a new User from a given model .
RequirementsGated< AuthorityResponse< GraphQL.Types.OAuth.OAuthConnection[]> > OAuthConnections(long userId, CancellationToken cancellationToken)
Gets the GraphQL.Types.OAuth.OAuthConnections for the User with a given userId .A RequirementsGated<T...
static async ValueTask< ILookup< long, GraphQL.Types.OAuth.OAuthConnection > > GetOAuthConnections(IReadOnlyList< long > userIds, IDatabaseContext databaseContext, CancellationToken cancellationToken)
Implements the oAuthConnectionsDataLoader.
static async ValueTask< ILookup< long, GraphQL.Types.OAuth.OidcConnection > > GetOidcConnections(IReadOnlyList< long > userIds, IDatabaseContext databaseContext, CancellationToken cancellationToken)
Implements the oidcConnectionsDataLoader.
RequirementsGated< AuthorityResponse< UpdatedUser > > Create(UserCreateRequest createRequest, bool? needZeroLengthPasswordWithOAuthConnections, CancellationToken cancellationToken)
Creates a User.A RequirementsGated<TResult> AuthorityResponse<TResult> for the created UpdatedUser.
static bool BadCreateRequestChecks(UserCreateRequest createRequest, bool? needZeroLengthPasswordWithOAuthConnections, [NotNullWhen(true)] out AuthorityResponse< UpdatedUser >? failResponse)
Checks if a createRequest should return a bad request AuthorityResponse<TResult>.
readonly IOidcConnectionsDataLoader oidcConnectionsDataLoader
The IOidcConnectionsDataLoader for the UserAuthority.
async ValueTask< AuthorityResponse< UpdatedUser > > UpdatedUserResponse(Security.IAuthorizationService authorizationService, User user, HttpSuccessResponse successResponse)
Create the AuthorityResponse<TResult> for an UpdatedUser.
readonly ICryptographySuite cryptographySuite
The ICryptographySuite for the UserAuthority.
ValueTask SendUserUpdatedTopics(User user)
Send topics through the topicEventSender indicating a given user was created or updated.
readonly IUsersDataLoader usersDataLoader
The IUsersDataLoader for the UserAuthority.
RequirementsGated< AuthorityResponse< UpdatedUser > > Update(UserUpdateRequest model, CancellationToken cancellationToken)
Updates a User.A RequirementsGated<TResult> AuthorityResponse<TResult> for the created UpdatedUser.
readonly IOAuthConnectionsDataLoader oAuthConnectionsDataLoader
The IOAuthConnectionsDataLoader for the UserAuthority.
Backend abstract implementation of IDatabaseContext.
DbSet< OAuthConnection > OAuthConnections
The OAuthConnections in the DatabaseContext.
DbSet< PermissionSet > PermissionSets
The PermissionSets in the DatabaseContext.
Task Save(CancellationToken cancellationToken)
Saves changes made to the IDatabaseContext.A Task representing the running operation.
DbSet< User > Users
The Users in the DatabaseContext.
DbSet< OidcConnection > OidcConnections
The OidcConnections in the DatabaseContext.
DbSet< UserGroup > Groups
The UserGroups in the DatabaseContext.
Represents a User that has been updated.
Represents a group of Users.
Definition UserGroup.cs:16
const string TgsSystemUserName
Username used when creating jobs automatically.
Definition User.cs:21
static string CanonicalizeName(string name)
Change a UserName.Name into a CanonicalName.
string? CanonicalName
The uppercase invariant of UserName.Name.
Definition User.cs:58
IDatabaseCollection< OidcConnection > OidcConnections
The DbSet<TEntity> for OidcConnections.
IDatabaseCollection< User > Users
The Users in the IDatabaseContext.
IDatabaseCollection< OAuthConnection > OAuthConnections
The DbSet<TEntity> for OAuthConnections.
Represents a host-side model that may be transformed into a TApiModel .
Interface for accessing the current request's ClaimsPrincipal.
ClaimsPrincipal User
Get the current ClaimsPrincipal.
Contains various cryptographic functions.
Receives notifications about permissions updates.
ValueTask UserDisabled(User user, CancellationToken cancellationToken)
Called when a given User is successfully disabled.
void UserModifiedInvalidateSessions(User user)
Invalidate all sessions for a given user .
Task< ISystemIdentity?> CreateSystemIdentity(User user, CancellationToken cancellationToken)
Create a ISystemIdentity for a given user .
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.
Definition ErrorCode.cs:12
@ List
User may list files if the Models.Instance allows it.
InstanceManagerRights
Rights for managing Models.Instances.
AdministrationRights
Administration rights for the server.
@ Api
The ApiHeaders.ApiVersionHeader header is missing or invalid.
HttpFailureResponse
Indicates the type of HTTP status code an failing AuthorityResponse should generate.
HttpSuccessResponse
Indicates the type of HTTP status code a successful AuthorityResponse<TResult> should generate.
@ Enabled
The OAuth Gateway is enabled.