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

Forbidden exception when Client requests Todos #8

Open
craig-blowfield opened this issue Jul 26, 2024 · 1 comment
Open

Forbidden exception when Client requests Todos #8

craig-blowfield opened this issue Jul 26, 2024 · 1 comment

Comments

@craig-blowfield
Copy link

craig-blowfield commented Jul 26, 2024

Hi,

After following the setup instructions I am getting the following error from the Client when navigating to the Todo page after successfully authenticating

image

The bearer token is present.

On the API side I get the following log statement

image

Client Setup

App permissions look like this

image

My Client .env looks like this

VITE_PORT=3002
API_URL=http://localhost:5198
VITE_AZURE_CLIENT_ID={AppClientID}
VITE_AZURE_AUTHORITY=https://login.microsoftonline.com/{TenantID}
VITE_TODO_API_ENDPOINT_URL=http://localhost:3002
VITE_TODO_API_SCOPES_READ=["api://{ApiClientId}/ToDoList.Read"]
VITE_TODO_API_SCOPES_WRITE=["api://{ApiClientId}/ToDoList.ReadWrite"]

API setup

App reg expose permissions looks like this

image

And role looks like this

image

I have set API ClientID secrets to {ApiClientId} and and TenantID secret to {TenantID}

And the API launchSettings.json looks like this

{
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:42790",
      "sslPort": 44335
    }
  },
  "profiles": {
    "https": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "launchUrl": "swagger",
      "applicationUrl": "https://localhost:7253;http://localhost:5198",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

Maybe I have missed a setup.

Any help would be really appreciated

@craig-blowfield
Copy link
Author

craig-blowfield commented Jul 26, 2024

Just debugged and the PermissionFilter is returning ForbidResult due to hasValidPermissions being false as my user claims does have the required permissions

image

Should me (user) have both valid permissions and scopes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant