私の最初のSpring Webアプリケーションで認証関連の問題をすべて解決した後、私は承認に行き詰まっています。
注釈を使用した構成@Secured
は非常に簡単なので、ここで間違いを犯したとは思いません。さらに、LDAP 認証プロバイダーを使用して Active Directory を使用しており、AD グループごとに役割を割り当てているため、これも問題ではありません。
だからここに私の問題の簡単な要約があります:
- セキュリティで保護されていないアクションが機能する
- 仕事を使ったアクション
@Secured("IS_AUTHENTICATED_FULLY")
- のようなものを使用したアクション
@Secured("GROUP_*")
は機能しません
保護されたアクションを呼び出すと、 aorg.springframework.security.AccessDeniedException
がスローされます。ログからの抜粋は次のとおりです。
DEBUG: org.springframework.security.intercept.AbstractSecurityInterceptor - Secure object: ReflectiveMethodInvocation: public org.springframework.web.servlet.ModelAndView de.dillinger.resources.controllers.HostsController.index(); target is of class [de.dillinger.resources.controllers.HostsController]; ConfigAttributes: [GROUP_IT]
DEBUG: org.springframework.security.intercept.AbstractSecurityInterceptor - Previously Authenticated: org.springframework.security.providers.UsernamePasswordAuthenticationToken@2a5333d9: Principal: org.springframework.security.userdetails.ldap.Person@1422384: Username: di32001; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: GROUP_ITS, GROUP_ITS-IT, GROUP_INTERNET, GROUP_SYSTEMGRUPPE, GROUP_IT; Password: [PROTECTED]; Authenticated: true; Details: org.springframework.security.ui.WebAuthenticationDetails@0: RemoteIpAddress: 127.0.0.1; SessionId: 773943FFB14E512872BB6CE25F46C00A; Granted Authorities: GROUP_ITS, GROUP_ITS-IT, GROUP_INTERNET, GROUP_SYSTEMGRUPPE, GROUP_IT
ご覧のとおり、アクションにはGROUP_IT
ロールが必要であり、私のユーザー オブジェクトにはこの権限があります。この問題の原因は本当にわかりません。