Giter Site home page Giter Site logo

azuread / azure-activedirectory-identitymodel-extensions-for-dotnet Goto Github PK

View Code? Open in Web Editor NEW
1.0K 101.0 386.0 50.52 MB

IdentityModel extensions for .Net

License: MIT License

C# 97.87% Batchfile 0.01% PowerShell 0.32% Shell 0.03% Perl 0.11% HTML 1.65%

azure-activedirectory-identitymodel-extensions-for-dotnet's Introduction

IdentityModel Extensions for .NET

Nuget

IdentityModel Extensions for .NET provide assemblies that are interesting for web developers that wish to use federated identity providers for establishing the caller's identity.

Versions

You can find the release notes for each version here. Older versions can be found here.

IdentityModel 7x

We are excited to announce the release of IdentityModel 7x, a major update to our popular .NET auth validation library. This new version introduces several improvements related to serialization and consistency in the API, which will provide a better user experience for developers, as well as full AOT compatibility on .NET, and huge perf improvements compared to 6x.

Note about 6.x

We bumped the release from 6.x to 7.x. We are maintaining two releases from two different branches. dev - 7.x dev6x - 6.x

dev6x will be maintained until March 2024, at which point, you will need to move to 7x to continue to get the latest and greatest improvements and security updates.

Samples and Documentation

The scenarios supported by IdentityModel extensions for .NET are described in Scenarios. The libraries are in particular used part of ASP.NET security to validate tokens in ASP.NET Web Apps and Web APIs. To learn more about token validation, and find samples, see:

Community Help and Support

