File tree Expand file tree Collapse file tree 3 files changed +30
-5
lines changed 
src/ITfoxtec.Identity.Saml2 Expand file tree Collapse file tree 3 files changed +30
-5
lines changed Original file line number Diff line number Diff line change 55using  System . ServiceModel . Security ; 
66using  System . IdentityModel . Selectors ; 
77using  System . Security . Cryptography . Xml ; 
8+ #if NETFULL 
9+ using  System . IdentityModel . Configuration ; 
10+ #else
11+ using  Microsoft . IdentityModel . Tokens ; 
12+ #endif
813
914namespace  ITfoxtec . Identity . Saml2 
1015{ 
@@ -36,10 +41,19 @@ public class Saml2Configuration
3641        public  X509RevocationMode  RevocationMode  {  get ;  set ;  }  =  X509RevocationMode . Online ; 
3742        public  X509CertificateValidator  CustomCertificateValidator  {  get ;  set ;  } 
3843#if NETFULL 
39-         public  SecurityTokenResolver  CustomIssuerTokenResolver  {  get ;  set ;  } 
44+         public  IdentityModelCaches  TokenReplayCache  {  get ;  set ;  } 
45+         public  TimeSpan ?  TokenReplayCacheExpirationPeriod  {  get ;  set ;  } 
46+ #else
47+         public  ITokenReplayCache  TokenReplayCache  {  get ;  set ;  } 
4048#endif
4149        public  bool  SaveBootstrapContext  {  get ;  set ;  }  =  false ; 
4250
51+ #if NETFULL 
52+ #else
53+         /// <summary> 
54+         /// By default no replayed validation is performed. Validation requires that TokenReplayCache has been set. 
55+         /// </summary> 
56+ #endif
4357        public  bool  DetectReplayedTokens  {  get ;  set ;  }  =  false ; 
4458
4559        public  bool  AudienceRestricted  {  get ;  set ;  }  =  true ; 
Original file line number Diff line number Diff line change @@ -37,19 +37,29 @@ public static Saml2IdentityConfiguration GetIdentityConfiguration(Saml2Configura
3737            configuration . IssuerNameRegistry  =  new  Saml2ResponseIssuerNameRegistry ( ) ; 
3838            configuration . CertificateValidationMode  =  config . CertificateValidationMode ; 
3939            configuration . RevocationMode  =  config . RevocationMode ; 
40-             configuration . DetectReplayedTokens  =  config . DetectReplayedTokens ; 
4140            SetCustomCertificateValidator ( configuration ,  config ) ; 
42-             if  ( config . CustomIssuerTokenResolver  !=  null ) 
41+ 
42+             configuration . DetectReplayedTokens  =  config . DetectReplayedTokens ; 
43+             if  ( config . TokenReplayCache  !=  null ) 
44+             { 
45+                 configuration . Caches  =  config . TokenReplayCache ; 
46+             } 
47+             if  ( config . TokenReplayCacheExpirationPeriod . HasValue ) 
4348            { 
44-                 configuration . IssuerTokenResolver  =  config . CustomIssuerTokenResolver ; 
49+                 configuration . TokenReplayCacheExpirationPeriod  =  config . TokenReplayCacheExpirationPeriod . Value ; 
4550            } 
4651            configuration . Initialize ( ) ; 
4752#else
4853            configuration . SaveSigninToken  =  config . SaveBootstrapContext ; 
4954            configuration . ValidateAudience  =  config . AudienceRestricted ; 
5055            configuration . ValidAudiences  =  config . AllowedAudienceUris . Select ( a =>  a ) ; 
5156            configuration . ValidIssuer  =  config . AllowedIssuer ; 
57+ 
5258            configuration . ValidateTokenReplay  =  config . DetectReplayedTokens ; 
59+             if  ( config . TokenReplayCache  !=  null ) 
60+             { 
61+                 configuration . TokenReplayCache  =  config . TokenReplayCache ; 
62+             } 
5363
5464            configuration . NameClaimType  =  ClaimTypes . NameIdentifier ; 
5565
Original file line number Diff line number Diff line change @@ -38,7 +38,8 @@ public static Saml2ResponseSecurityTokenHandler GetSaml2SecurityTokenHandler(Sam
3838                RevocationMode  =  configuration . RevocationMode , 
3939                CertificateValidator  =  configuration . CertificateValidator , 
4040                DetectReplayedTokens  =  configuration . DetectReplayedTokens , 
41-                 IssuerTokenResolver  =  configuration . IssuerTokenResolver 
41+                 Caches  =  configuration . Caches , 
42+                 TokenReplayCacheExpirationPeriod  =  configuration . TokenReplayCacheExpirationPeriod 
4243            } ; 
4344
4445            handler . SamlSecurityTokenRequirement . NameClaimType  =  ClaimTypes . NameIdentifier ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments