昂首阔步/英国人授权.范围默认检查 [英] Swagger/Swashbuckle Authorize. Scopes checked by default

查看:62
本文介绍了昂首阔步/英国人授权.范围默认检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to set an auth scope checkbox checked by default on Swashbuckle UI on a asp.net Core 2.0 Web API??

我使用"openid"作用域,并且希望每次都进行检查.

I use the "openid" scope and I'd like to have it checked every time.

谢谢.

推荐答案

这是现代浏览器的一种变通方法,可以将其注入 index.html .

Here is hacktastic workaround for modern browsers which can be injected into 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);

这篇关于昂首阔步/英国人授权.范围默认检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