Skip to content

Conversation

@crazyrokr
Copy link
Collaborator

@crazyrokr crazyrokr commented Dec 9, 2025

#67

The main goal of the PR is to prepare a module and class structures covering the most common authentication mechanisms, so it introduces the following entities:

  1. AuthRequest is a DTO containing all necessary authentication data
  2. AuthenticationService allows to authenticate incoming AuthRequest
  3. AuthenticationProvider provides an authentication mechanism (Basic, X509, JWT, etc.)
  4. CredentialsSource provides access to different authentication data storages (file, database, network, etc.)

@crazyrokr crazyrokr linked an issue Dec 9, 2025 that may be closed by this pull request
@crazyrokr crazyrokr changed the title [broker-67] Add authentications modules and initial class structure [broker-67] Design of authentication mechanism Dec 9, 2025
# Conflicts:
#	acl-groovy-dsl/src/main/groovy/javasabr/mqtt/service/acl/AclRulesLoader.groovy
#	application/src/main/java/javasabr/mqtt/broker/application/config/MqttBrokerSpringConfig.java
@github-actions
Copy link

github-actions bot commented Dec 10, 2025

Test Coverage Report

Overall Project 86.27% -0.12% 🍏
Files changed 94.76% 🍏

File Coverage
AclRulesLoader.groovy 100% 🍏
AuthRequest.java 100% 🍏
ConnectToAuthRequestConverter.java 100% 🍏
DefaultAuthenticationService.java 100% 🍏
CredentialsSourceDatabaseProperties.java 100% 🍏
AllOfBuilder.groovy 98.13% 🍏
R2dbcCredentialsSource.java 93.75% -6.25% 🍏
AuthenticationSpringConfig.java 90.4% -9.6% 🍏
MqttBrokerSpringConfig.java 90.23% 🍏
ConnectInMqttInMessageHandler.java 80.86% 🍏
FileCredentialsSource.java 79.69% -3.13% 🍏
PasswordBasedAuthenticationProvider.java 71.43% -28.57% 🍏
InMemoryCredentialSource.java 70% 🍏

@crazyrokr crazyrokr self-assigned this Dec 10, 2025
@crazyrokr crazyrokr added enhancement New feature or request core labels Dec 10, 2025
@crazyrokr crazyrokr requested a review from JavaSaBr December 10, 2025 22:27

@Bean
AuthenticationService authenticationService(
List<AuthenticationProvider> credentialSource,
Copy link
Owner

Choose a reason for hiding this comment

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

authenticationProviders or credentialSource?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@@ -0,0 +1,5 @@
DROP TABLE IF EXISTS user_credentials;
CREATE TABLE user_credentials (
Copy link
Owner

Choose a reason for hiding this comment

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

I think for our own version of DB tables we should use Flyway

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, let's implement this within the ticket #141

@@ -0,0 +1,12 @@
package javasabr.mqtt.model.message;

public interface AuthRequest {
Copy link
Owner

Choose a reason for hiding this comment

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

I think it can be a record. it's not a very intensive operation, we can make it "nicer"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@crazyrokr crazyrokr marked this pull request as ready for review December 13, 2025 15:04
@crazyrokr crazyrokr requested a review from JavaSaBr December 13, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Design of authentication mechanism

3 participants