apache / directory-scimple

Apache Directory - SCIMple
https://directory.apache.org/scimple/
Apache License 2.0
66 stars 37 forks source link

[scim-server] Usage in SpringBoot breaks standard @RestController and SecurityFilters #575

Closed 39otrebla closed 3 months ago

39otrebla commented 3 months ago

I've successfully integrated this library in Spring Boot 3.2.4, and it works like a charm (so thank you).

However, our SpringBoot application has to serve other HTTP endpoints besides SCIM ones, and we are having mainly two issues:

  1. we implemented a test @RestController with a simple @GetMapping("/test-endpoint"), but calling this endpoint ends up invoking the SCIM server (which in turn does not find this path mapping and returns 404).

  2. it seems there's no way to configure a prefix for all SCIM endpoints (e.g. /SCIM/**. This makes it impossible to configure multiple SecurityFilter(s) based on the path prefix, which is required if the same SpringBoot application serves other resources

39otrebla commented 3 months ago

Apologies, I found out just now that Jakarta Application was registered as CondtionalOnMissingBean.

For anyone having the same question, it is as simple as overriding the default @Bean for the Jakarta Application, using @ApplicationPath("/prefix"):

// ScimServerApplication.java

@ApplicationPath("/scim")
public class ScimServerApplication extends Application {
    @Override
    public Set<Class<?>> getClasses() {
        return ScimResourceHelper.scimpleFeatureAndResourceClasses();
    }
}

And then:

// MyApplication.java

@Bean
ServerConfiguration serverConfiguration() {
    return new ServerConfiguration()
            .setId("contoso.com")
            // all other configs
            .setBulkMaxOperations(50);
}

@Bean
Application scimApplication() {
    return new ScimServerApplication();
}

I confirm that both issues in the OP are solved. It may be worth mentioning in the doc.

kkucybala commented 1 month ago

These simple additions indeed fixed the problem for my project too, would be worthwhile adding it to the docs because anyone trying to integrate this library in any non-trivial service will have the same problem

bdemers commented 4 weeks ago

Great points!
Does anyone want to take a quick pass at updating the README?