Identity Server 3 : Logging client id for reporting

送分小仙女□ 提交于 2019-12-12 03:19:02

问题


I am looking at options to log client id for every request (if available), so that it can be used for reporting purpose to find out the number of request per client. Ids logs the client id for token request when LogLevel is Information. Looking at IDS code, we need to extract the client id from AuthenticationHeader or from Body of the request. Wanted to know if there anything that is already built into ids to do this. Any other ways to do this?


回答1:


Absolutely!

Implementing the IEventService is what you're after.

An overview of all the events being transmitted to the IEventService can be viewed in the source of these internal extension methods; IEventServiceExtensions.

The AccessTokenIssuedEvent, AuthorizationCodeDetails and RefreshTokenDetails events will include the ClientId receiving the token - so you can create an audit log.

The default implementation of IEventService is the DefaultEventService, which will use the logging mechanism you're using for IdentityServer, but you can swap that out to log to a DB if you prefer.



来源:https://stackoverflow.com/questions/38770098/identity-server-3-logging-client-id-for-reporting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!