What is httpBasic method in spring security?

这一生的挚爱 提交于 2021-01-28 02:22:43

问题


I override configure(HttpSecurity http) method in SampleSecurityConfig Class like this

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
        .authorizeRequests()
        .antMatchers("/delete/**").hasRole("ADMIN")
        .anyRequest().authenticated()
        .and()
        .formLogin().and().httpBasic();
}

If i don't use httpBasic method, it seems no problem occurred.

what does httpBasic method exactly do?


回答1:


Calling this method on HttpSecurity will enable Http Basic Authentication for your application with some "reasonable" defaults.

It will return a HttpBasicConfigurer for further customization.

You can test this by curl and passing a header like Authorization: Basic bzFbdGfmZrptWY30YQ== but base64 encoding a valid username/password combination.

Documentation for httpBasic



来源:https://stackoverflow.com/questions/57574981/what-is-httpbasic-method-in-spring-security

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!