Swagger/Swashbuckle 授权。默认检查范围

标签 swagger openid asp.net-core-webapi swashbuckle authorize

是否可以在 asp.net Core 2.0 Web API 上的 Swashbuckle UI 上设置默认选中的身份验证范围复选框?

我使用“openid”范围,我希望每次都检查它。

谢谢你。

enter image description here

最佳答案

这是现代浏览器的 hacktastic 解决方法,可以注入(inject) index.html .

function checkScopes(container) {
  const inputNodes = container.querySelectorAll(".scopes input");
  for (const checkbox of inputNodes) {
    checkbox.click();
    console.log('Scope checkbox modified: ' + checkbox.id);
  }
}

function watchDOM() {
  // target element that we will observe
  const target = document.body;

  // subscriber function
  function subscriber(mutations) {
    mutations.forEach((mutation) => {
      if (mutation.target.className == 'auth-wrapper') {
        checkScopes(mutation.target);
      }
    });
  }

  // instantiating observer
  const observer = new MutationObserver(subscriber);

  // observing target
  observer.observe(target, { childList: true, subtree: true });
};

document.addEventListener('DOMContentLoaded', watchDOM);

关于Swagger/Swashbuckle 授权。默认检查范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48890812/

相关文章:

c# - ASP.NET Core (MVC 6) 中的路由消歧

python - 如何从 Django 内置 API 文档中排除 rest-auth 端点?

java - 将所有微服务的 Swagger 集中在一个地方

openid - 不使用任何 Google API 进行身份验证的 Google OpenID Connect

既然 Google 已弃用其 OpenID2 提供商,那么 OpenID Connect 授权又如何?

asp.net-core-webapi - HTTP 错误 500.19 - 内部服务器错误代码 0x8007000d

web-services - 如何在 swagger-go 中使用 golang echo web 框架?

windows - 如何在Windows中安装haskell openid包

powershell - 本地服务器上的 Invoke-RestMethod 身份验证失败

c# - 从 ASP.NET Core 3.1 端点流式传输数据而不消耗大量内存