Authentication refactoring#5
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces comprehensive enhancements to the authentication configuration system and replaces the MessageBuilder pattern with fluent methods directly on the Message class. The changes provide more precise authentication validation through explicit field mapping and improve the developer experience with built-in fluent message construction.
- Enhanced authentication configuration system with detailed field mapping and flexible validation patterns
- Removal of MessageBuilder class in favor of fluent methods directly on the Message class
- Migration from generic authentication type validation to provider-specific authentication configurations
Reviewed Changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/Deveel.Messaging.Abstractions/Messaging/Message.cs |
Added comprehensive fluent builder methods directly to Message class |
src/Deveel.Messaging.Abstractions/Messaging/MessageBuilder.cs |
Completely removed MessageBuilder class |
src/Deveel.Messaging.Connector.Abstractions/Messaging/IChannelSchema.cs |
Updated interface to use AuthenticationConfigurations instead of AuthenticationTypes |
src/Deveel.Messaging.Connector.Abstractions/Messaging/ChannelSchema.cs |
Major refactoring to support new authentication configuration system |
src/Deveel.Messaging.Connector.Abstractions/Messaging/AuthenticationConfiguration.cs |
New class defining explicit authentication field requirements |
src/Deveel.Messaging.Connector.Abstractions/Messaging/AuthenticationField.cs |
New class representing individual authentication fields with validation |
src/Deveel.Messaging.Connector.Abstractions/Messaging/FlexibleAuthenticationConfiguration.cs |
New class supporting flexible "any one of" field validation |
src/Deveel.Messaging.Connector.Abstractions/Messaging/AuthenticationConfigurations.cs |
Factory class providing predefined authentication configurations |
docs/Enhanced-Authentication-Configuration.md |
Comprehensive documentation of the new authentication system |
| Multiple test files | Updated to use new Message fluent interface and authentication configurations |
| public IList<object>? AllowedValues { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the authentication role this field plays. | ||
| /// </summary> |
There was a problem hiding this comment.
The AllowedValues property returns a mutable IList which allows external modification of the validation rules. Consider using IReadOnlyList for the getter and providing a separate method for modifications to maintain data integrity.
| public IList<object>? AllowedValues { get; set; } | |
| /// <summary> | |
| /// Gets or sets the authentication role this field plays. | |
| /// </summary> | |
| /// <summary> | |
| /// Gets the collection of allowed values for this field as a read-only list. | |
| /// </summary> | |
| /// <remarks> | |
| /// If specified, the field value must be one of the allowed values. | |
| /// If null or empty, any value of the correct data type is allowed. | |
| /// </remarks> | |
| public IReadOnlyList<object>? AllowedValues => _allowedValues; | |
| /// <summary> | |
| /// Sets the allowed values for this field. | |
| /// </summary> | |
| /// <param name="values">The collection of allowed values.</param> | |
| public void SetAllowedValues(IEnumerable<object>? values) { | |
| if (values == null) { | |
| _allowedValues = null; | |
| } else { | |
| _allowedValues = new List<object>(values); | |
| } | |
| } | |
| /// <summary> | |
| /// Adds a value to the allowed values collection. | |
| /// </summary> | |
| /// <param name="value">The value to add.</param> | |
| public void AddAllowedValue(object value) { | |
| if (_allowedValues == null) { | |
| _allowedValues = new List<object>(); | |
| } | |
| _allowedValues.Add(value); | |
| } | |
| /// <summary> | |
| /// Removes a value from the allowed values collection. | |
| /// </summary> | |
| /// <param name="value">The value to remove.</param> | |
| /// <returns>True if the value was removed; otherwise, false.</returns> | |
| public bool RemoveAllowedValue(object value) { | |
| if (_allowedValues == null) { | |
| return false; | |
| } | |
| return _allowedValues.Remove(value); | |
| } | |
| /// </summary> |
This pull request introduces two main enhancements: a comprehensive documentation update describing the new enhanced authentication configuration system for Channel Schemas, and a set of builder methods to the
Messageclass for fluent message construction. These changes improve both the developer experience and the clarity of authentication requirements for messaging channels.Documentation: Enhanced Authentication Configuration
docs/Enhanced-Authentication-Configuration.mddetailing the enhanced authentication configuration system. This includes explicit field mapping, flexible authentication options, provider-specific patterns, usage examples, migration guidance, and a summary of benefits and predefined configurations.API Improvements: Fluent Message Construction
Messageclass insrc/Deveel.Messaging.Abstractions/Messaging/Message.csfor fluent, chainable message creation. These methods allow setting the message ID, sender/receiver (by endpoint, email, or phone), content (text or HTML), and attaching properties such as subject, remote ID, and reply-to information.