我們正在使用activiti v5.18和spring boot。爲了調用activiti REST API,我們必須創建一個activiti用戶來傳遞基本認證。據我所知,activiti安全是基於spring啓動安全性,我們嘗試了兩種方法。如何禁用activiti REST HTTP
排除Activiti的春天啓動安全自動配置
@EnableAutoConfiguration(exclude = {org.activiti.spring.boot.SecurityAutoConfiguration.class})
創建一個類來擴展Spring類的WebSecurityConfigurerAdapter),並設置 'security.basic.enabled =假' 在application.properties
@Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) @Order(SecurityProperties.ACCESS_OVERRIDE_ORDER) public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { // @formatter:off http .authorizeRequests() .antMatchers(HttpMethod.GET, "/","/static/**", "/resources/**","/resources/public/**").permitAll() .anyRequest().authenticated() .and() .formLogin() .and() .httpBasic().disable() .requiresChannel().anyRequest().requiresSecure(); // @formatter:on } }
不幸的是,他們沒有禁用基本身份驗證,當我去頁面'http://localhost:8080/repository/deployments',瀏覽器彈出用戶登錄窗口。並在頁面上顯示錯誤消息
此應用程序沒有顯式映射/錯誤,因此您將此視爲後備。
有一個意外的錯誤(type = Unauthorized,status = 401)。 訪問此資源需要完全身份驗證
另外,我們有自己的REST服務,當客戶端調用我們的REST服務時,瀏覽器還要求輸入activiti REST用戶/密碼。
有什麼辦法可以禁用activiti REST HTTP基本認證嗎?
嗨,我想使用奶蛋烘餅和自定義身份驗證impl,而不是activiti中的基本身份驗證,所以我需要做你寫的東西,然後我在哪裏做我自己的身份驗證,並回答一個真實的驗證功能?我應該在哪裏放置斷點? – ilansch
對於自定義認證,實現自定義認證過濾器public class CustomAuthenticationFilter extends AbstractAuthenticationProcessingFilter。在此過濾器中,您可以進行身份驗證。在的Spring Java配置,聲明你的過濾器作爲一個bean: \ @Bean \t公共CustomAuthenticationFilter customTokenAuthenticationFilter(){ \t \t回報新CustomAuthenticationFilter( 「/ **」);}; \ @Autowired CustomAuthenticationFilter customTokenAuthenticationFilter; 並使用.addFilterBefore(customTokenAuthenticationFilter,BasicAuthenticationFilter.class).httpBasic(); 將您的過濾器添加到鏈中。 – Ben
嗨,spring conf文件在哪裏?當主持activiti休息? – ilansch