Ticket T1284828
Visible to All Users

Set LogonParametersType in MiddleTier Security WinForms

created 15 days ago

I am trying to add a Custom Logon Parameter to an XAF .NET 9.0 WinForms Application using Middle Tier Security.
The following code in Startup.cs (builder.Security) does not compile

Code
.AddPasswordAuthentication(options => { options.IsSupportChangePassword = true; options.**LogonParametersType** = typeof(CustomLogonParameters); options.**Events**.OnAuthenticate = context => { CustomLogonParameters logonParameters = (CustomLogonParameters)context.LogonParameters; ... }; });

Error : MiddleTierPasswordAuthenticationOptions does not contain a definition for LogonParametersType
MiddleTierPasswordAuthenticationOptions does not contain a definition for Events

Neither does this

Code
.**AddAuthenticationProvider**<AuthenticationStandardProviderOptions, ApplicationAuthenticationStandardProvider>(options => { options.IsSupportChangePassword = true; options.LogonParametersType = typeof(CustomLogonParameters); });

Error : MiddleTierPasswordAuthenticationOptions does not contain a definition for AddAuthenticationProvider

How do I fix this, What am I likely doing wrong?

Answers approved by DevExpress Support

created 13 days ago

Hello,

To complete this task, create a custom authentication class as demonstrated here: Customize Standard Authentication Behavior and Supply Additional Logon Parameters (.NET Applications) | XAF: Cross-Platform .NET App UI & Web API | DevExpress Documentation. I created a simple example for you to illustrate how to achieve this with a middle-tier app of v24.2.6.

The result:
Clipboard-File-1.png

Please try this solution and let me know if it helps.

Regards,
Andrey

    Comments (3)
    F F
    Fitzroy F. Wright 12 days ago

      In your documentation from the link you provided it says

      Pass Custom Classes to the Security System

      If You Used the OnAuthenticate Event

      In the application’s Startup.cs files, set the provider’s LogonParametersType option to CustomLogonParameters within the AddPasswordAuthentication method call.
      File: MySolution.Blazor.Server\Startup.cs, MySolution.Win\Startup.cs, (MySolution.MiddleTier\Startup.cs), MySolution.WebApi\Startup.cs

      Based on your example it seams I should ignore this instruction as your example does not do this.

      Herman (DevExpress Support) 11 days ago

        Hello Fitzroy,

        Thank you for the update.

        We're working on your inquiry and will update this ticket once we have information to share or if we require clarification.

        Best regards,
        Herman

        Andrey K (DevExpress Support) 11 days ago

          Hello,

          Thank you for your patience.

          It should also be possible to use this option. I modified my example so it doesn't use CustomAuthentication and set the logon parameters via the AuthenticationStandardProviderOptions.LogonParametersType property. Please pay attention to the change made in the setLog\setLog.MiddleTier\JWT\WebApiAuthenticationController.cs file.

          Let me know if this helps.

          Regards,
          Andrey

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.