dudil / fastapi_msal

A FastAPI Plug-In to support authentication authorization using the Microsoft Authentication Library (MSAL)
MIT License
43 stars 20 forks source link

Custom Policy Not SUpported #41

Closed simon-lighthouse closed 2 months ago

simon-lighthouse commented 2 months ago

Describe the bug I've followed the setup steps and set up my MSAL configuration as per reproduce steps to adda custom policy, but I am receiving a pydantic error:

pydantic_core._pydantic_core.ValidationError: 1 validation error for IDTokenClaims
tfp
  Input should be 'AAD_SINGLE', 'AAD_MULTI', 'B2C_1_LOGIN', 'B2C_1_PROFILE' or 'B2C_1A_LOGIN' [type=enum, input_value='B2C_1_signup_signin', input_type=str]      
    For further information visit https://errors.pydantic.dev/2.8/v/enum

To Reproduce Steps to reproduce the behavior:

  1. Set up the client config with the following:

    client_config: MSALClientConfig = MSALClientConfig()
    client_config.client_id = os.getenv("CLIENT_ID")
    client_config.client_credential = "The client_credential retrieved at step #1"
    client_config.tenant = os.getenv("TENANT_ID")
    client_config.b2c_policy = "B2C_1_signup_signin"
  2. Run the users/me endpoint

Expected behavior This should return the users/me response correctly, but instead a pydantic error is thrown as above

Environment Settings

dudil commented 2 months ago

HI @simon-lighthouse Thank you for finding this issue 🙏 I would resolve it and issue a new release with the fix

simon-lighthouse commented 2 months ago

Great fix, works perfectly! Your library is great!