private async Task CreateSeedClientDocmentAsync() { Console.WriteLine("Creating seed client"); var seedClientDownParty = new OAuthDownParty(); await seedClientDownParty.SetIdAsync(new Party.IdKey { TenantName = settings.MasterTenant, TrackName = settings.MasterTrack, PartyName = settings.ClientId }); seedClientDownParty.Client = new OAuthDownClient { RedirectUris = new[] { settings.RedirectUri }.ToList(), ResourceScopes = new List <OAuthDownResourceScope> { new OAuthDownResourceScope { Resource = apiResourceName, Scopes = new[] { "foxids_master" }.ToList() } }, ResponseTypes = new[] { "token" }.ToList(), AccessTokenLifetime = 1800 // 30 minutes }; (var secret, var oauthClientSecret) = await CreateSecretAsync(); seedClientDownParty.Client.Secrets = new List <OAuthClientSecret> { oauthClientSecret }; seedClientDownParty.SetPartitionId(); await simpleTenantRepository.SaveAsync(seedClientDownParty); Console.WriteLine("Seed client document created and saved in Cosmos DB"); Console.WriteLine($"Seed client secret is: {secret}"); }
public async Task CreateMasterFoxIDsControlApiResourceDocumentAsync(string tenantName, bool includeMasterTenantScope = false) { var mControlApiResourceDownParty = new OAuthDownParty { Name = Constants.ControlApi.ResourceName }; await mControlApiResourceDownParty.SetIdAsync(new Party.IdKey { TenantName = tenantName?.ToLower(), TrackName = Constants.Routes.MasterTrackName, PartyName = Constants.ControlApi.ResourceName }); var scopes = new List <string> { Constants.ControlApi.Scope.Tenant }; if (includeMasterTenantScope) { scopes.Add(Constants.ControlApi.Scope.Master); } mControlApiResourceDownParty.Resource = new OAuthDownResource() { Scopes = scopes }; await tenantRepository.CreateAsync(mControlApiResourceDownParty); }
private async Task CreateFoxIDsApiResourceDocumentAsync() { Console.WriteLine("Creating FoxIDs api resource"); var apiResourceDownParty = new OAuthDownParty(); await apiResourceDownParty.SetIdAsync(new Party.IdKey { TenantName = settings.MasterTenant, TrackName = settings.MasterTrack, PartyName = apiResourceName }); apiResourceDownParty.Resource = new OAuthDownResource { Scopes = apiResourceScopes.ToList() }; apiResourceDownParty.SetPartitionId(); await simpleTenantRepository.SaveAsync(apiResourceDownParty); Console.WriteLine($"FoxIDs api resource document created and saved in Cosmos DB"); }