Get Spring Security intercept urls from database or properties

后端 未结 2 1500
傲寒
傲寒 2020-12-18 12:22

Hopefully this is super simple, exists, and I\'m overlooking something right under my nose. I know that I can restrict access via annotations:

@Secured({\"R         


        
相关标签:
2条回答
  • 2020-12-18 12:25

    do you want to use something like this in you spring xml?

    <!-- Settings -->
    <b:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <b:property name="locations">
            <b:value>/WEB-INF/config.properties</b:value>
        </b:property>
    </b:bean>
    

    and then als in your Spring XML:

    <http entry-point-ref="authenticationProcessingFilterEntryPoint">
            <intercept-url pattern='/custom/**' access="${roles.admin}"/>
    </http>
    
    0 讨论(0)
  • 2020-12-18 12:43

    It's been a while, but you can create a Voter object which helps decide whether to allow access to a URL. The Voter object can load data from the database, or a file, or just randomly return Allow, Deny, or Abstain.

    0 讨论(0)
提交回复
热议问题