We leverage Stack Overflow to work with the community on supporting Microsoft Entra and its SDKs, including this one! We highly recommend you ask your questions on Stack Overflow (we're all on there!) Also browse existing issues to see if someone has had your question before.

We recommend you use the "identityModel" tag so we can see it! Here is the latest Q&A on Stack Overflow for IdentityModel: https://stackoverflow.com/questions/tagged/identityModel

Have a design proposal? Please submit a design proposal before starting work on a PR to ensure it means the goals/objectives of this library and it's priorities.

Security Reporting

See SECURITY.md

Security Vulnerability in Microsoft.IdentityModel.Tokens 5.1.0

IdentityModel Extensions library Microsoft.IdentityModel.Tokens has a known security vulnerability affecting version 5.1.0. Please update to >= 5.1.1 immediately. An updated package is available on NuGet. For more details, see the security notice.

Contributing

All code is licensed under the MIT license and we triage actively on GitHub. We enthusiastically welcome contributions and feedback. See Contributing.md for guidelines, branch information, build instructions, and legalese.

License

Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License (the "License");

We Value and Adhere to the Microsoft Open Source Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

azure-activedirectory-identitymodel-extensions-for-dotnet's People

Contributors

brentschmaltz avatar cesarpayan avatar chenyan98 avatar ciaozhang avatar dannybtsai avatar eerhardt avatar fupingfranco avatar geok avatar gislikonrad avatar hp712 avatar ininja avatar jennyf19 avatar jmprieur avatar joegoldman2 avatar keegan-caruso avatar kellyyangsong avatar kevinchalet avatar leastprivilege avatar lovemaths avatar mafurman avatar pmaytak avatar polita avatar rojaennam avatar sruke avatar stephentoub avatar timhannmsft avatar tratcher avatar tushargupta51 avatar vanillajonathan avatar westin-m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-activedirectory-identitymodel-extensions-for-dotnet's Issues

RsaSecurityKey needs constructor sanity check.

There is a relationship between P, Q and Modulus, if this is not correct, then things most likely will go very bad from here. So this fix is in the principal of early detection and failure as later when creating the RSACryptoServiceProvider fail later on.

Add this check and throw appropriate exception.

SymmetricSignatureProvider

Support for Symmetric Algorithms needs to be added back into K.
This support was dropped while FxCore was solidifying the crypto support.
Action is to review the symmetric support in FxCore and determine if it is sufficient if not, add a PInvoke layer into the OS.

Symbols are not available

Symbols for the identitymodel extensions dlls are not available, making it hard to debug.

They are available for the Katana dlls.

ECH support is missing

Waiting for FxCore to solidify on Crypto support. Review what is available in RC and if sufficient, use it OR add a PInvoke layer to call the OS support.

Add support for OIDC Discovery of userinfo_endpoint

The OpenID Connect Discovery 1.0 specification describes a RECOMMENDED metadata value called "userinfo_endpoint". This is supported by the UserInfoEndpoint property of class OpenIdConnectConfiguration, but unfortunately the SetFromDictionary method doesn't process the value from the incoming JSON.

The simple fix is to add a new constant to OpenIdProviderMetadataNames and to provide support for that value in the SetFromDictionary method.

JSON Web Encryption (JWE) support

Can you please implement JWE support? I have a requirement for using this and it is not available. It also seems pretty common to use JWT and JWE together (for example OpenID Connect spec). So this would be really helpful. Thank you!

`ConfigurationManager<T>`’s `AutomaticRefreshInterval`, `MinimumIntervalBetweenRefreshAttempts` should clearly indicate the bounds when a value is set outside of the bounds

ConfigurationManager<T>’s AutomaticRefreshInterval, MinimumIntervalBetweenRefreshAttempts should clearly indicate the bounds when a value is set outside of the bounds.

For example for the below setting, the following exception message is shown:

Notifications = new WsFederationAuthenticationNotifications()
                    {
                        MessageReceived = context =>
                            {
                                var configManager = context.Options.ConfigurationManager as ConfigurationManager<WsFederationConfiguration>;
                                configManager.MinimumIntervalBetweenRefreshAttempts = new TimeSpan(100);
                                context.Options.ConfigurationManager.RequestRefresh();
                                return Task.FromResult(0);
                            }
                    }

00:00:01
Parameter name: value
Actual value was 00:00:00.0000100.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: 00:00:01
Parameter name: value
Actual value was 00:00:00.0000100.

WSFederation middleware doesn't work with JwtSecurityTokenHandler

The jwt token that comes to the Relying Party is in the format of "BinarySecurityToken". The code path in JwtSecurityTokenHandler that takes in TokenValidationParameters, expects the jwt token to be in the format of encoded jwt string (^[A-Za-z0-9-]+.[A-Za-z0-9-]+.[A-Za-z0-9-_]*$).

The stack trace is available at http://katanaproject.codeplex.com/discussions/548517#post1259890

Example BinarySecurityToken:

"<wsse:BinarySecurityToken wsu:Id="_38f31386-bf3e-4c93-a62c-30fa0452ade8-D60C1C07E1AFA969FE4254D90951D072" ValueType="urn:ietf:params:oauth:token-type:jwt" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">ZXlK3ZMM.............I5dloyeGVXMA==/wsse:BinarySecurityToken

Allow disabling refreshes on ConfigurationManager

We should support disabling one or both refresh intervals by setting Timeout.InfiniteTimeSpan.

                ConfigurationManager = new ConfigurationManager<WsFederationConfiguration>(metadata)
                {
                    AutomaticRefreshInterval = Timeout.InfiniteTimeSpan,
                    MinimumIntervalBetweenRefreshAttempts = Timeout.InfiniteTimeSpan
                },

Seperately, we'll add bool RefreshOnIssuerKeyNotFound at the middleware layer.

Add timestamp to nonce generation

When creating a nonce, add a the current time in UTC to the beginning.
Add a timespan property (default 1 min) to ProtocolValidation that will reject all nonces that are 'old'.

Naming

Why do you have Azure AD in the naming? Shouldn't the JWT or OIDC implementations be general purpose?

Delegates used during TokenValidation should return true / false and the runtime should throw an exception (BREAKING)

The current model for delegates puts the control of throwing in the developers hands. this means in order have a consistent model with the runtime (from the perspective of exceptions), the developer will need to review our exception classes.

A review with Vittorio resulted in a suggested change to the model to have the delegates (audience and lifetime) return true / false and the runtime throw SecurityTokenInvalidAudienceException and SecurityTokenInvalidLifeTimeException if false is returned. This is a simplier model for users.

The proposed error messages are:

"IDX10230: Lifetime validation failed. Delegate returned false, securitytoken: '{0}'.";
"IDX10231: Audience validation failed. Delegate returned false, securitytoken: '{0}'.";

The ValidateIssuer delegate returns a string as an issuer may not be defined in a token.

The current OM returns a string;
public delegate string IssuerValidator(string issuer, SecurityToken securityToken, TokenValidationParameters validationParameters);

Some options:

  1. Out param / throw on false: public delegate bool IssuerValidator(string issuer, SecurityToken securityToken, TokenValidationParameters validationParameters, out string useIhisIssuer);
  2. Leave the OM as is, if issuer is returned as null or whitespace throw

"IDX10232: Issuer validation failed. Delegate returned null or whitespace, securitytoken: '{0}'.";

Update the version of the identity model dlls to contain only the release version and not the nightly build version

From Prabu,

Yesterday when I downloaded the latest bits of WSFederation & identity model bits from their respective myget feeds, I ran into these exceptions. Chris and I looking at it further realized that the strong name of the identity model assemblies contain the nightly build version numbers. Since the latest WSFederation dll that I downloaded from myget was compiled against a different version of these identity model assemblies I ran into this exception. Typically nuget adds a binding redirect in these cases, but sometimes it does not when these packages are being installed on class libraries – especially the case if it’s a class library.

Ask here is: Can we make the strong name of the identity model dlls to contain only the release version instead of the nightly build version? In katana as a general practice we revise the version number in strong name only for major versions. Nightly build numbers will go only as package version and file version giving a smoother experience for people trying out nighty builds.

A first chance exception of type 'System.IO.FileLoadException' occurred in Microsoft.Owin.Security.WsFederation.dll

Additional information: Could not load file or assembly 'System.IdentityModel.Tokens.Jwt, Version=4.0.10527.1506, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

A first chance exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll

Additional information: Could not load file or assembly 'Microsoft.IdentityModel.Protocol.Extensions, Version=1.0.10527.1506, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

It can be something like this:

Microsoft.IdentityModel.Protocol.Extensions, Version=1.0.10602.1106 1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Microsoft.IdentityModel.Protocol.Extensions, Version=4.0.10527.1506 4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Wrong type check for payload audiences

In file :
https://github.com/MSOpenTech/azure-activedirectory-identitymodel-extensions-for-dotnet/blob/master/src/System.IdentityModel.Tokens.Jwt/JwtPayload.cs

line 153, IList audiences = value as IList;
it checks audiences against string, however when the object serializes tojson and deserialized, due to natüre of json, it would be converted to an object[]. So even if we have valid strings, it will fail due to incorrect check as above. It should check if value is IEnumerable then it should check if each item is a string instead.

Rename IExpirableNonceCache to ITokenReplayCache (BREAKING)

public interface IExpirableNonceCache is used by developers for mitigating token replays. TokenValidationParameters.TokenReplayCache is the property they use when token replay mitigation is required.

Review with Vittorio concluded with a recommendation of changing the interface and parameter names to match the use of the property.

new OM suggested:
public ITokenReplayCache TokenReplayCache
bool TryAdd(string securityToken, DateTime expiresOn);
bool TryFind(string securityToken);

Complete Json serialization extensibility

JSon serialization / deserialization and creation of claims takes a hard dependency on NewtonSoft throughout the stack. If a user wishes to use a different serializer, it would be difficult to do so.
We need to examine the stack and ensure extensibility is possible.

See:

  1. JwtPayload.Claims
  2. JsonWebKey constructor
  3. JsonWebKeySet constructor
  4. ConfigurationManager

Typo in the Iat property

public int? Iat

    {

        get { return this.GetIntClaim(JwtConstants.ReservedClaims.Iss);  --- should be Iat instead.}

    }

Exception IDX11008 when called from WIF

When using the JwtSecurityTokenHandler in my web application I ended up with an exception IDX11008 (This method is not supported to validate a 'jwt' use the method: ValidateToken(String, TokenValidationParameters, out SecurityToken))
The call stack is this:
System.IdentityModel.Tokens.JwtSecurityTokenHandler.ValidateToken(SecurityToken token) +46 System.IdentityModel.Tokens.SecurityTokenHandlerCollection.ValidateToken(SecurityToken token) +73 System.IdentityModel.Services.TokenReceiver.AuthenticateToken(SecurityToken token, Boolean ensureBearerToken, String endpointUri) +118 System.IdentityModel.Services.WSFederationAuthenticationModule.SignInWithResponseMessage(HttpRequestBase request) +489 System.IdentityModel.Services.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args) +361 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

I created the web application with Visual Studio 2013 by using the the wizard for .NET 4.5: "ASP .NET Web Application" and then the "Web Forms" template. Then "Change Authetication", "Organizational Accounts", "On-Premisis" and then the fedaration URL of Azure ACS.

I don't know if I did it as it is supposed to work. But I don't understand why the ValidateToken is declared obsolete while it is called by the .NET Framework.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.