Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8309839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:14:48+00:00 2026-06-08T19:14:48+00:00

I created this simple AdminController: @Controller @RequestMapping(admin) public class AdminController { @PreAuthorize(hasAuthority(‘ROLE_ADMIN’)) @RequestMapping(value =

  • 0

I created this simple AdminController:

@Controller
@RequestMapping("admin")
public class AdminController {
    @PreAuthorize("hasAuthority('ROLE_ADMIN')")
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public @ResponseBody String welcomeAdmin() {
        return "Spring Security - ROLE_ADMIN";
    }   
    @PreAuthorize("hasAuthority('ROLE_ADMIN')")
    @RequestMapping(value = "/{query}", method = RequestMethod.GET)
    public @ResponseBody String welcomeAdmin(@PathVariable String query) {
        return query;
    }
}

This is the security-context.xml:

<http auto-config="true">
    <intercept-url pattern="/admin*" access="ROLE_ADMIN"/>
    <logout logout-success-url="/admin" />
</http>

<authentication-manager>
    <authentication-provider>
        <user-service>
            <user name="user" password="password" authorities="ROLE_USER" />
            <user name="admin" password="password" authorities="ROLE_ADMIN" />
        </user-service>
    </authentication-provider>
</authentication-manager>

Which is loaded here in the web.xml:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/spring/root-context.xml
        /WEB-INF/spring/appServlet/security-context.xml
    </param-value>
</context-param>
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
  <filter-name>springSecurityFilterChain</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

There are no errors, but the /admin resource is accessible to anyone, why is it that the resource is not being filtered by the Spring security?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:14:50+00:00Added an answer on June 8, 2026 at 7:14 pm

    what version of spring security are you using?

    in your security-context.xml you need

    <global-method-security pre-post-annotations="enabled" >
    </global-method-security>
    

    in order to use annotations.

    also you should try:

    <intercept-url pattern="/admin*" access="hasRole('ROLE_ADMIN')"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created this simple program in Eclipse: import java.util.*; import java.io.*; public class prob1
I have this simple model: class Tag(models.Model): title = models.SlugField() created = models.datetime def
I have this simple class: public class MappingCollection<T> : List<T> { private int _declaredTotal
I am using this simple code public class Main extends Activity { private ProgressDialog
I created a COM-interop .dll with this simple class: using System.Runtime.InteropServices; namespace ClassLibrary1 {
I created this class library(ReportLib) with a simple Telerik report using Telerik Reporting Wizard.
I created this simple example because I was using a more complex class, a
I have created this simple program to learn shared_ptr using namespace std; #define Yes
I've created this simple GUI: from tkinter import * root = Tk() def grabText(event):
I've created this simple example program, but this doesn't work. it won't connect. any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.