11using ModelContextProtocol . Protocol . Auth ;
2- using System . Security . Claims ;
32
43namespace ModelContextProtocol . Server . Auth ;
54
@@ -11,24 +10,18 @@ namespace ModelContextProtocol.Server.Auth;
1110/// it should be extended or replaced with a more robust implementation that integrates with your
1211/// authentication system (e.g., OAuth 2.0 server, identity provider, etc.)
1312/// </remarks>
14- public class SimpleServerAuthorizationProvider : IServerAuthorizationProvider
13+ /// <remarks>
14+ /// Initializes a new instance of the <see cref="SimpleServerAuthorizationProvider"/> class
15+ /// with the specified resource metadata and token validator.
16+ /// </remarks>
17+ /// <param name="resourceMetadata">The protected resource metadata.</param>
18+ /// <param name="tokenValidator">A function that validates access tokens. If not provided, a function that always returns true will be used.</param>
19+ public class SimpleServerAuthorizationProvider (
20+ ProtectedResourceMetadata resourceMetadata ,
21+ Func < string , Task < bool > > ? tokenValidator = null ) : IServerAuthorizationProvider
1522{
16- private readonly ProtectedResourceMetadata _resourceMetadata ;
17- private readonly Func < string , Task < bool > > _tokenValidator ;
18-
19- /// <summary>
20- /// Initializes a new instance of the <see cref="SimpleServerAuthorizationProvider"/> class
21- /// with the specified resource metadata and token validator.
22- /// </summary>
23- /// <param name="resourceMetadata">The protected resource metadata.</param>
24- /// <param name="tokenValidator">A function that validates access tokens. If not provided, a function that always returns true will be used.</param>
25- public SimpleServerAuthorizationProvider (
26- ProtectedResourceMetadata resourceMetadata ,
27- Func < string , Task < bool > > ? tokenValidator = null )
28- {
29- _resourceMetadata = resourceMetadata ?? throw new ArgumentNullException ( nameof ( resourceMetadata ) ) ;
30- _tokenValidator = tokenValidator ?? ( _ => Task . FromResult ( true ) ) ;
31- }
23+ private readonly ProtectedResourceMetadata _resourceMetadata = resourceMetadata ?? throw new ArgumentNullException ( nameof ( resourceMetadata ) ) ;
24+ private readonly Func < string , Task < bool > > _tokenValidator = tokenValidator ?? ( _ => Task . FromResult ( true ) ) ;
3225
3326 /// <inheritdoc />
3427 public ProtectedResourceMetadata GetProtectedResourceMetadata ( ) => _resourceMetadata ;
0 commit comments