В Spring безопасности мы используем тег intercept-url для определения доступа для URL-адресов, как показано ниже:
<intercept-url pattern="/**" access="ROLE_ADMIN" />
<intercept-url pattern="/student" access="ROLE_STUDENT" />
Это жестко закодировано в applicationContext-security.xml
. Вместо этого я хочу прочитать значения доступа из таблицы базы данных. Я определил свой собственный UserDetailsService
, и я прочитал роли для зарегистрированного пользователя из базы данных. Как назначить эти роли шаблонам URL во время выполнения?