| | | 1 | | namespace Chronicis.Client.Extensions; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Extension methods for configuring authentication services. |
| | | 5 | | /// </summary> |
| | | 6 | | public static class AuthenticationServiceExtensions |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Adds Auth0 OIDC authentication configuration for Chronicis. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <param name="services">The service collection.</param> |
| | | 12 | | /// <param name="baseUrl">The base URL of the application for redirect URIs.</param> |
| | | 13 | | public static IServiceCollection AddChronicisAuthentication( |
| | | 14 | | this IServiceCollection services, |
| | | 15 | | string baseUrl) |
| | | 16 | | { |
| | 0 | 17 | | services.AddOidcAuthentication(options => |
| | 0 | 18 | | { |
| | 0 | 19 | | options.ProviderOptions.Authority = "https://auth.chronicis.app"; |
| | 0 | 20 | | options.ProviderOptions.ClientId = "Itq22vH9FBHKlYHL1j0A9EgVjA9f6NZQ"; |
| | 0 | 21 | | options.ProviderOptions.ResponseType = "code"; |
| | 0 | 22 | | options.ProviderOptions.RedirectUri = $"{baseUrl}/authentication/login-callback"; |
| | 0 | 23 | | options.ProviderOptions.PostLogoutRedirectUri = baseUrl; |
| | 0 | 24 | | |
| | 0 | 25 | | // Auth0 requires the audience parameter to issue a proper JWT access token |
| | 0 | 26 | | options.ProviderOptions.AdditionalProviderParameters.Add("audience", "https://api.chronicis.app"); |
| | 0 | 27 | | |
| | 0 | 28 | | options.ProviderOptions.DefaultScopes.Clear(); |
| | 0 | 29 | | options.ProviderOptions.DefaultScopes.Add("openid"); |
| | 0 | 30 | | options.ProviderOptions.DefaultScopes.Add("profile"); |
| | 0 | 31 | | options.ProviderOptions.DefaultScopes.Add("email"); |
| | 0 | 32 | | }); |
| | | 33 | | |
| | 0 | 34 | | return services; |
| | | 35 | | } |
| | | 36 | | } |