- 
                Notifications
    You must be signed in to change notification settings 
- Fork 336
[WIP] IdentityModel dependency update for OpenIdConnect, WsFed, and Bearer #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -2,15 +2,12 @@ | |
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|  | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IdentityModel.Metadata; | ||
| using System.IdentityModel.Tokens; | ||
| using System.Collections.ObjectModel; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Net.Http; | ||
| using System.Security.Cryptography.X509Certificates; | ||
| using System.ServiceModel.Security; | ||
| using System.Xml; | ||
| using Microsoft.IdentityModel.Protocols.WsFederation; | ||
| using Microsoft.IdentityModel.Tokens; | ||
|  | ||
| namespace Microsoft.Owin.Security.ActiveDirectory | ||
| { | ||
|  | @@ -23,9 +20,6 @@ internal static class WsFedMetadataRetriever | |
|  | ||
| public static IssuerSigningKeys GetSigningKeys(string metadataEndpoint, TimeSpan backchannelTimeout, HttpMessageHandler backchannelHttpHandler) | ||
| { | ||
| string issuer = string.Empty; | ||
| var tokens = new List<X509SecurityToken>(); | ||
|  | ||
| using (var metadataRequest = new HttpClient(backchannelHttpHandler, false)) | ||
| { | ||
| metadataRequest.Timeout = backchannelTimeout; | ||
|  | @@ -35,32 +29,13 @@ public static IssuerSigningKeys GetSigningKeys(string metadataEndpoint, TimeSpan | |
| Stream metadataStream = metadataResponse.Content.ReadAsStreamAsync().Result; | ||
| using (XmlReader metaDataReader = XmlReader.Create(metadataStream, SafeSettings)) | ||
| { | ||
| var serializer = new MetadataSerializer { CertificateValidationMode = X509CertificateValidationMode.None }; | ||
|  | ||
| MetadataBase metadata = serializer.ReadMetadata(metaDataReader); | ||
| var entityDescriptor = (EntityDescriptor)metadata; | ||
|  | ||
| if (!string.IsNullOrWhiteSpace(entityDescriptor.EntityId.Id)) | ||
| { | ||
| issuer = entityDescriptor.EntityId.Id; | ||
| } | ||
| var serializer = new WsFederationMetadataSerializer(); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nicely simplified :-) | ||
| var wsFederationConfiguration = serializer.ReadMetadata(metaDataReader); | ||
|  | ||
| SecurityTokenServiceDescriptor stsd = entityDescriptor.RoleDescriptors.OfType<SecurityTokenServiceDescriptor>().First(); | ||
| if (stsd == null) | ||
| { | ||
| throw new InvalidOperationException(Properties.Resources.Exception_MissingDescriptor); | ||
| } | ||
|  | ||
| IEnumerable<X509RawDataKeyIdentifierClause> x509DataClauses = | ||
| stsd.Keys.Where(key => key.KeyInfo != null | ||
| && (key.Use == KeyType.Signing || key.Use == KeyType.Unspecified)) | ||
| .Select(key => key.KeyInfo.OfType<X509RawDataKeyIdentifierClause>().First()); | ||
| tokens.AddRange(x509DataClauses.Select(token => new X509SecurityToken(new X509Certificate2(token.GetX509RawData())))); | ||
| return new IssuerSigningKeys { Issuer = wsFederationConfiguration.Issuer, Keys = wsFederationConfiguration.SigningKeys }; | ||
| } | ||
| } | ||
| } | ||
|  | ||
| return new IssuerSigningKeys { Issuer = issuer, Tokens = tokens }; | ||
| } | ||
| } | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,5 +1,12 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <packages> | ||
| <package id="Microsoft.IdentityModel.Logging" version="5.2.0.407281058-pre" targetFramework="net451" /> | ||
| <package id="Microsoft.IdentityModel.Protocols" version="5.2.0.407281058-pre" targetFramework="net451" /> | ||
| <package id="Microsoft.IdentityModel.Protocols.WsFederation" version="5.2.0.407281058-pre" targetFramework="net451" /> | ||
| <package id="Microsoft.IdentityModel.Tokens" version="5.2.0.407281058-pre" targetFramework="net451" /> | ||
| <package id="Microsoft.IdentityModel.Tokens.Saml" version="5.2.0.407281058-pre" targetFramework="net451" /> | ||
| <package id="Microsoft.IdentityModel.Xml" version="5.2.0.407281058-pre" targetFramework="net451" /> | ||
| <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net451" /> | ||
| <package id="Owin" version="1.0" targetFramework="net45" /> | ||
| <package id="System.IdentityModel.Tokens.Jwt" version="4.0.0" targetFramework="net45" /> | ||
| <package id="System.IdentityModel.Tokens.Jwt" version="5.2.0.407281058-pre" targetFramework="net451" /> | ||
| </packages> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tratcher my apologizes. This is one of the best commits I've ever read. But I can't find any reference/article for migration from System.IdentityModel to Microsoft.IdentityModel Could you please provide us more information about this? We've exciting code that needs to migrated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should take that up with @lovemaths and @brentschmaltz, most of this was done on their advice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File an issue here: https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ysmoradi we are developing the updated IdentityModel changes here: https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/tree/dev