Skip to content
This repository has been archived by the owner on Feb 7, 2020. It is now read-only.

Adding a proper authorization #36

Merged
merged 3 commits into from
Jun 5, 2019
Merged

Conversation

jmprieur
Copy link
Contributor

@jmprieur jmprieur commented Jun 5, 2019

  1. Updating the code so that the controller checks that the client has the role access_as_application
  2. Explains how to direct Azure AD to not even issue a token for client which would not be approved to get a token for the protected Web API.

1. Updating the code so that the controller checks that the client has the role `access_as_application`
2. Explains how to direct Azure AD to not even issue a token for client which would not be approved to get a token for the protected Web API.
@jmprieur
Copy link
Contributor Author

jmprieur commented Jun 5, 2019

Also fixes #35

Claim scopeClaim = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/scope");
if (scopeClaim != null)
Claim scopeClaim = ClaimsPrincipal.Current.FindFirst("roles");
if (scopeClaim == null || (scopeClaim.Value != "access_as_application"))
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some duplicate code, consider adding a function (ValidateRoleClaim) for this authz check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @henrik-me. Will address in later commit

Copy link

@henrik-me henrik-me left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Contributor

@TiagoBrenck TiagoBrenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ve added a manual step on the powershell to set 'User assignment required' and to grant admin consent to the tenant.

LGTM

@jmprieur
Copy link
Contributor Author

jmprieur commented Jun 5, 2019

Thanks @TiagoBrenck @henrik-me @kalyankrishna1

@jmprieur jmprieur merged commit c23507c into master Jun 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants