diff --git a/README.md b/README.md index a96ac16..ee87ab9 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,46 @@ -![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/587734441/25.1.3%2B) [![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T1145991) [![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183) [![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives) # XAF - Customize Logon Parameters -This example demonstrates how to customize standard authentication behavior and supply additional logon parameters in XAF applications. The default login form displays **User Name** and **Password** editors. This sample customizes the login form to show **Company** and **Application User** lookup editors instead of **User Name**. +This example customizes standard authentication behavior and supplies additional logon parameters in an XAF application. The default login form displays **User Name** and **Password** editors. This sample replaces **User Name** with **Company** and **Application User** lookup editors. + ![Login form](https://docs.devexpress.com/eXpressAppFramework/images/custom-logon-prameters-blazor.png) +> **Note**: +> * When first running a Blazor application, it does not create a database or populate lookup editors. To create a database, either log in with an empty username or start the Middle Tier server. +> * If using Middle Tier security, start the Middle Tier server before launching the Blazor or Win Forms client. ## Implementation Details -### ASP.NET Core Blazor - -1. Define a [Company](./CS/EF/EFCoreCustomLogonAll.Module/BusinessObjects/Company.cs) class that contains company names. This class should contain a list of `ApplicationUser` objects as a part of a one-to-many relationship. Add the second part of this relationship to the [ApplicationUser](./CS/EF/EFCoreCustomLogonAll.Module/BusinessObjects/ApplicationUser.cs#L28) class generated by the Solution Wizard. Finally, add the `Company` class to your application’s [DbContext](./CS/EF/EFCoreCustomLogonAll.Module/BusinessObjects/EFCoreCustomLogonAllDbContext.cs#L43). -2. Create a custom logon parameter class that uses the `Company` class. To see an example, refer to the following file - [CustomLogonParameters.cs]. -3. Implement [custom authentication] that uses custom logon parameters. -4. Implement a custom [authentication provider] that creates an instance of the custom authentication strategy. -5. Pass custom classes to the Security System. To see an example, refer to the following file - [Startup.cs](./CS/EF/EFCoreCustomLogonAll.Blazor.Server/Startup.cs#L73-L78). -6. Add [demo data](./CS/EF/EFCoreCustomLogonAll.Module/DatabaseUpdate/Updater.cs). -7. Generate a [demo database](https://docs.devexpress.com/eXpressAppFramework/404264/data-security-and-safety/security-system/authentication/customize-standard-authentication-behavior-and-supply-additional-logon-parameters/customize-authentication-behavior-blazor#generate-a-demo-database). -8. Run the application. +1. Define a [Company](./CS/EF/EFCoreCustomLogonAll.Module/BusinessObjects/Company.cs) class that contains company names. This class should contain a list of `ApplicationUser` objects as a part of a one-to-many relationship. Add the second part of this relationship to the [ApplicationUser](./CS/EF/EFCoreCustomLogonAll.Module/BusinessObjects/ApplicationUser.cs#L28) class generated by the [Template Kit](https://docs.devexpress.com/eXpressAppFramework/405447/installation-upgrade-version-history/visual-studio-integration/template-kit). Then, add the `Company` class to your application's [DbContext](./CS/EF/EFCoreCustomLogonAll.Module/BusinessObjects/EFCoreCustomLogonAllDbContext.cs#L43). -For detailed instructions, refer to the following topic: [Customize Standard Authentication Behavior and Supply Additional Logon Parameters (Blazor)](https://docs.devexpress.com/eXpressAppFramework/404264/data-security-and-safety/security-system/authentication/customize-standard-authentication-behavior-and-supply-additional-logon-parameters/customize-authentication-behavior-blazor). +1. Create a custom logon parameter class that uses the `Company` class ([CustomLogonParameters.cs](./CS/EF/EFCoreCustomLogonAll.Module/Authentication/CustomLogonParameters.cs)). +1. To access lists of companies and application users in login form (before authentication), implement data transfer objects (DTO) ([CompanyDTO.cs](./CS/EF/EFCoreCustomLogonAll.Module/Authentication/CompanyDTO.cs) / [ApplicationUserDTO.cs](./CS/EF/EFCoreCustomLogonAll.Module/Authentication/ApplicationUserDTO.cs)). +1. Register the `CustomLogonParameters` type as a known logon parameter type ([Program.cs (Blazor)](./CS/EF/EFCoreCustomLogonAll.Blazor.Server/Program.cs#L17) / [Program.cs (WinForms)](CS/EF/EFCoreCustomLogonAll.Win/Program.cs#L14)). +1. A lookup editor displays the Edit button. Create a controller and call the [CustomizeViewItemControl](https://docs.devexpress.com/eXpressAppFramework/DevExpress.ExpressApp.DetailViewExtensions.CustomizeViewItemControl.overloads) method to hide the button from the **Company** and **Application User** lookup editors ([CustomLogonParameterLookupActionVisibilityController.cs](./CS/EF/EFCoreCustomLogonAll.Blazor.Server/Authentication/CustomLogonParameterLookupActionVisibilityController.cs)). -### WinForms and ASP.NET Web Forms - -For detailed instructions, refer to the following topic: [Customize Standard Authentication Behavior and Supply Additional Logon Parameters (WinForms & ASP.NET Web Forms)](https://docs.devexpress.com/eXpressAppFramework/112982/data-security-and-safety/security-system/authentication/customize-standard-authentication-behavior-and-supply-additional-logon-parameters/customize-authentication-behavior-web). +For detailed instructions, refer to the following topic: [Customize Standard Authentication Behavior and Supply Additional Logon Parameters](https://docs.devexpress.com/eXpressAppFramework/404264/data-security-and-safety/security-system/authentication/customize-standard-authentication-behavior-and-supply-additional-logon-parameters/customize-authentication-behavior-blazor). ## Files to Review * [Company.cs](./CS/EF/EFCoreCustomLogonAll.Module/BusinessObjects/Company.cs) -* [CustomLogonParameters.cs] -* [CustomAuthentication.cs] -* [CustomAuthenticationStandardProvider.cs] +* [ApplicationUser.cs](./CS/EF/EFCoreCustomLogonAll.Module/BusinessObjects/ApplicationUser.cs) +* [EFCoreCustomLogonAllDbContext.cs](./CS/EF/EFCoreCustomLogonAll.Module/BusinessObjects/EFCoreCustomLogonAllDbContext.cs) +* [CustomLogonParameters.cs](./CS/EF/EFCoreCustomLogonAll.Module/Authentication/CustomLogonParameters.cs) +* [Program.cs (Blazor)](./CS/EF/EFCoreCustomLogonAll.Blazor.Server/Program.cs) +* [Program.cs (WinForms)](CS/EF/EFCoreCustomLogonAll.Win/Program.cs) +* [CompanyDTO.cs](./CS/EF/EFCoreCustomLogonAll.Module/Authentication/CompanyDTO.cs) +* [ApplicationUserDTO.cs](./CS/EF/EFCoreCustomLogonAll.Module/Authentication/ApplicationUserDTO.cs) +* [CustomLogonParameterLookupActionVisibilityController.cs](./CS/EF/EFCoreCustomLogonAll.Blazor.Server/Authentication/CustomLogonParameterLookupActionVisibilityController.cs) ## Documentation -* [Customize Standard Authentication Behavior and Supply Additional Logon Parameters (Blazor)](https://docs.devexpress.com/eXpressAppFramework/404264/data-security-and-safety/security-system/authentication/customize-standard-authentication-behavior-and-supply-additional-logon-parameters/customize-authentication-behavior-blazor) -* [Customize Standard Authentication Behavior and Supply Additional Logon Parameters (WinForms & ASP.NET Web Forms)](https://docs.devexpress.com/eXpressAppFramework/112982/data-security-and-safety/security-system/authentication/customize-standard-authentication-behavior-and-supply-additional-logon-parameters/customize-authentication-behavior-web) +* [Customize Standard Authentication Behavior and Supply Additional Logon Parameters (**.NET Applications**)](https://docs.devexpress.com/eXpressAppFramework/404264/data-security-and-safety/security-system/authentication/customize-standard-authentication-behavior-and-supply-additional-logon-parameters/customize-authentication-behavior-blazor) +* [Customize Standard Authentication Behavior and Supply Additional Logon Parameters (**.NET Framework Applications**)](https://docs.devexpress.com/eXpressAppFramework/112982/data-security-and-safety/security-system/authentication/customize-standard-authentication-behavior-and-supply-additional-logon-parameters/customize-authentication-behavior-web) ## More Examples -* [XAF ASP.NET Web Forms - Use OAuth2 Authentication Providers](https://github.com/DevExpress-Examples/xaf-web-forms-use-oauth2-authentication-providers) + * [Role-based Access Control, Permission Management, and OData / Web / REST API Services for Entity Framework and XPO ORM](https://github.com/DevExpress-Examples/XAF_Security_E4908) ## Does this example address your development requirements/objectives?