integrate Identity Access module! with your main project - Wiz-DevTech/prettygirllz GitHub Wiki

Congratulations on completing your Identity Access module! Now that your Spring Security implementation is working correctly, you need to integrate it with your main project. Here's how to do that:

Add the module as a dependency in your main project If you're using Maven in your main project, add the Identity Access module as a dependency in your main project's pom.xml:

<dependency>
  <groupId>com.wizdevtech</groupId>
  <artifactId>identity-access</artifactId>
  <version>1.0.0</version>
</dependency>
If using Gradle, add to your build.gradle:
'''
'''groovy
dependencies {
  implementation project(':identity-access')
}

Configure your main application to use the security components In your main application's configuration, import the security configuration: '''java @Import(com.wizdevtech.identityaccess.config.SecurityConfig.class) @SpringBootApplication public class MainApplication { // ... } ''' Configure shared database settings Make sure your main application uses the same database configuration or properly separates the databases if needed. Update your environment variables Ensure your main application has access to the same environment variables needed by the Identity Access module, particularly:

JWT_SECRET
JWT_EXPIRATION
ENCRYPTION_KEY

Implement the authentication in your controllers In your main application's controllers, you can now use annotations like @PreAuthorize to secure endpoints:

@RestController
@RequestMapping("/api/resources")
public class ResourceController {
    
    @GetMapping
    @PreAuthorize("isAuthenticated()")
    public ResponseEntity<?> getResources() {
        // Only authenticated users can access
        return ResponseEntity.ok("Protected resources");
    }
    
    @GetMapping("/admin")
    @PreAuthorize("hasRole('ADMIN')")
    public ResponseEntity<?> getAdminResources() {
        // Only admins can access
        return ResponseEntity.ok("Admin resources");
    }
}

Test the integration After integrating the module, test that authentication works across your entire application by:

Registering/logging in through the Identity Access endpoints Using the JWT token to access your main application's protected resources

Update documentation Make sure to update your project documentation to include information about:

The authentication flow Available endpoints for registration/login How to use JWT tokens in requests Any role-based access control information

This modular approach allows you to maintain the Identity Access functionality separately while seamlessly integrating it with your main application.

⚠️ **GitHub.com Fallback** ⚠️