Search code examples
grailsoauthspring-securitygrails-plugin

Getting Application Configuration in doWithSpring Colsure of Plugin Descriptor


I am extending the Spring oauth Plugin and want to declare beans for some Classes I extended like the OAuthConfig class, I want to declare the extended class as a bean in the doWithSpring closure of the plugin Descriptor

public class MyOAuthConfig extends org.scribe.model.OAuthConfig {


   public MyOAuthConfig(String key, String secret) {
    super(key, secret); 
   }

}

I want to declare this class as a plugin bean

doWithSpring{
   passportOAuthConfig(com.mycompany.security.MyOAuthConfig){
        key = [application configuration here]
   }
}

How can I get a grails application configuration here


Solution

  • You have access to application which is the grailsApplication from doWithSpring. So you can do the following:

    doWithSpring = {
      ...
       passportOAuthConfig(com.mycompany.security.MyOAuthConfig){
            key = application.config.someValueFromHere
       }
      ...
    }