-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
153 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Pixel.Identity.Shared.Branding; | ||
|
||
namespace Pixel.Identity.Core.Controllers; | ||
|
||
[ApiController] | ||
[AllowAnonymous] | ||
[Route("api/[controller]")] | ||
[ApiExplorerSettings(IgnoreApi = true)] | ||
public class BrandingController(IBrandingService brandService) : Controller | ||
{ | ||
private readonly IBrandingService _brandService = brandService; | ||
|
||
[HttpGet] | ||
public async Task<IActionResult> GetAsync() | ||
{ | ||
var brand = await _brandService.GetBrandAsync(); | ||
return Ok(brand); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Pixel.Identity.Core/Services/AppSettingsBrandService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Pixel.Identity.Shared.Branding; | ||
|
||
namespace Pixel.Identity.UI.Client.Services; | ||
|
||
public class AppSettingsBrandService(IConfiguration configuration) : IBrandingService | ||
{ | ||
private readonly IConfiguration _configuration = configuration; | ||
|
||
private Brand _brand; | ||
|
||
public async Task<Brand> GetBrandAsync() => _brand ??= await BuildAsync(); | ||
|
||
private Task<Brand> BuildAsync() | ||
{ | ||
var name = _configuration["Brand:Name"] ?? BrandingProperties.Name; | ||
var shortName = _configuration["Brand:ShortName"] ?? BrandingProperties.ShortName; | ||
var logoUriDark = _configuration["Brand:LogoUriDark"] ?? BrandingProperties.LogoUriDark; | ||
var logoUriLight = _configuration["Brand:LogoUriLight"] ?? BrandingProperties.LogoUriLight; | ||
|
||
return Task.FromResult(new Brand(name, shortName, logoUriDark, logoUriLight)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System; | ||
|
||
namespace Pixel.Identity.Shared.Branding; | ||
|
||
public record Brand(String Name, String ShortName, String LogoUriDark, String LogoUriLight) | ||
{ | ||
public static readonly Brand Empty = new(BrandingDefaults.PleaseWait, BrandingDefaults.PleaseWait, String.Empty, String.Empty); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace Pixel.Identity.Shared.Branding; | ||
|
||
public static class BrandingDefaults | ||
{ | ||
public static readonly String PleaseWait = "Please wait ..."; | ||
public const String Name = "Pixel Identity Provider"; | ||
public const String ShortName = "Pixel Identity"; | ||
public const String LogoUriDark = ""; | ||
public const String LogoUriLight = ""; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace Pixel.Identity.Shared.Branding; | ||
|
||
public static class BrandingProperties | ||
{ | ||
public static String Name { get; set; } = BrandingDefaults.Name; | ||
public static String ShortName { get; set; } = BrandingDefaults.ShortName; | ||
public static String LogoUriDark { get; set; } = BrandingDefaults.LogoUriDark; | ||
public static String LogoUriLight { get; set; } = BrandingDefaults.LogoUriLight; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Pixel.Identity.Shared.Branding; | ||
|
||
public interface IBrandingService | ||
{ | ||
Task<Brand> GetBrandAsync(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Pixel.Identity.UI.Client/Services/RemoteBrandService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Pixel.Identity.Shared.Branding; | ||
using System.Net.Http; | ||
using System.Net.Http.Json; | ||
using System.Threading.Tasks; | ||
|
||
namespace Pixel.Identity.UI.Client.Services; | ||
|
||
public class RemoteBrandService(HttpClient httpClient) : IBrandingService | ||
{ | ||
private readonly HttpClient httpClient = httpClient; | ||
private Brand _brand; | ||
|
||
public async Task<Brand> GetBrandAsync() | ||
{ | ||
if (_brand == null) | ||
{ | ||
_brand = await httpClient.GetFromJsonAsync<Brand>("api/branding"); | ||
} | ||
|
||
return _brand; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters