Skip to content

Commit

Permalink
Merge pull request #419 from alvarosanchez/feature/issue-389
Browse files Browse the repository at this point in the history
Fix for #389
  • Loading branch information
alvarosanchez authored Feb 13, 2020
2 parents f10a8ca + 8750f0a commit 0b28eb4
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,14 @@ class SpringSecurityRestGrailsPlugin extends Plugin {
GrailsApplication grailsApplication

Closure doWithSpring() { {->
def conf = SpringSecurityUtils.securityConfig
if (!conf || !conf.active) {
if (!springSecurityPluginsAreActive()){
return
}

def conf = SpringSecurityUtils.securityConfig
SpringSecurityUtils.loadSecondaryConfig 'DefaultRestSecurityConfig'
conf = SpringSecurityUtils.securityConfig

if (!conf.rest.active) {
return
}

boolean printStatusMessages = (conf.printStatusMessages instanceof Boolean) ? conf.printStatusMessages : true

if (printStatusMessages) {
Expand Down Expand Up @@ -297,6 +293,9 @@ class SpringSecurityRestGrailsPlugin extends Plugin {

@Override
void doWithApplicationContext() {
if (!springSecurityPluginsAreActive()){
return
}
def customClaimProvidersList = applicationContext.getBeanNamesForType(CustomClaimProvider).collect {
applicationContext.getBean(it, CustomClaimProvider)
}
Expand Down Expand Up @@ -358,5 +357,19 @@ class SpringSecurityRestGrailsPlugin extends Plugin {
"sha256": new StandardPasswordEncoder()]
}

private boolean springSecurityPluginsAreActive() {
def conf = SpringSecurityUtils.securityConfig
if (!conf || !conf.active) {
return false
}

SpringSecurityUtils.loadSecondaryConfig 'DefaultRestSecurityConfig'
conf = SpringSecurityUtils.securityConfig

if (!conf.rest.active) {
return false
}
return true
}

}

0 comments on commit 0b28eb4

Please sign in to comment.