Results 1 to 3 of 3

Thread: Spring Security: authentication User and Admin

  1. #1

    Default Spring Security: authentication User and Admin

    Hi everyone,
    I am currently working in a projekt that uses Spring, Hibernate und Spring WebFlow.
    The program must be able to identify / verify a user and admin.
    The program authenticates the user but not admin. And when I try to combine the two no longer works.

    The connection to the database is realized with Hibernate.

    Can someone help me?

    Thank you in advance.

  2. #2

    Default

    Quote Originally Posted by Lukem View Post
    Can someone help me?
    Not without a lot more information. We'll need relevant code and configuration snippets, as well as any relevant exceptions you're getting. Some more detail on the precise nature of the problem you're having is good too.

  3. #3

    Default

    Yes, you have reason...
    Here are the codes:

    In my mmv-security.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security"
    	xsi:schemaLocation="
    		http://www.springframework.org/schema/beans
    		http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    		http://www.springframework.org/schema/security
    		http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
    
    	<import resource="mmv-data.xml" />
    	
    	<!--
    		======================================================================
    		Spring Security
    		======================================================================
    	-->
    	
    	<security:http auto-config="true" access-denied-page="/loginRequired.htm">
    		<security:intercept-url pattern="/members/**"
    			access="ROLE_USER, ROLE_ADMIN" />
    		<security:intercept-url pattern="/admin/**"
    			access="ROLE_ADMIN" />
    		<security:intercept-url pattern="/**"
    			access="ROLE_USER,ROLE_ADMIN,ROLE_ANONYMOUS" />
    		<!-- <security:intercept-url pattern="/members/**"
    			access="ROLE_PREMIUM" /> --> 
    		<security:form-login login-page="/login.htm"
    			default-target-url="/members/myMMV.htm"
    			authentication-failure-url="/loginFailed.htm"
    			always-use-default-target="true" login-processing-url="/j_spring_security_check" />
    		<security:logout logout-url="/logout.htm"
    			logout-success-url="/logoutSuccess.htm" invalidate-session="true" />
    	</security:http>
    
    	<security:authentication-provider>
    		<!-- <security:password-encoder hash="md5" /> -->
    		<security:jdbc-user-service
    			data-source-ref="dataSource"
    			users-by-username-query="SELECT username,password,enabled FROM Member WHERE username = ?"
    			authorities-by-username-query="SELECT username,authority FROM Authorities WHERE username = ?" />
    		<!-- <security:user-service>
    		<security:user name="admin" password="secret" authorities="ROLE_ADMIN" />
    		</security:user-service> -->
    	</security:authentication-provider>
    
    	<bean id="springSecurityFilterChain" class="org.springframework.security.util.FilterChainProxy">
    		<security:filter-chain-map path-type="ant">
    			<security:filter-chain 
    				pattern="/members/**"
    				filters="httpSessionContextIntegrationFilterWithASCFalse,
    				 _basicAuthenticationFilter,basicExceptionTranslationFilter,
    				 _filterSecurityInterceptor" />
    		</security:filter-chain-map>
    	</bean>
    
    </beans>
    The user authentication works very well. But when I add "
    <security:user-service>
    <security:user name="admin" password="secret" authorities="ROLE_ADMIN" />
    </security:user-service>",
    the user authentication does not work. Then I can only register as admin, the role and the name of the admin is not available in the database.

    How can I save the admin (name and role) in the database using Hibernate and authenticate a user and an admin?

    Thank you very much in advance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •