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

Auth role Integratefor User Service Communication in Authentication Service #3

Closed
wants to merge 28 commits into from

Conversation

felixojiambo
Copy link
Owner

Communication between the User Service and Authentication Service to replace direct database access in the Authentication Service. This change ensures better modularity, scalability, and performance, which are critical for a secure and robust banking application.

…cation without creating an entity in the Payment Service.
Added invoiceId as a UUID to reference invoices managed by the Invoice Service.
Maintained the paymentGateway field to identify the external payment gateway used.
…on annotations

- Added CardPaymentRequest class to handle card payment input.
- Applied Jakarta Bean Validation annotations (@notblank, @pattern) for data validation.
- Updated project dependencies to include Hibernate Validator and Jakarta Validation API.
- Ensured proper validation handling in PaymentController with @Valid annotation.
- Implemented Kafka producer configuration in the `KafkaProducerConfig` class.
- Added `ProducerFactory` bean for creating Kafka producer instances with custom configurations.
- Configured `KafkaTemplate` bean for interacting with Kafka topics.
- Set up default configurations for Kafka producer, including:
  - Bootstrap server: `localhost:9092`
  - Key and value serializers: `StringSerializer`

This configuration allows the application to send messages to Kafka topics.
- Added `KafkaProducerService` to handle message publishing to Kafka topics.
- Injected `KafkaTemplate` for seamless interaction with Kafka.
- Created a `sendMessage` method to publish messages to a specified Kafka topic.

This service abstracts Kafka message publishing, promoting reusability and simplicity across the application.
- Implemented `registerUser` method in the controller to handle user registration requests.
- Validates email uniqueness before saving the user.
- Automatically assigns a default role (ROLE_USER) to new users.
- Publishes a user registration event to the Kafka topic `user-registration`.
- Returns a `UserResponse` with user details upon successful registration.

This feature enhances user registration functionality and integrates event-driven messaging for improved system extensibility.
- Configured Kafka consumer with `DefaultKafkaConsumerFactory` for the `auth-service` group.
- Set up message deserialization using `StringDeserializer`.
- Added a `ConcurrentMessageListenerContainer` to listen to the `user-registration` topic.
- Prepared the configuration for handling user registration events via Kafka.

This configuration enables the authentication service to process user-related events for seamless integration across services.
- Add UserController with registration, profile, and role assignment endpoints.
- Configure security for UserService with role-based access control and JWT support.
- Implement UserService for managing users, roles, and password encoding.
- Add AuthController for user login and JWT token generation.
- Configure AuthenticationService security with JwtAuthenticationFilter and stateless sessions.
- Integrate UserServiceClient in AuthenticationService for fetching user details.
- Include DTOs for UserService and AuthenticationService to standardize data transfer.
Copy link

gitguardian bot commented Dec 31, 2024

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
13669044 Triggered Username Password 07a2456 payment-service/src/main/resources/application.yml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@felixojiambo
Copy link
Owner Author

The Authentication Service no longer accesses the user database directly. Ensure the User Service is running and reachable for proper functioning.

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

Successfully merging this pull request may close these issues.

1 participant