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

fix(webapi): Require base service provider scope on search endpoint #1476

Merged
merged 6 commits into from
Nov 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public static class ClaimsPrincipalExtensions
private const string PidClaim = "pid";


// TODO: This scope is also defined in WebAPI/GQL. Can this be fetched from a common auth lib?
// TODO: These scopes are also defined in WebAPI/GQL. Can this be fetched from a common auth lib?
// https://github.com/digdir/dialogporten/issues/647
// This could be done for all claims/scopes/prefixes etc, there are duplicates
public const string ServiceProviderScope = "digdir:dialogporten.serviceprovider";
private const string ServiceProviderScope = "digdir:dialogporten.serviceprovider";
private const string ServiceProviderSearchScope = "digdir:dialogporten.serviceprovider.search";

public static bool TryGetClaimValue(this ClaimsPrincipal claimsPrincipal, string claimType,
[NotNullWhen(true)] out string? value)
Expand Down Expand Up @@ -244,7 +245,7 @@ public static (UserIdType, string externalId) GetUserType(this ClaimsPrincipal c
return (UserIdType.SystemUser, externalId);
}

if (claimsPrincipal.HasScope(ServiceProviderScope) &&
if ((claimsPrincipal.HasScope(ServiceProviderScope) || claimsPrincipal.HasScope(ServiceProviderSearchScope)) &&
claimsPrincipal.TryGetOrganizationNumber(out externalId))
{
return (UserIdType.ServiceOwner, externalId);
Expand Down
Loading