diff options
author | Dan Timoney <dtimoney@att.com> | 2021-04-20 11:59:06 -0400 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2021-04-20 11:59:06 -0400 |
commit | a90eecf70419ec4acba6f5a8425300eef7f45290 (patch) | |
tree | c9e2a68e7a84f45c0130737c0c6b8430fd2e755f /ms/sliboot/src/main | |
parent | 49dd1b8c88cba58ef87a048688a98508d60fcca8 (diff) |
Use CadiFilter instead of shiro
Microservices should use CadiFilter rather than shiro to integrate
with AAF
Change-Id: I95b9a844b7ac868f864134de7345013001357352
Issue-ID: SDNC-1523
Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'ms/sliboot/src/main')
-rw-r--r-- | ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java index 9805d004..0d7a547f 100644 --- a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java +++ b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java @@ -25,17 +25,16 @@ import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.ComponentScan;
+import org.springframework.core.annotation.Order;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
-import org.apache.shiro.realm.Realm;
-import org.apache.shiro.realm.text.PropertiesRealm;
-import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition;
-import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition;
import org.springframework.context.annotation.Bean;
-import org.onap.aaf.cadi.shiro.AAFRealm;
+
+import org.onap.aaf.cadi.filter.CadiFilter;
@SpringBootApplication(scanBasePackages={ "org.onap.ccsdk.apps.ms.sliboot.*", "org.onap.ccsdk.apps.services" })
@EnableJpaRepositories("org.onap.ccsdk.apps.ms.sliboot.*")
@@ -51,34 +50,21 @@ public class SlibootApp { }
@Bean
- public Realm realm() {
-
- // If cadi prop files is not defined use local properties realm
- // src/main/resources/shiro-users.properties
- if ("none".equals(System.getProperty("cadi_prop_files", "none"))) {
- log.info("cadi_prop_files undefined, AAF Realm will not be set");
- PropertiesRealm realm = new PropertiesRealm();
- return realm;
- } else {
- AAFRealm realm = new AAFRealm();
- return realm;
- }
+ @Order(1)
+ public FilterRegistrationBean<CadiFilter> cadiFilter() {
+ CadiFilter filter = new CadiFilter();
- }
+ FilterRegistrationBean<CadiFilter> registrationBean = new FilterRegistrationBean<>();
+ registrationBean.setFilter(filter);
+ if ("none".equals(System.getProperty("cadi_prop_files", "none"))) {
+ log.info("cadi_prop_files undefined, AAF CADI disabled");
+ registrationBean.addUrlPatterns("/xxxx/*");
+ } else {
+ registrationBean.addUrlPatterns("/*");
+ registrationBean.addInitParameter("cadi_prop_files", System.getProperty("cadi_prop_files"));
+ }
- @Bean
- public ShiroFilterChainDefinition shiroFilterChainDefinition() {
- DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
-
- // if cadi prop files is not set disable authentication
- if ("none".equals(System.getProperty("cadi_prop_files", "none"))) {
- chainDefinition.addPathDefinition("/**", "anon");
- } else {
- log.info("Loaded property cadi_prop_files, AAF REALM set");
- chainDefinition.addPathDefinition("/**", "authcBasic, rest[org.onap.sdnc.odl:odl-api]");
- }
-
- return chainDefinition;
- }
+ return registrationBean;
+ }
}
|