Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling Third-Party Authentication and Role Synchronization in DDD and Clean Architecture #657

Open
itsoli91 opened this issue Dec 28, 2023 · 1 comment

Comments

@itsoli91
Copy link

itsoli91 commented Dec 28, 2023

I'm working on a project that tries to use DDD and Clean Architecture principles. The project integrates with a third-party service for authentication and role management. In this context, I face a specific challenge:

Situation:

  • We use a third-party service to handle authentication.
  • Roles are created in this third-party service via an API call.
  • In our domain, we have a corresponding Role entity.
  • The creation of our Role entity is dependent on the successful creation of a role in the third-party service.

Question:

Interface Definition: In the context of DDD and Clean Architecture, where should I define the interfaces for this role synchronization process? Should they be part of the Core layer, UseCase layer, or elsewhere?

Implementation Location: Considering the dependency on an external service, where is it most appropriate to place the implementation of these interfaces? How should the interaction between our system and the third-party service be structured to maintain the integrity of our architecture?

I'm looking for guidance on structuring this functionality and please If you find it useful add similar situation to the sample for better understanding when integration with third party services is needed.

@itsoli91
Copy link
Author

itsoli91 commented Dec 29, 2023

In addition to the previously mentioned inquiries. Should all Commands and Queries be exclusively defined within the UseCase layer, or is it acceptable to define some within the Infrastructure layer?

For instance, consider the scenario where a user needs to upload a file. The file is initially saved in a storage solution, which could be a local system or a cloud service. Subsequently, the storage path or link must be communicated to the UseCase layer for further processing by the appropriate handler.

In this context, I'm contemplating an approach where a command is initially handled in the Infrastructure layer. Within this command's handling, another command is generated and passed to the UseCase layer to continue the logic. Would this be a feasible and architecturally sound approach? Additionally, are there any best practices or potential pitfalls that should be considered in such a design?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant