This repository was archived by the owner on Dec 24, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Owin.Security.OAuth.Introspection
Owin.Security.OAuth.Validation Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77using System ;
88using JetBrains . Annotations ;
9+ using Microsoft . Extensions . Logging ;
910using Owin . Security . OAuth . Introspection ;
1011
1112namespace Owin
@@ -64,5 +65,33 @@ public static IAppBuilder UseOAuthIntrospection(
6465
6566 return app . Use < OAuthIntrospectionMiddleware > ( app . Properties , options ) ;
6667 }
68+
69+ /// <summary>
70+ /// Configures the OAuth2 introspection middleware to enable logging.
71+ /// </summary>
72+ /// <param name="options">The options used to configure the OAuth2 introspection middleware.</param>
73+ /// <param name="configuration">The delegate used to configure the logger factory.</param>
74+ /// <returns>The options used to configure the OAuth2 introspection middleware.</returns>
75+ public static OAuthIntrospectionOptions UseLogging (
76+ [ NotNull ] this OAuthIntrospectionOptions options ,
77+ [ NotNull ] Action < ILoggerFactory > configuration )
78+ {
79+ if ( options == null )
80+ {
81+ throw new ArgumentNullException ( nameof ( options ) ) ;
82+ }
83+
84+ if ( configuration == null )
85+ {
86+ throw new ArgumentNullException ( nameof ( configuration ) ) ;
87+ }
88+
89+ var factory = new LoggerFactory ( ) ;
90+ configuration ( factory ) ;
91+
92+ options . Logger = factory . CreateLogger < OAuthIntrospectionMiddleware > ( ) ;
93+
94+ return options ;
95+ }
6796 }
6897}
Original file line number Diff line number Diff line change 66
77using System ;
88using JetBrains . Annotations ;
9+ using Microsoft . Extensions . Logging ;
910using Owin . Security . OAuth . Validation ;
1011
1112namespace Owin
@@ -79,5 +80,33 @@ public static IAppBuilder UseOAuthValidation(
7980
8081 return app . Use < OAuthValidationMiddleware > ( app . Properties , options ) ;
8182 }
83+
84+ /// <summary>
85+ /// Configures the OAuth2 validation middleware to enable logging.
86+ /// </summary>
87+ /// <param name="options">The options used to configure the OAuth2 validation middleware.</param>
88+ /// <param name="configuration">The delegate used to configure the logger factory.</param>
89+ /// <returns>The options used to configure the OAuth2 validation middleware.</returns>
90+ public static OAuthValidationOptions UseLogging (
91+ [ NotNull ] this OAuthValidationOptions options ,
92+ [ NotNull ] Action < ILoggerFactory > configuration )
93+ {
94+ if ( options == null )
95+ {
96+ throw new ArgumentNullException ( nameof ( options ) ) ;
97+ }
98+
99+ if ( configuration == null )
100+ {
101+ throw new ArgumentNullException ( nameof ( configuration ) ) ;
102+ }
103+
104+ var factory = new LoggerFactory ( ) ;
105+ configuration ( factory ) ;
106+
107+ options . Logger = factory . CreateLogger < OAuthValidationMiddleware > ( ) ;
108+
109+ return options ;
110+ }
82111 }
83112}
You can’t perform that action at this time.
0 commit comments