Skip to content
Snippets Groups Projects
Commit d2667302 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Added CORS configuration to speedup development + minor changes

parent d4cb9838
No related branches found
No related tags found
No related merge requests found
...@@ -55,3 +55,5 @@ nbactions.xml ...@@ -55,3 +55,5 @@ nbactions.xml
.vscode/ .vscode/
/gms-ui/target/ /gms-ui/target/
/gms/nbactions-release-profile.xml
...@@ -4,12 +4,12 @@ export default { ...@@ -4,12 +4,12 @@ export default {
fetchMainModel () { fetchMainModel () {
return fetch(BASE_API_URL + 'groups?groupId=ROOT&tab=groups&paginatorPageSize=20&paginatorPage=1', { return fetch(BASE_API_URL + 'groups?groupId=ROOT&tab=groups&paginatorPageSize=20&paginatorPage=1', {
method: 'GET', method: 'GET',
mode: 'cors',
cache: 'no-cache', cache: 'no-cache',
credentials: 'include', credentials: 'include',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json',
'Accept': 'application/json',
} }
}); }).then(response => response.json());
} }
}; };
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</b-col> </b-col>
</b-row> </b-row>
<div id="groups-list"> <div id="groups-list">
<b-list-group v-for="group in model.groupsPanel.groups"> <b-list-group v-for="group in model.groupsPanel.items">
<b-list-group-item href="#"> <b-list-group-item href="#">
<span class="float-left">{{group.name}}</span> <span class="float-left">{{group.name}}</span>
<span v-if="group.permission === 'ADMIN'" class="float-right"> <span v-if="group.permission === 'ADMIN'" class="float-right">
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
<div class="row"> <div class="row">
<div class="col-md-9"> <div class="col-md-9">
<b-pagination <b-pagination
v-model="model.groupsPanel.paginator.page" v-model="model.groupsPanel.currentPage"
:total-rows="model.groupsPanel.paginator.totalItems" :total-rows="model.groupsPanel.totalItems"
:per-page="model.groupsPanel.paginator.pageSize" :per-page="model.groupsPanel.pageSize"
aria-controls="groups-list" aria-controls="groups-list"
align="center" align="center"
v-on:change="setPage" v-on:change="setPage"
...@@ -57,7 +57,7 @@ export default { ...@@ -57,7 +57,7 @@ export default {
}, },
data: function() { data: function() {
return { return {
selectedPageSize: this.model.groupsPanel.paginator.pageSize, selectedPageSize: this.model.groupsPanel.pageSize,
pageSizeOptions: [ pageSizeOptions: [
{ value: 20, text: "20" }, { value: 20, text: "20" },
{ value: 50, text: "50" }, { value: 50, text: "50" },
......
<template> <template>
<b-tab title="Members"> <b-tab title="Members" v-if="model.membersPanel !== null">
<b-list-group v-for="member in model.membersPanel.members" id="members-list"> <b-list-group v-for="member in model.membersPanel.members" id="members-list">
<b-list-group-item href="#"> <b-list-group-item href="#">
{{member.label}} {{member.label}}
......
package it.inaf.ia2.gms.authn; package it.inaf.ia2.gms.authn;
import java.util.Arrays;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso; import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.Ordered;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
@Configuration @Configuration
@EnableOAuth2Sso @EnableOAuth2Sso
public class SecurityConfig extends WebSecurityConfigurerAdapter { public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private Environment env;
@Value("${cors.allowed.origin}")
private String corsAllowedOrigin;
@Override @Override
public void configure(HttpSecurity http) throws Exception { public void configure(HttpSecurity http) throws Exception {
super.configure(http); super.configure(http);
if (Arrays.asList(env.getActiveProfiles()).contains("dev")) {
http.authorizeRequests()
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll();
}
http.csrf().disable(); http.csrf().disable();
} }
@Bean
@Profile("dev")
public FilterRegistrationBean corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration().applyPermitDefaultValues();
config.setAllowedOrigins(Arrays.asList(corsAllowedOrigin));
config.setAllowCredentials(true);
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
return bean;
}
} }
package it.inaf.ia2.gms.model; package it.inaf.ia2.gms.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
...@@ -17,6 +18,7 @@ public class GroupNode { ...@@ -17,6 +18,7 @@ public class GroupNode {
permissions = new HashSet<>(); permissions = new HashSet<>();
} }
@JsonProperty("id")
public String getGroupId() { public String getGroupId() {
return groupId; return groupId;
} }
...@@ -25,6 +27,7 @@ public class GroupNode { ...@@ -25,6 +27,7 @@ public class GroupNode {
this.groupId = groupId; this.groupId = groupId;
} }
@JsonProperty("name")
public String getGroupName() { public String getGroupName() {
return groupName; return groupName;
} }
......
...@@ -17,4 +17,8 @@ spring.datasource.username=gms ...@@ -17,4 +17,8 @@ spring.datasource.username=gms
spring.datasource.password=gms spring.datasource.password=gms
#spring.jpa.open-in-view=false #spring.jpa.open-in-view=false
rap.ws-url=http://localhost/rap-ia2/ws rap.ws-url=http://localhost/rap-ia2/ws
\ No newline at end of file
# For development only:
spring.profiles.active=dev
cors.allowed.origin=http://localhost:8080
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment