首页 \ 问答 \ Asp.net核心WEB API安全的第三方中间件路线?(Asp.net core WEB API secure 3rd party middleware routes?)

Asp.net核心WEB API安全的第三方中间件路线?(Asp.net core WEB API secure 3rd party middleware routes?)

寻找如何解决这个问题的建议:

我有一个通过JWT身份验证和用户角色授权进行保护的asp.net core 2 webapi项目。

我在我的asp.net webapi中添加了第三方中间件,该中间件公开了度量标准端点。

我可以在度量中间件中设置端点路由和端口,但没有授权选项。

我希望确保这些端点与我自己的API端点相同,以便只有某个角色才能访问它们,但不确定如何解决这个问题,也许某些其他自定义中间件会降低链路,从而找到这些路由并检查JWT ?


Looking for suggestions of how to go about this:

I have an asp.net core 2 webapi project secured with JWT authentication and user role authorization.

I added a 3rd party middleware in my asp.net webapi that exposes metrics endpoints.

I can set the endpoint route and port in the metrics middleware but there is no option for authorization.

I would like to secure those endpoints the same as my own API endpoints so only a certain role can access them, but not sure how to go about this, perhaps some other custom middleware lower down the chain that spots those routes and checks for the JWT?


原文:https://stackoverflow.com/questions/50138784
更新时间:2021-07-20 15:07

最满意答案

log4j.properties下行添加到log4j.properties

log4j.logger.org.apache.hadoop.hbase.tool.Canary=INFO, console

您可以将INFO更改为此类所需的任何日志记录级别。

如果您还想阻止该类使用其他appender,请通过添加以下行来更改它的可添加性:

log4j.additivity.org.apache.hadoop.hbase.tool.Canary = false

Add the following line to your log4j.properties:

log4j.logger.org.apache.hadoop.hbase.tool.Canary=INFO, console

You can change INFO to whatever logging level you need for this class.

If you also want to prevent the class from using other appenders, change the additivity for it by adding the following line:

log4j.additivity.org.apache.hadoop.hbase.tool.Canary = false

相关问答

更多
  • 更新的答案: 对不起我没问题。 我之前的回答是完全错误的; 所以你的问题在于你正在使用同一名称ApplicationLogger实现记录器(使用LoggerFactory )。 此记录器无法找到AppLog对象的调用类,因为它没有引用它。 正如您所说,您可以在每次调用中注入记录器名称,但很难维护。 您可以尝试包装Logger类。 public final class AppLogger { private Logger logger; protected AppLogger ...
  • 一个例子: log4j.rootLogger=ERROR, logfile log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender log4j.appender.logfile.datePattern='-'dd'.log' log4j.appender.logfile.File=log/radius-prod.log log4j.appender.logfile.layout=org.apache.log4j.PatternLay ...
  • 您告诉您的类在DEBUG级别登录,但告诉appender忽略WARN和INFO以下的任何内容,因此您将看不到日志消息。 至于将发现log4j.properties的顺序: WEB-INF / classes目录 WEB-INF / lib中的任何JAR common / classes(在tomcat目录中) 任何你共同/赞同的JAR 您放入common / lib的任何JAR 共享/类 您放入shared / lib的任何JAR 发现将在找到第一个文件时停止。 You tell your class to ...
  • log4j.properties下行添加到log4j.properties : log4j.logger.org.apache.hadoop.hbase.tool.Canary=INFO, console 您可以将INFO更改为此类所需的任何日志记录级别。 如果您还想阻止该类使用其他appender,请通过添加以下行来更改它的可添加性: log4j.additivity.org.apache.hadoop.hbase.tool.Canary = false Add the following line ...
  • 将记录器配置为以下类别: log4j.logger.org.hibernate.SQL=DEBUG log4j.logger.org.hibernate.type=TRACE 第一个将记录SQL语句(用?作为参数值),第二个会在需要时输出这些参数值。 所以像这样的事情应该在你的情况下做到这一点:
    不是直接的,但是你可以写一个自定义的appender拦截调用,检查级别,然后在你想要的任何级别打印它们。 或者,您可以执行一些面向方面的编程并拦截/更改其调用。 但是你为什么要改变它们记录的水平? Not directly, but you could write a custom appender that intercepts the calls, checks the levels, and then prints them at whatever level you want. Or, you co ...
  • log4j服务器是否需要特定格式? 当然是。 如果你读了SocketAppender的javadoc,你会发现: SocketAppender不使用布局。 它们将序列化的LoggingEvent对象发送到服务器端。 因此,除非您实现Go代码以Java序列化对象的格式编写套接字数据包,否则您应该考虑使用其他类型的日志服务器,例如syslog 。 Does log4j server require a specific format? Yes, of course. If you read the javado ...
  • Log4j有一种称为可additivity东西。 默认情况下,它设置为true,这意味着您编写的每个日志不仅会被特定记录器记录,还会记录其祖先(在本例中为根记录器)。 要将其设置为false,请尝试以下操作: log4j.additivity.DEFAULT_LOGGER = false 在此了解更多信息。 Log4j has something called additivity. by default it is set to true and it means that every log you ...
  • 阅读appender可加性 。 您必须将其设置为false。 之前在SO上提出过类似的问题。 相关代码段: properties文件的版本: log4j.additivity.org.quartz = false Read on appender additivity. You must set it to false. A ...
  • 如果您仍希望拥有共享主配置,可以考虑向应用程序添加一些内容,以便在初始化后更改Log4J记录器级别。 您可以通过JMX调用这些更改,从集中源获取覆盖,或者只是定期读取本地特定于安装的覆盖文件(如果存在),具体取决于您的应用程序可以依赖的基础结构支持。 请查看此信息以获取更多信息: If you still want to have a shared main configuration, you could consider adding something to the application that ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。