Widen / cloudfront-auth

An AWS CloudFront Lambda@Edge function to authenticate requests using Google Apps, Microsoft, Auth0, OKTA, and GitHub login
ISC License
623 stars 148 forks source link

No Code Found Error 401 with Azure #83

Closed jaredrobinsonchurch closed 3 years ago

jaredrobinsonchurch commented 3 years ago

Here is my config file:

{ "AUTH_REQUEST": { "client_id": "the client id", "redirect_uri": "https://*************.cloudfront.net/qsembed.html", "response_type": "code", "response_mode": "query", "scope": "openid" }, "TOKEN_REQUEST": { "client_id": "the client id", "grant_type": "authorization_code", "redirect_uri": "https://***************.cloudfront.net/qsembed.html", "client_secret": "client secret" }, "DISTRIBUTION": "Microsoft", "AUTHN": "MICROSOFT", "PRIVATE_KEY": "-----BEGIN RSA PRIVATE KEY----- The key -----END PUBLIC KEY-----\r\n", "TENANT": "the tennant", "DISCOVERY_DOCUMENT": "https://login.microsoftonline.com/************/.well-known/openid-configuration", "SESSION_DURATION": 3600, "CALLBACK_PATH": "/qsembed.html", "AUTHZ": "1" }

I keep getting the No Code Found Error 401 show up whenever I try to go to my cloudfront site. I have tried doing the different suggestions in the other cases with similar issue, such as making sure I include the body in the cloudfront behavior, I have checked the redirect URI to make sure it is the same place. Most of the resolved issues say they changed the callback path to fix it but not what they changed it to. Whenever I try to change my callback path it sets it up in a infinite redirect loop, so I am not sure what to do. Any suggestions?

cweseloh commented 3 years ago

I had this issue the first time I tried this too because I had a "/" for my callback path. Once I switched to using:

"redirect_uri": "https://example.cloudfront.net/_callback" and "CALLBACK_PATH": "/_callback"

and then made sure Azure was setup with the same reply url (https://example.cloudfront.net/_callback), it worked.