SimpleIdServer icon indicating copy to clipboard operation
SimpleIdServer copied to clipboard

PWP registration workflow

Open BrunoFelipe-dev opened this issue 1 year ago • 2 comments

In the PWD registration flow, a username and password are requested. It is possible to register a user by adding a valid email address to the username field. However, when logging in, the following error occurs:

ArgumentException: Invalid cookie name: [email protected] (Parameter 'value') Microsoft.Net.Http.Headers.CookieHeaderValue.CheckNameFormat(StringSegment name, string parameterName)

Register: Captura de tela 2024-11-22 113121

User created: Captura de tela 2024-11-22 113138

Login: Captura de tela 2024-11-22 114131

Error on submit: Captura de tela 2024-11-22 113257

Is it possible to implement a registration flow where the user is able to register with "email (in the username field) and password" to log in?

What should I do to make possible to do it this way, since it is how applications with identity server usually do it. In my case, I would like to force the username to always be an email address in the registration step and validate the email using code in a second step in my application.

BrunoFelipe-dev avatar Nov 22 '24 14:11 BrunoFelipe-dev

To always use the email as the login, the property IsEmailUsedDuringAuthentication must be set to true. Edit the Program.cs file and modify the options as follows:

idServerBuilder = services.AddSIDIdentityServer(callback: cb =>
        {
            cb.IsEmailUsedDuringAuthentication = true;
            if (!string.IsNullOrWhiteSpace(identityServerConfiguration.SessionCookieNamePrefix))
                cb.SessionCookieName = identityServerConfiguration.SessionCookieNamePrefix;
            cb.Authority = identityServerConfiguration.Authority;
            cb.ScimClientOptions = conf;
        }, cookie: c =>
        {
            if (!string.IsNullOrWhiteSpace(identityServerConfiguration.AuthCookieNamePrefix))
                c.Cookie.Name = identityServerConfiguration.AuthCookieNamePrefix;
        }, dataProtectionBuilderCallback: ConfigureDataProtection)

Configuring the Registration Workflow

Follow these steps to configure the registration workflow:

  1. Open the administration website and navigate to the Manual Identity Provisioning section.
  2. Click the add registration workflow button and fill out the form with the following values:
  • Name : workflow
  • Auth methods : pwd, email
  1. Click the add button to confirm the creation.

The registration workflow is now ready for use and can be accessed via the following URL:: https://localhost:5001/master/registration?workflowName=workflow

Checking Email Client Configuration

Before launching the registration workflow, ensure the email client is properly configured:

  1. Open the administration website and navigate to the Authentication window.
  2. Click on the Email element and verify that the configuration is correct.

Known issue

There is currently a minor issue with cookie creation. This issue will be resolved in the Release503 branch.

simpleidserver avatar Nov 22 '24 15:11 simpleidserver

The issue has been fixed in the Release503 branch. Now, when the login is in an email format, authentication will work. :)

simpleidserver avatar Nov 23 '24 19:11 simpleidserver