diff options
author | David Stilwell <stilwelld@att.com> | 2020-03-18 10:02:50 -0400 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2020-03-19 16:14:31 -0400 |
commit | 35d9348ab67b6dc3c8e90a2a479f75fcd0af9228 (patch) | |
tree | 537ade8be9a327c2b26a96a7ac79dd12a8bac9a9 /sliapi/springboot/src/main | |
parent | d8bda45b7e8feccaa521d0ae35b72ae3b87c5a89 (diff) |
Springboot integration with AAF
Changes made: pom.xml updates, App.java add Beans for realm and filterchain
Issue-ID: CCSDK-2178
Change-Id: I29aa242ceff6a2f840b93a8d18ca5385190ca6d2
Signed-off-by: David Stilwell <stilwelld@att.com>
Diffstat (limited to 'sliapi/springboot/src/main')
-rw-r--r-- | sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java | 37 | ||||
-rw-r--r-- | sliapi/springboot/src/main/resources/shiro-users.properties | 3 |
2 files changed, 40 insertions, 0 deletions
diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java index ed3ee0446..2892430b1 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java @@ -24,6 +24,13 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.PropertiesRealm;
+import org.apache.shiro.realm.text.TextConfigurationRealm;
+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;
@SpringBootApplication
@EnableSwagger2
@@ -34,4 +41,34 @@ public class App { public static void main(String[] args) throws Exception {
SpringApplication.run(App.class, args);
}
+
+ @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"))) {
+ PropertiesRealm realm = new PropertiesRealm();
+ return realm;
+ } else {
+ AAFRealm realm = new AAFRealm();
+ return realm;
+ }
+
+ }
+
+ @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 {
+ chainDefinition.addPathDefinition("/**", "authcBasic, rest[org.onap.sdnc:odl-api]");
+ }
+
+ return chainDefinition;
+ }
+
}
diff --git a/sliapi/springboot/src/main/resources/shiro-users.properties b/sliapi/springboot/src/main/resources/shiro-users.properties new file mode 100644 index 000000000..df4b1ae7a --- /dev/null +++ b/sliapi/springboot/src/main/resources/shiro-users.properties @@ -0,0 +1,3 @@ +user.admin = Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U,service +role.service = odl-api:* + |