Skip to content
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

[Bug] AddProtectedWebApiCallsProtectedWebApi overwrites existing OnTokenValidated event handler #154

Closed
jg11jg opened this issue May 10, 2020 · 2 comments
Labels
bug Something isn't working fixed P1
Milestone

Comments

@jg11jg
Copy link
Contributor

jg11jg commented May 10, 2020

The AddProtectedWebApiCallsProtectedWebApi method registers an event handler for OnTokenValidated, but without preserving any existing registered event handler. As a side effect, any existing event registration gets lost, for example, the OnTokenValidated event handler registered in AddProtectedWebApi(), and indeed the OnTokenValidated event handler in JwtBearerMiddlewareDiagnostics (if subscribed).

I believe this is a bug.

options.Events.OnTokenValidated = async context =>

jg11jg added a commit to jg11jg/microsoft-identity-web that referenced this issue May 11, 2020
… event handler AzureAD#154

Preserving existing event hander when registering OnTokenValidated event handler in AddProtectedWebApiCallsProtectedWebApi.  Previous code was overwriting existing event handler meaning that logging via JwtBearerMiddlewareDiagnostics would no longer work and perhaps more seriously the OnTokenValidated event handler registered in AddProtectedWebApi (intended to "This check is required to ensure that the Web API only accepts tokens from tenants where it has been consented and provisioned.")

AzureAD#154
@jmprieur jmprieur added bug Something isn't working P1 labels May 11, 2020
@jmprieur jmprieur added this to the 0.1.3-preview milestone May 11, 2020
@jennyf19 jennyf19 added the fixed label May 11, 2020
@jennyf19
Copy link
Collaborator

automatically closed, will reopen until it's in the release

@jennyf19 jennyf19 reopened this May 11, 2020
jmprieur added a commit that referenced this issue May 12, 2020
jmprieur added a commit that referenced this issue May 12, 2020
* - Removing a useless instruction (as pointed to by @jg11jg in #154)
- Regenerating the XML comments

* Fixing a couple of static analysis warnings
@jennyf19
Copy link
Collaborator

Included in 0.1.3-preview release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed P1
Projects
None yet
Development

No branches or pull requests

3 participants