Skip to content

Authentication refactoring#5

Merged
tsutomi merged 3 commits into
mainfrom
authentication-refactoring
Aug 7, 2025
Merged

Authentication refactoring#5
tsutomi merged 3 commits into
mainfrom
authentication-refactoring

Conversation

@tsutomi

@tsutomi tsutomi commented Aug 7, 2025

Copy link
Copy Markdown
Member

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 Message class for fluent message construction. These changes improve both the developer experience and the clarity of authentication requirements for messaging channels.

Documentation: Enhanced Authentication Configuration

  • Added a new documentation file docs/Enhanced-Authentication-Configuration.md detailing 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

  • Added a suite of builder methods to the Message class in src/Deveel.Messaging.Abstractions/Messaging/Message.cs for 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.

@tsutomi tsutomi requested a review from Copilot August 7, 2025 21:17
@tsutomi tsutomi self-assigned this Aug 7, 2025
@tsutomi tsutomi added documentation Improvements or additions to documentation enhancement New feature or request labels Aug 7, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/Deveel.Messaging.Connector.Abstractions/Messaging/IChannelSchema.cs Outdated
Comment on lines +73 to +77
public IList<object>? AllowedValues { get; set; }

/// <summary>
/// Gets or sets the authentication role this field plays.
/// </summary>

Copilot AI Aug 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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>

Copilot uses AI. Check for mistakes.
@tsutomi tsutomi merged commit edc796f into main Aug 7, 2025
6 checks passed
@tsutomi tsutomi deleted the authentication-refactoring branch August 7, 2025 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants