| 1 | using IntercomService.Contracts; |
| 2 | using IntercomService.Options; |
| 3 | using Microsoft.Extensions.Options; |
| 4 | |
| 5 | namespace IntercomService.Services; |
| 6 | |
| 7 | public sealed class AuthProviderRegistry( |
| 8 | IOptions<GitHubAuthOptions> githubOptions, |
| 9 | IOptions<OidcAuthOptions> oidcOptions) |
| 10 | { |
| 11 | public IReadOnlyList<AuthProviderDto> ListProviders() |
| 12 | { |
| 13 | var list = new List<AuthProviderDto>(); |
| 14 | var github = githubOptions.Value; |
| 15 | if (!string.IsNullOrWhiteSpace(github.ClientId) && !string.IsNullOrWhiteSpace(github.ClientSecret)) |
| 16 | list.Add(new AuthProviderDto("github", "GitHub", true)); |
| 17 | |
| 18 | var oidc = oidcOptions.Value; |
| 19 | if (!string.IsNullOrWhiteSpace(oidc.Authority) |
| 20 | && !string.IsNullOrWhiteSpace(oidc.ClientId) |
| 21 | && !string.IsNullOrWhiteSpace(oidc.ClientSecret)) |
| 22 | { |
| 23 | var id = string.IsNullOrWhiteSpace(oidc.ProviderId) ? "oidc" : oidc.ProviderId.Trim(); |
| 24 | var name = string.IsNullOrWhiteSpace(oidc.DisplayName) ? id : oidc.DisplayName.Trim(); |
| 25 | list.Add(new AuthProviderDto(id, name, true)); |
| 26 | } |
| 27 | |
| 28 | return list; |
| 29 | } |
| 30 | } |
| 31 | |
View only · write via MCP/CIDE