how to configure my application with spring security? -
i new spring security tried read , there alot of information , don't know if in right direction. have html file html element create js lets assume have 2 input fields id ( html input fields )
emailinput , passwordinput
and button id ( html button )
loginlabel
i added configuration pring-security-config
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> </beans>
i added web.xml
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>
i created servlet filer
import org.springframework.beans.factory.annotation.autowired; import org.springframework.context.annotation.*; import org.springframework.security.config.annotation.authentication.builders.*; import org.springframework.security.config.annotation.web.configuration.*; @configuration @enablewebsecurity public class securityconfig extends websecurityconfigureradapter { @autowired public void configureglobal(authenticationmanagerbuilder auth) throws exception { auth .inmemoryauthentication() .withuser("user").password("password").roles("user"); }
}
how connect between fields in input ( element not tag ) securityconfig ?
do need create element or can without ?
do need create jsp file or ok use html files ?
- step 1: enable http security.
- step 2: turn on form login.
- step 3: set names of username , password parameters expected in login request.
sample below:
@configuration @enablewebsecurity public class securityconfig extends websecurityconfigureradapter { protected void configure(httpsecurity http) throws exception { http .formlogin() .usernameparameter("emailinput") .passwordparameter("passwordinput"); } }
Comments
Post a Comment