question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to remove Top level document security

See original GitHub issue

I’m adding JWT authorization to the document:

 document.AddSecurity("JWT", 
    Enumerable.Empty<string>(),
    new OpenApiSecurityScheme {
    Type = OpenApiSecuritySchemeType.ApiKey,
    Name = "Authorization",
    In = OpenApiSecurityApiKeyLocation.Header,
    Description = "Type into the textbox: Bearer {your JWT token}."
});

document.OperationProcessors.Add(
    new AspNetCoreOperationSecurityScopeProcessor("JWT")
        //new OperationSecurityScopeProcessor("JWT")
);

and for some reason in the swagger.json it appends the security to the whole document. Ex:

...
"security": [
    {
      "JWT": []
    }
  ]

is there a way to remove that section?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
dbartumeucommented, Jul 9, 2019

And now i got it. Here is the final code:

document.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("JWT"));

document.DocumentProcessors.Add(
  new SecurityDefinitionAppender("JWT",
	new OpenApiSecurityScheme
	{
	  Type = OpenApiSecuritySchemeType.ApiKey,
	  Name = "Authorization",
	  In = OpenApiSecurityApiKeyLocation.Header,
	  Description = "Type into the textbox: Bearer {your JWT token}."
	})
);
0reactions
RicoSutercommented, Jul 10, 2019

Created PR: https://github.com/RicoSuter/NSwag/pull/2305 What do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Restrict access to documents with Information Rights ...
Use a different Windows user account to rights-manage files · Open the document, worksheet, or presentation. · Select the File tab. · On...
Read more >
Setting up security policies for PDFs
In Acrobat, choose Tools > Protect > More Options > Manage Security Policies. · Click New. · Select Use Public Key Certificates, and...
Read more >
Document level security | Elasticsearch Guide [8.9]
Set up a cluster for high availability ... To enable document level security, you use a query to specify the documents that each...
Read more >
Security (Access) Basics
Document -level security can only be set by someone in a cabinet who ... Remove other users from the Access List of a...
Read more >
Establishing Windows File and Folder Level Permissions
Select the Security tab. The top portion of the dialog box lists the users and/or groups that have access to the file or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found