/*
 * Copyright 2018-2019 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.b2international.snowowl.core.rest;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.firewall.HttpFirewall;
import org.springframework.security.web.firewall.StrictHttpFirewall;

/**
 * @since 7.0
 */
@Configuration
@EnableWebSecurity
public class SnowOwlSecurityConfig extends WebSecurityConfigurerAdapter {

	@Bean
	public HttpFirewall allowUrlEncodedSlashHttpFirewall() {
	    StrictHttpFirewall firewall = new StrictHttpFirewall();
	    firewall.setAllowUrlEncodedSlash(true);
	    return firewall;
	}
	
	@Override
	protected void configure(final HttpSecurity http) throws Exception {
		http
			.sessionManagement()
				.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
			.and()
			.csrf().disable();
		
		// authentication is handled internally in AuthorizedRequest
		http.authorizeRequests()
			.antMatchers("/**")
			.permitAll();
	}
	
	@Override
	public void configure(WebSecurity web) throws Exception {
		web.httpFirewall(allowUrlEncodedSlashHttpFirewall());
	}
	
}

@@ -1207,16 +1207,102 @@
 Policy;%0A
+import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;%0A
 import o
@@ -1426,16 +1426,137 @@
 ewall;%0A%0A
+import com.b2international.commons.platform.PlatformUtil;%0Aimport com.b2international.snowowl.core.rest.util.CORSFilter;%0A%0A
 /**%0A * @
@@ -2083,16 +2083,165 @@
 e();%0A%09%09%0A
+%09%09// add dev time CORS filter%0A%09%09if (PlatformUtil.isDevVersion()) %7B%0A%09%09%09http.addFilterAfter(new CORSFilter(), BasicAuthenticationFilter.class);%0A%09%09%7D%0A%09%09%0A
 %09%09// aut

add dev time CORS filter