Skip to content

Auth domain layer#181

Merged
scraft-official merged 8 commits intorelease/2.25from
feature/auth-domain-layer
Dec 29, 2025
Merged

Auth domain layer#181
scraft-official merged 8 commits intorelease/2.25from
feature/auth-domain-layer

Conversation

@scraft-official
Copy link
Copy Markdown
Collaborator

This pull request introduces a major refactoring of the authentication domain model, moving from a property/type-based approach to a more extensible and modular "auth method" architecture. The changes enable support for multiple authentication methods, improve separation of concerns, and lay the groundwork for future extensibility. The most important changes are grouped below.

Core Domain Model Refactor

  • Replaced the old AuthType/AuthProperties model with a new AuthMethod abstraction in the Auth entity, allowing authentication logic and data to be encapsulated per method. The Auth class now references an AuthMethod and supports method-based creation, modification, and authentication. (Auth.java, AuthMethod.java, AuthMethodType.java, BaseAuthMethod.java, PasswordAuthMethod.java) [1] [2] [3] [4] [5] [6] [7] [8]

  • Removed legacy classes and interfaces: AuthType, AuthProperties, AuthByPasswordProperties, and their usages. (AuthType.java, AuthProperties.java, AuthByPasswordProperties.java) [1] [2] [3]

Authentication Method Abstractions

  • Introduced the AuthMethod interface and supporting types, including AuthMethodType, AuthMethodMeta, and concrete implementations for password authentication. (AuthMethod.java, PasswordAuthMethod.java, AuthMethodMeta.java, BaseAuthMethodType.java) [1] [2] [3] [4]

  • Added serialization/deserialization infrastructure for auth methods, including AuthMethodSerializedModel, AuthMethodSerializer, and AuthMethodDeserializer. (AuthMethodSerializedModel.java, AuthMethodSerializer.java, AuthMethodDeserializer.java) [1] [2] [3]

Creation/Modification/Deletion Meta Refactor

  • Replaced the old AuthByPasswordCreationMeta with a generic AuthCreationMeta interface and a password-specific implementation. Analogous interfaces and classes were added for modification and deletion meta, supporting future extensibility for other auth methods. (AuthCreationMeta.java, PasswordAuthCreationMeta.java, AuthModificationMeta.java, PasswordChangeModificationMeta.java, AuthDeletionMeta.java) [1] [2] [3] [4] [5] [6]

Exception Handling

  • Added a new AuthenticationException for more precise error handling during authentication failures. (AuthenticationException.java)

Metadata and Utility Enhancements

  • Refactored AuthMeta to use Lombok and prepared it for future metadata (e.g., login attempts). (AuthMeta.java)

Overall, these changes modernize the authentication infrastructure, making it more modular, extensible, and maintainable, and prepare the codebase for supporting additional authentication methods in the future.

Replaces the previous AuthType and AuthProperties-based authentication model with a new AuthMethod abstraction. Introduces AuthMethod, AuthMethodMeta, and AuthMethodType interfaces, along with a PasswordAuthMethod implementation. Updates Auth entity and related creation meta to use the new structure. Removes obsolete classes related to the old authentication model.
Introduces AuthModificationMeta interface and PasswordChangeModificationMeta implementation to support modifications to Auth entities, specifically password changes. Updates Auth class to handle modification meta, restricts auth method type changes, and adds canAuthenticate utility method.
Introduced the AuthDeletionMeta interface for deletion metadata in the auth domain. Updated the Auth class to handle AuthDeletionMeta during deletion, preparing for future extensibility.
Introduced interfaces and models for serializing and deserializing authentication methods, including AuthMethodSerializer, AuthMethodDeserializer, and AuthMethodSerializedModel. Refactored PasswordAuthMethod to use a new BaseAuthMethod enum for type management and added deserialization logic. Removed the static factory method from AuthMethodType and centralized type definitions in BaseAuthMethod.
Introduced the @nonnull annotation to the 'method' variable in the Auth class constructor to enforce non-nullability and improve code safety.
Renamed the BaseAuthMethod enum to BaseAuthMethodType and updated all references in PasswordAuthMethod. This improves naming consistency and clarity in the authentication method type implementation.
Updated AuthService.create to require accountId and refactored usage in InitialSetupUseCase. Renamed PasswordAuthMeta to PasswordAuthMethodMeta in PasswordAuthMethod for consistency. Also updated import and builder usage to match new class names.
Annotated the passwordHash and salt variables with @nonnull in PasswordAuthMethod to enforce non-nullability and improve code safety.
@scraft-official
Copy link
Copy Markdown
Collaborator Author

Wszystkie zasoby mojego mózgu zostały tutaj wykorzystane XD, aby nie uciąć sobie drogę na przyszłe wprowadzenie nowych metod,

@scraft-official scraft-official merged commit f3970a6 into release/2.25 Dec 29, 2025
2 checks passed
scraft-official added a commit that referenced this pull request Jan 4, 2026
* Refactor authentication to use AuthMethod abstraction

Replaces the previous AuthType and AuthProperties-based authentication model with a new AuthMethod abstraction. Introduces AuthMethod, AuthMethodMeta, and AuthMethodType interfaces, along with a PasswordAuthMethod implementation. Updates Auth entity and related creation meta to use the new structure. Removes obsolete classes related to the old authentication model.

* Add Auth modification meta and password change support

Introduces AuthModificationMeta interface and PasswordChangeModificationMeta implementation to support modifications to Auth entities, specifically password changes. Updates Auth class to handle modification meta, restricts auth method type changes, and adds canAuthenticate utility method.

* Add AuthDeletionMeta interface and update Auth deletion

Introduced the AuthDeletionMeta interface for deletion metadata in the auth domain. Updated the Auth class to handle AuthDeletionMeta during deletion, preparing for future extensibility.

* Add serialization support for auth methods

Introduced interfaces and models for serializing and deserializing authentication methods, including AuthMethodSerializer, AuthMethodDeserializer, and AuthMethodSerializedModel. Refactored PasswordAuthMethod to use a new BaseAuthMethod enum for type management and added deserialization logic. Removed the static factory method from AuthMethodType and centralized type definitions in BaseAuthMethod.

* Add @nonnull annotation to method variable in Auth

Introduced the @nonnull annotation to the 'method' variable in the Auth class constructor to enforce non-nullability and improve code safety.

* Rename BaseAuthMethod to BaseAuthMethodType

Renamed the BaseAuthMethod enum to BaseAuthMethodType and updated all references in PasswordAuthMethod. This improves naming consistency and clarity in the authentication method type implementation.

* Refactor auth creation and password auth meta classes

Updated AuthService.create to require accountId and refactored usage in InitialSetupUseCase. Renamed PasswordAuthMeta to PasswordAuthMethodMeta in PasswordAuthMethod for consistency. Also updated import and builder usage to match new class names.

* Add @nonnull to passwordHash and salt variables

Annotated the passwordHash and salt variables with @nonnull in PasswordAuthMethod to enforce non-nullability and improve code safety.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants