Spring basic authentication not working

Entropy

Trying to set up basic authentication in a web-app using spring. I am patterning what I do off this example: http://howtodoinjava.com/2013/04/16/custom-userdetailsservice-example-for-spring-3-security/. I am using Spring 4.

The behavior is that my HttpRequestHandler runs, never challenging for password. LoginDao never runs.

spring config:

<security:http auto-config="true"  use-expressions="true">
    <security:intercept-url pattern="/*" access="hasRole('ROLE_USER')" />
    <security:http-basic />
</security:http>

<security:authentication-manager>
    <security:authentication-provider user-service-ref="loginDao" />
</security:authentication-manager>

<bean id="loginDao" class="weight.dao.LoginDao" />

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="/WEB-INF/wt.properties" />
</bean>
Stefan

What's missing in this tutorial are the entries you have to add to your web.xml. These will load you security context and add the security filter chain to your whole app (which is the main strut of Spring Security):

 <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        classpath:/your-security-context-file.xml
        classpath:/your-other-context-files.xml
        ...
    </param-value>
</context-param>

<filter>
    <display-name>Spring Security Filter</display-name>
    <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>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SwitchUserFilter not working in Spring security when used with Basic Authentication

From Dev

swagger : basic authentication not working

From Dev

Basic authentication not working with Requests library

From Dev

Basic Authentication not working on WebSphere 7

From Dev

Authentication is not working in spring

From Dev

Spring 4.0.0 basic authentication with RestTemplate

From Dev

Spring Security Rest Basic authentication

From Dev

Spring MVC REST + Spring Security + Basic Authentication

From Dev

Spring in-memory-authentication not working

From Dev

spring security custom authentication not working

From Dev

Basic node.js express authentication not working

From Dev

Spring Security with Spring Boot: Mix Basic Authentication with JWT token authentication

From Dev

Spring Cloud Zuul gateway 401 basic authentication

From Dev

Spring security: authentication with http basic and form login

From Java

Basic authentication for REST API using spring restTemplate

From Dev

Secure Spring Boot REST app with basic authentication

From Dev

Basic and form based authentication with Spring security Javaconfig

From Dev

Spring Security Basic Authentication only happens once

From Dev

Spring Security Basic Authentication always causes 404

From Dev

Spring-Security Basic HTML authentication

From Dev

Passing BASIC authentication data into a spring ws client

From Dev

Spring Boot with Jersey basic authentication always 404

From Dev

How to use RESTful with Basic Authentication in Spring Boot

From Dev

Basic Authentication not enabling on Spring Boot Application

From Dev

why Spring basic @Autowired is not working?

From Dev

How can I implement Basic Authentication with JWT authentication in Spring Boot?

From Dev

Spring Web Security logout not working with httpBasic authentication

From Dev

Spring security custom authentication provider not working

From Dev

koa, passport-http strategy: basic authentication not working

Related Related

  1. 1

    SwitchUserFilter not working in Spring security when used with Basic Authentication

  2. 2

    swagger : basic authentication not working

  3. 3

    Basic authentication not working with Requests library

  4. 4

    Basic Authentication not working on WebSphere 7

  5. 5

    Authentication is not working in spring

  6. 6

    Spring 4.0.0 basic authentication with RestTemplate

  7. 7

    Spring Security Rest Basic authentication

  8. 8

    Spring MVC REST + Spring Security + Basic Authentication

  9. 9

    Spring in-memory-authentication not working

  10. 10

    spring security custom authentication not working

  11. 11

    Basic node.js express authentication not working

  12. 12

    Spring Security with Spring Boot: Mix Basic Authentication with JWT token authentication

  13. 13

    Spring Cloud Zuul gateway 401 basic authentication

  14. 14

    Spring security: authentication with http basic and form login

  15. 15

    Basic authentication for REST API using spring restTemplate

  16. 16

    Secure Spring Boot REST app with basic authentication

  17. 17

    Basic and form based authentication with Spring security Javaconfig

  18. 18

    Spring Security Basic Authentication only happens once

  19. 19

    Spring Security Basic Authentication always causes 404

  20. 20

    Spring-Security Basic HTML authentication

  21. 21

    Passing BASIC authentication data into a spring ws client

  22. 22

    Spring Boot with Jersey basic authentication always 404

  23. 23

    How to use RESTful with Basic Authentication in Spring Boot

  24. 24

    Basic Authentication not enabling on Spring Boot Application

  25. 25

    why Spring basic @Autowired is not working?

  26. 26

    How can I implement Basic Authentication with JWT authentication in Spring Boot?

  27. 27

    Spring Web Security logout not working with httpBasic authentication

  28. 28

    Spring security custom authentication provider not working

  29. 29

    koa, passport-http strategy: basic authentication not working

HotTag

Archive