zyro23 / grails-spring-websocket

93 stars 28 forks source link

A component required a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' that could not be found. #63

Closed antondelpiero closed 6 years ago

antondelpiero commented 6 years ago

Hi there,

I need a little help. I create a new REST Grails 3 app with this plugins:

compile 'org.grails.plugins:spring-security-core:3.2.1'
compile("org.grails.plugins:spring-security-rest:2.0.0.M2") {
  exclude group: 'org.grails.plugins', module: 'spring-security-core'
}
compile "org.grails.plugins:grails-spring-websocket:2.4.1"
compile "org.springframework.security:spring-security-config:5.0.3.RELEASE"
compile "org.springframework.security:spring-security-messaging:5.0.3.RELEASE"
compile "org.springframework.security:spring-security-web:5.0.3.RELEASE"

without the three last plugin I can start the app, but I need to secure the communication therefore the last 3 plugins.

zyro23 commented 6 years ago

try aligning the spring-security-config/spring-security-messaging versions with the spring-security-core version pulled in by the grails spring-security plugin (or rather defined by the spring-boot bom), i.e. 4.2.x.

compile "org.springframework.security:spring-security-config"
compile "org.springframework.security:spring-security-messaging"

(leaving out spring-security-web as that is already a dependency of the spring-security-core plugin).

depending on your setup, if you get any startup error related to boot autoconfiguration, you might have to exclude some auto-configuration classes, e.g. by putting this onto your Application class:

@EnableAutoConfiguration(exclude = [SecurityFilterAutoConfiguration, SpringBootWebSecurityConfiguration])

after that, you should be able to use a @Configuration bean extending AbstractSecurityWebSocketMessageBrokerConfigurer.

antondelpiero commented 6 years ago

Thank you very much, it works. Would you mind updating the doc?

zyro23 commented 6 years ago

the docs are correct. the issue you were facing is just that you are using the spring-security-core grails plugin. the example in the docs is not. but sure, if you feel that is misleading, feel free to pull-request a hint reg. the grails spring-security-core plugin to the "misc" section at the bottom of the readme.

glad you got it working!