Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task: throw error on implicit flow #5692

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Plugins/PluginsGenerationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
pluginDocument.Write(writer);
break;
case PluginType.APIManifest:
var apiManifest = new ApiManifestDocument("application"); //TODO add application name

Check warning on line 82 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)

Check warning on line 82 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
// pass empty config hash so that its not included in this manifest.
apiManifest.ApiDependencies[Configuration.ClientClassName] = Configuration.ToApiDependency(string.Empty, TreeNode?.GetRequestInfo().ToDictionary(static x => x.Key, static x => x.Value) ?? [], WorkingDirectory);
var publisherName = string.IsNullOrEmpty(OAIDocument.Info?.Contact?.Name)
Expand Down Expand Up @@ -137,7 +137,7 @@
}
return newSchema;
}
static OpenApiSchema? MergeAllOfInSchema(OpenApiSchema? schema)

Check warning on line 140 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this static local function to reduce its Cognitive Complexity from 137 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)

Check warning on line 140 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this static local function to reduce its Cognitive Complexity from 137 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)
{
if (schema?.AllOf is not { Count: > 0 }) return schema;
var newSchema = new OpenApiSchema();
Expand Down Expand Up @@ -414,7 +414,7 @@
{
ReferenceId = $"{{{name}_REGISTRATION_ID}}"
},
SecuritySchemeType.OAuth2 => new OAuthPluginVault
SecuritySchemeType.OAuth2 when securityScheme.Flows.AuthorizationCode != null => new OAuthPluginVault
{
ReferenceId = $"{{{name}_CONFIGURATION_ID}}"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,21 @@ public static TheoryData<string, string, string, PluginAuthConfiguration, Action
Assert.Equal("{oauth2_0_CONFIGURATION_ID}", ((OAuthPluginVault)auth0!).ReferenceId);
}
},
// oauth2: implicit
{
"{securitySchemes: {oauth2_0: {type: oauth2, flows: {implicit: {}}}}}",
string.Empty, "security: [oauth2_0: []]", null, resultingManifest =>
{
Assert.NotNull(resultingManifest.Document);
Assert.Empty(resultingManifest.Problems);
Assert.NotEmpty(resultingManifest.Document.Runtimes);
var auth0 = resultingManifest.Document.Runtimes[0].Auth;
Assert.IsType<OAuthPluginVault>(auth0);
Assert.Equal(AuthType.OAuthPluginVault, auth0?.Type);
Assert.Equal("{oauth2_0_CONFIGURATION_ID}", ((OAuthPluginVault)auth0!).ReferenceId);
}
},
thewahome marked this conversation as resolved.
Show resolved Hide resolved

// should be anonymous
{
"{}", string.Empty, "security: [invalid: []]", null, resultingManifest =>
Expand Down
Loading