Beispiel #1
0
        /// <summary>
        ///     A singleton configuration for a Auth0 configuration.
        /// </summary>
        /// <remarks>
        ///    This is a pretty simple (non-polymorphic) approach to be extended as needed. This should be publicly
        ///     cacheable
        /// </remarks>
        public static Auth0Representation ToAuthenticatorRepresentation(
            this Auth0Configuration configuration,
            string authenticator,
            IUrlHelper url)
        {
            return(new Auth0Representation
            {
                Links = new[]
                {
                    // self
                    authenticator.MakeAuthenticatorUri(url).MakeWebLink(IanaLinkRelation.Self),

                    // logical parent is authenticate
                    url.MakeAuthenticatorUri().MakeWebLink(IanaLinkRelation.Up),
                },

                Audience = configuration.Audience,
                ClientId = configuration.ClientId,
                Domain = configuration.Domain,
                Leeway = configuration.Leeway,
                RequestedScopes = configuration.RequestedScopes.Split(' ').ToList(),
                ResponseType = configuration.ResponseType.Split(' ').ToList(),
                Realm = AuthenticatorDefaults.AuthenticatorAuth0Realm
            });
        }
Beispiel #2
0
        private static Auth0Configuration GetConfiguration(IConfiguration configuration)
        {
            var result = new Auth0Configuration();

            configuration.Bind("Auth0", result);

            if (result.Audience == null || result.Authority == null)
            {
                throw new AuthenticationConfigurationException("Auth0 configuration cannot be found.");
            }

            return(result);
        }
Beispiel #3
0
 public Auth0Client(HttpClient httpClient, IOptions <Auth0Configuration> auth0Options)
 {
     _httpClient             = httpClient;
     _authOptions            = auth0Options?.Value ?? throw new ArgumentNullException(nameof(auth0Options));
     _httpClient.BaseAddress = new Uri(_authOptions.Instance);
 }