LoginSignup
6
6

More than 5 years have passed since last update.

[Grails]SpringSecurityCoreを導入してdbconsoleが使えなくなった際の対応

Posted at

webベースでデータベースの確認が行える便利なdbconsoleですが、SpringSecurityCoreを導入すると、アノテーションの宣言されていないコントローラにアクセスするとAccess Deniedとなってしまい、dbconsoleが使えなくなってしまいます。

じゃあdbconsoleのコントローラにアノテーションを。。。と思いましたが、 grails-app/conf/Config.groovygrails.plugin.springsecurity.controllerAnnotations.staticRulesに、dbconsoleへのアクセスの際の動作を記述することで回避出来ました。
(回避できたというか、そもそもそうするべきものですね。。。)

grails-app/conf/Config.groovy
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
    '/':                              ['permitAll'],
    '/index':                         ['permitAll'],
    '/index.gsp':                     ['permitAll'],
    '/**/js/**':                      ['permitAll'],
    '/**/css/**':                     ['permitAll'],
    '/**/images/**':                  ['permitAll'],
    '/**/favicon.ico':                ['permitAll'],
    '/**/dbconsole/**':                ['isAuthenticated()']    // これを追加
]

SpringSecurityCoreを導入すると、アクセスされた際の挙動を指定していないと問答無用でAccess Deniedとなります。
上記のように isAuthenticated() で、ログインしている必要があるよ、という指定をしてあげればOK。
公式ドキュメントはこのあたり

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6