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

Debug the roles function using the local auth emulator #364

Open
simonaco opened this issue Dec 17, 2021 · 9 comments
Open

Debug the roles function using the local auth emulator #364

simonaco opened this issue Dec 17, 2021 · 9 comments
Labels
complexity: days Issues that need a few days to be resolved priority: high (P0) High priority scope: auth Issues related to the authentication emulator status: release-blocker Issues blocking a major release type: enhancement New feature or request type: RFC This is a request for comment
Milestone

Comments

@simonaco
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Enable local dev for role management through serverless functions

Describe the solution you'd like
Test programmatically assigned roles in local environment

Describe alternatives you've considered
Call the auth function locally with something like Postman to ensure it responds with the right roles given an input.
Use the local emulator to set custom roles at login to test how your app works with different roles.

Additional context
Tutorial: Assign custom roles with a function and Microsoft Graph

@simonaco
Copy link
Contributor Author

simonaco commented Dec 17, 2021

@Reshmi-Sriram Reshmi-Sriram added type: enhancement New feature or request scope: auth Issues related to the authentication emulator labels Jan 10, 2022
@AverageCakeSlice
Copy link

AverageCakeSlice commented Jan 15, 2022

Related to #306

@simonaco simonaco added the priority: high (P0) High priority label Jan 20, 2022
@manekinekko manekinekko added type: RFC This is a request for comment complexity: days Issues that need a few days to be resolved labels Mar 14, 2022
@manekinekko manekinekko added the status: release-blocker Issues blocking a major release label Apr 13, 2022
@manekinekko
Copy link
Member

I will look at this post-GA.

The current workaround is to print a warning if we detect the auth in the staticwebapp.config.json

@oneolddev
Copy link

What is the current status of this? I was attempting to enable role management and test locally. I expected my GetRoles function to be called but it wasn't after login. I was able to call GetRoles directly. I was hoping not to debug in a live SWA deployment.

I'm using SWA CLI ver 1.01 and C#(.net6).

@Reshmi-Sriram
Copy link
Member

Hi @c0g1t8,
We have this in our radar and will be working on this shortly. We do not have a timeline yet to commit this, but you should be seeing some update in a couple of months.

cc// @sgollapudi77

@amatracaru
Copy link

Is there any update on this?

@ghost
Copy link

ghost commented Jul 25, 2023

I'd like to second this - any progress so far? At the moment trying to debug is not possible for me, as issues only seem to occur in prod, and not on a local dev machine.

@adrianhall adrianhall added this to the 1.1.12 milestone Jul 1, 2024
@bzbetty
Copy link

bzbetty commented Dec 13, 2024

I added a hack locally to node_modules/@azure/static-web-apps-cli/dist/public/auth.html

and changed the form.submit to the following

  // store cookie info as base64
      form.submit(() => {
        event.preventDefault();
        fetch('/api/roles', {
          method: 'POST', body: JSON.stringify({
            userId: form.find("#userId").val(),
          })
        })
          .then(x => x.json())
          .then(x => {            
            saveCookie(form);
            redirectToApp();
          });

      });

it's not perfect (eg you could forward on more details from the form to the roles method (and pull the roles method from the config).

@bzbetty
Copy link

bzbetty commented Dec 13, 2024

Can potentially also use a

{
      "route": "/.auth/login/azureb2c/",
      "rewrite": "/auth.html"
    },

to replace the login file without manually editing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity: days Issues that need a few days to be resolved priority: high (P0) High priority scope: auth Issues related to the authentication emulator status: release-blocker Issues blocking a major release type: enhancement New feature or request type: RFC This is a request for comment
Projects
None yet
Development

No branches or pull requests

8 participants