public async Task <User> GetOrAddUserWithBedrockUser(IBedrockUser bedrockUser) { if (bedrockUser.GlobalKey == Guid.Empty) { return(default(User)); } var returnValue = await Context .Users .AsNoTracking() .FirstOrDefaultAsync(u => u.GlobalKey == bedrockUser.GlobalKey); if (returnValue == null) { returnValue = new User { Username = bedrockUser.Emails?.FirstOrDefault(), GlobalKey = bedrockUser.GlobalKey }; Context.Users.Add(returnValue); } return(returnValue); }
public static void SetRowAuditDataEntityDeletable(EntityEntry entry, IBedrockUser user, DateTime currentDateTime) { var deletableEntity = entry.Entity as IBedrockDeletableEntity; if (deletableEntity != null && deletableEntity.IsDeleted) { deletableEntity.DeletedBy = user.UserId; deletableEntity.DeletedDate = currentDateTime; } }
protected virtual async Task PostAuthenticate(HttpContext context) { var claimsPrincipal = context.User.Transform(_options.ClaimType); BedrockUser = SecurityModel.BedrockUser.CreateFromPrincipal(claimsPrincipal, _options.ClaimType); var bedrockIdentity = new BedrockIdentity(BedrockUser, (ClaimsIdentity)context.User.Identity); var bedrockPrincipal = new BedrockPrincipal(BedrockUser, bedrockIdentity); bedrockPrincipal.AddIdentity(bedrockIdentity); context.User = bedrockPrincipal; Thread.CurrentPrincipal = bedrockPrincipal; }
public override Task TokenValidated(TokenValidatedContext context) { ClaimsPrincipal = context.Principal.Transform(ClaimType); BedrockUser = SecurityModel.BedrockUser.CreateFromPrincipal(ClaimsPrincipal, ClaimType); var bedrockIdentity = new BedrockIdentity(BedrockUser); var bedrockPrincipal = new BedrockPrincipal(BedrockUser, bedrockIdentity); bedrockIdentity.AddClaims(ClaimsPrincipal.Claims); bedrockPrincipal.AddIdentity(bedrockIdentity); context.Principal = bedrockPrincipal; Thread.CurrentPrincipal = bedrockPrincipal; ClaimsPrincipal = bedrockPrincipal; return(base.TokenValidated(context)); }
public static void SetRowAuditDataEntity(EntityEntry entry, IBedrockUser user, DateTime currentDateTime) { var auditableEntity = entry.Entity as IBedrockAuditEntity; if (auditableEntity != null) { if (entry.State == EntityState.Added) { auditableEntity.CreatedBy = user.UserId; auditableEntity.CreatedDate = currentDateTime; auditableEntity.UpdatedBy = user.UserId; auditableEntity.UpdatedDate = currentDateTime; } else if (entry.State == EntityState.Modified) { auditableEntity.UpdatedBy = user.UserId; auditableEntity.UpdatedDate = currentDateTime; } } }
public BedrockIdentity(IBedrockUser user, ClaimsIdentity claimsIdentity) : this(user.DisplayName, claimsIdentity) { }
public BedrockIdentity(IBedrockUser user) : this(user.DisplayName) { }
protected void SetRowAuditDataEntitiesDeletable(IEnumerable <EntityEntry> changedEntries, IBedrockUser user, DateTime currentDateTime) { if (!BedrockConfiguration.Data.AutoSaveAuditFields) { return; } changedEntries.Each(e => EntityHelper.SetRowAuditDataEntityDeletable(e, user, currentDateTime)); }
public void SetUser(IBedrockUser user, ClaimsPrincipal principal) { User = user ?? throw new ArgumentNullException(nameof(user)); Principal = principal; }
public void SetUser(IBedrockUser user) { User = user ?? throw new ArgumentNullException(nameof(user)); Principal = new BedrockPrincipal(User, new BedrockIdentity(User)); }
public BedrockPrincipal(IBedrockUser bedrockUser, BedrockIdentity identity) { BedrockUser = bedrockUser; _identity = identity; }