Esempio n. 1
0
        public static void EnableAzureAdB2cOAuth2(this SwaggerUiConfig c, string clientId, string policyName, string clientSecret = null, string realm = null, string appName = "Swagger UI", bool enableDiscoveryUrlSelector = true, IDictionary <string, string> additionalParameters = null)
        {
            var additionalParams = new Dictionary <string, string>
            {
                { "p", policyName },
                { "response_mode", "fragment" }
            };

            if (additionalParameters != null)
            {
                foreach (var additionalParameter in additionalParameters)
                {
                    additionalParams.Add(additionalParameter.Key, additionalParameter.Value);
                }
            }
            c.EnableOAuth2Support(
                clientId,
                clientSecret,
                realm,
                appName,
                additionalQueryStringParams: additionalParams
                );
            if (enableDiscoveryUrlSelector)
            {
                c.EnableDiscoveryUrlSelector();
            }
        }
Esempio n. 2
0
        public void It_should_support_an_optional_setting_to_enable_oauth2()
        {
            _swaggerUiConfig.EnableOAuth2Support("test-client-id", "test-realm", "test-app-name");

            var content = GetAsString("http://tempuri.org/swagger/ui/index.html");

            StringAssert.Contains("oAuth2Enabled: true", content);
            StringAssert.Contains("oAuth2ClientId: \"test-client-id\"", content);
            StringAssert.Contains("oAuth2Realm: \"test-realm\"", content);
            StringAssert.Contains("oAuth2AppName: \"test-app-name\"", content);
        }