On this page
- 1. Module Overview
- 2. Features
- 3. Requirements
- 4. Installation
- Step-by-Step Installation
- 5. Configuration
- 6. Block Configuration
- Steps to Configure the Block:
- 7. Usage
- Example Output
- 8. Code Structure
- Key Files and Directories
- Code Explanation
- 9. Development Guidelines
- Testing
- 10. Support and Maintenance
- License
How to use Entra ID login block
Technical and Functional Documentation for social_auth_entra_id module.
1. Module Overview
The social_auth_entra_id module provides a login block for users to authenticate using Microsoft Entra ID. It integrates with the Microsoft Entra ID OAuth2 service to facilitate user login and manage user sessions.
2. Features
- Entra ID Authentication: Allows users to log in using their Microsoft Entra ID.
- Customizable Login Link: Administrators can customize the login text and add custom CSS classes.
- User-Friendly Interface: Displays different content based on user authentication status (logged in vs. anonymous).
3. Requirements
- Drupal 9 or 10: This module is compatible with both versions.
- PHP 7.3 or higher: Ensure your server meets the PHP requirements.
- Composer: To manage dependencies.
4. Installation
Step-by-Step Installation
Download the Module: download using composer
composer require 'drupal/social_auth_entra_id'- Download the Module: Clone the module from the repository or download it directly.
git clone <repository-url> modules/custom/social_auth_entra_id- Enable the Module: Navigate to the modules page in the Drupal admin interface or run the following command:
drush en social_auth_entra_id- Verify Installation: Ensure the module appears in the list of enabled modules.
5. Configuration
After enabling the module, configure the necessary settings:
- Navigate to the Configuration Page: Go to
/admin/config/services/entra-id/settingsin your Drupal site. - Enter the Required API Credentials: Fill in the details for Microsoft Entra ID (Client ID, Client Secret, etc.).
- Redirect URI (optional)
- Platform: Web
- Call back url
your-domain/user/login/entra-id/callback
- Save Configuration: Click "Save" to apply your settings.
6. Block Configuration
The EntraIdLoginBlockBlock provides a login interface that can be added to any region of your theme.
Steps to Configure the Block:
- Navigate to the Block Layout Page: Go to
/admin/structure/blockin your Drupal site. - Place the Block: Find "Entra ID Login Block" in the list and click "Place Block" next to it.
- Configure the Block Settings:
- Login Text: Enter the HTML to be displayed for the login link (e.g.,
<i class="fa-brands fa-microsoft"></i> Log in with Microsoft Entra ID). - Custom Class: Enter any additional CSS classes you want to apply to the link.
- Save Block Configuration: Click "Save Block".
7. Usage
Once the module is installed and configured:
- Anonymous Users: The block will display a login link allowing users to authenticate via Microsoft Entra ID.
Example Output
- For anonymous users:
<a href="/user/login/entra-id" class="btn btn-primary"><i class="fa-brands fa-microsoft"></i> Log in with Microsoft Entra ID</a>8. Code Structure
Key Files and Directories
src/Plugin/Block/EntraIdLoginBlockBlock.php: Contains the main block logic.social_auth_entra_id.module: Implements hook functions and other module-wide logic.config/schema/social_auth_entra_id.schema.yml: Defines the configuration schema for the module.
Code Explanation
- EntraIdLoginBlockBlock Class: Extends
BlockBaseand implements the methods necessary to build the block, configure settings, and submit form values. - build() Method: Generates the HTML output based on the user's authentication status.
- blockForm() and blockSubmit() Methods: Handle the configuration form for customizing the login text and CSS class.
9. Development Guidelines
- Follow Drupal coding standards for all PHP code.
- Ensure that all new features are covered by unit tests.
- Maintain backward compatibility where possible.
Testing
Run the tests using PHPUnit to verify module functionality.
phpunit
10. Support and Maintenance
For support, please open an issue in the module repository or contact the maintainer directly.
License
This module is licensed under the GPL-2.0-or-later license.
This template covers all necessary aspects of the social_auth_entra_id module, from installation to usage. Be sure to customize it further based on any specific features or requirements your module might have!
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion