pax_global_header 0000666 0000000 0000000 00000000064 13645630721 0014521 g ustar 00root root 0000000 0000000 52 comment=a989ae7c3754af823b34dfc4a28e30e9c1060fb1
ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/ 0000775 0000000 0000000 00000000000 13645630721 0020041 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/.gitignore 0000664 0000000 0000000 00000001326 13645630721 0022033 0 ustar 00root root 0000000 0000000 .DS_Store
node_modules
gms-ui/dist
gms-ui/node/
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
HELP.md
gms/target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
nbactions.xml
### VS Code ###
.vscode/
/gms-ui/target/
/gms/nbactions-release-profile.xml
/gms-client/gms-client-lib/target/
/gms-client/gms-cli/target/
/gms/node/
nb-configuration.xml
ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/README.md 0000664 0000000 0000000 00000004004 13645630721 0021316 0 ustar 00root root 0000000 0000000 # IA2 GMS
## Database Docker image
To build the image run **from current directory**:
docker build -f database/Dockerfile --tag gms-db .
To start the image and use the database:
docker run -d -p 5432:5432 -i -t gms-db:latest
## GMS Docker image
To build the image:
mvn clean package dockerfile:build -DskipTests
To run:
docker run --env-file docker-env -d -p 8081:8081 -i -t gms:latest
## Create the first super-admin
The first super admin user must be added manually, then he/she will be able to add other administrators from the UI:
INSERT INTO gms_permission (group_id, user_id, permission, group_path) VALUES('ROOT', '1', 'ADMIN', '');
The value `user_id` is the RAP user id.
## Command line clients
To add a command line client first generate the sha256 of its password:
echo -n password | sha256sum
Then insert the client line into the database:
INSERT INTO gms_client (client_id, client_secret, allowed_actions, ip_filter)
VALUES ('test', '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', '{"*"}', NULL);
## Developer notes
Backend and frontend are 2 separate applications:
* the backend is the Maven application in the gms folder, based on Java and Spring Boot;
* the frontend is the npm application is the gms-ui folder, based on Vue.js.
The Maven application automatically packs the Vue.js products inside the final jar, however the frontend application can be tested isolatedly running `npm run serve` in order to take advantage of the npm autoreload functionalities.
By default http calls are mocked inside the Vue.js application.
In order to rely on real server calls edit the .env.development file in this way:
VUE_APP_API_CLIENT = 'server'
VUE_APP_API_BASE_URL = 'http://localhost:8081/gms/'
This assumes that your backend runs on 8081 port (with dev profile active, in order to enable the CORS policy) and the frontend runs on 8080 port.
First, do the login using the application running on the 8081 port, then you can access the frontend on the 8080.
ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/database/ 0000775 0000000 0000000 00000000000 13645630721 0021605 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/database/Dockerfile 0000664 0000000 0000000 00000000267 13645630721 0023604 0 ustar 00root root 0000000 0000000 FROM library/postgres:11
COPY gms/src/main/resources/sql/init.sql /docker-entrypoint-initdb.d/
COPY database/user.sql /docker-entrypoint-initdb.d/
ENV POSTGRES_HOST_AUTH_METHOD=trust
ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/database/user.sql 0000664 0000000 0000000 00000000312 13645630721 0023300 0 ustar 00root root 0000000 0000000 CREATE ROLE gms WITH LOGIN PASSWORD 'gms';
GRANT USAGE ON SCHEMA public TO gms;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO gms;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO gms; ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/docker-env 0000664 0000000 0000000 00000000766 13645630721 0022032 0 ustar 00root root 0000000 0000000 SPRING_DATASOURCE_URL=jdbc:postgresql://140.105.79.115:5432/postgres
SECURITY_OAUTH2_CLIENT_ACCESS-TOKEN-URI=http://140.105.79.115/rap-ia2/auth/oauth2/token
SECURITY_OAUTH2_CLIENT_USER-AUTHORIZATION-URI=http://localhost/rap-ia2/auth/oauth2/authorize
SECURITY_OAUTH2_RESOURCE_TOKEN-INFO-URI=http://140.105.79.115/rap-ia2/auth/oauth2/check_token
SECURITY_OAUTH2_RESOURCE_JWK_KEY-SET-URI=http://140.105.79.115/rap-ia2/auth/oidc/jwks
RAP_WS-URL=http://140.105.79.115/rap-ia2/ws
SPRING_PROFILES_ACTIVE=prod
ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/ 0000775 0000000 0000000 00000000000 13645630721 0022103 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/ 0000775 0000000 0000000 00000000000 13645630721 0023436 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/.gitignore 0000664 0000000 0000000 00000000515 13645630721 0025427 0 ustar 00root root 0000000 0000000 HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/
ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/gms.properties 0000664 0000000 0000000 00000000232 13645630721 0026337 0 ustar 00root root 0000000 0000000 #base_url=http://localhost:8081/gms
#client_id=test
#client_secret=test
base_url=https://sso.ia2.inaf.it/gms
client_id=sso-admin
client_secret=cXjbauYe8g
ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/pom.xml 0000664 0000000 0000000 00000003131 13645630721 0024751 0 ustar 00root root 0000000 0000000
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.1.7.RELEASE
it.inaf.ia2
gms-cli
0.0.1-SNAPSHOT
gms-cli
GMS Command Line Client
1.8
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-test
test
${project.groupId}
gms-client-lib
1.0-SNAPSHOT
org.springframework.boot
spring-boot-maven-plugin
ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/ 0000775 0000000 0000000 00000000000 13645630721 0024225 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/main/ 0000775 0000000 0000000 00000000000 13645630721 0025151 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/main/java/ 0000775 0000000 0000000 00000000000 13645630721 0026072 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/main/java/it/ 0000775 0000000 0000000 00000000000 13645630721 0026506 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/main/java/it/inaf/ 0000775 0000000 0000000 00000000000 13645630721 0027423 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/main/java/it/inaf/ia2/ 0000775 0000000 0000000 00000000000 13645630721 0030076 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/main/java/it/inaf/ia2/gms/ 0000775 0000000 0000000 00000000000 13645630721 0030664 5 ustar 00root root 0000000 0000000 cli/ 0000775 0000000 0000000 00000000000 13645630721 0031354 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/main/java/it/inaf/ia2/gms CLI.java 0000664 0000000 0000000 00000010300 13645630721 0032620 0 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/main/java/it/inaf/ia2/gms/cli package it.inaf.ia2.gms.cli;
import it.inaf.ia2.gms.client.GmsClient;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class CLI implements CommandLineRunner {
private final GmsClient client;
public CLI() throws IOException {
File config = new File("gms.properties");
if (!config.exists()) {
System.err.println("Unable to find the file gms.properties");
System.exit(1);
}
Properties properties = new Properties();
try (InputStream in = new FileInputStream(config)) {
properties.load(in);
}
String baseUrl = (String) properties.get("base_url");
if (baseUrl == null) {
System.err.println("Missing base_url in gms.properties");
System.exit(1);
}
String clientId = (String) properties.get("client_id");
if (clientId == null) {
System.err.println("Missing client_id in gms.properties");
System.exit(1);
}
String clientSecret = (String) properties.get("client_secret");
if (clientSecret == null) {
System.err.println("Missing client_secret in gms.properties");
System.exit(1);
}
client = new GmsClient(baseUrl, clientId, clientSecret);
}
@Override
public void run(String... args) throws Exception {
if (args.length < 2) {
displayUsage();
}
switch (args[0]) {
case "create-group":
client.addGroup(getNames(args, 1));
System.out.println("Group created");
break;
case "delete-group":
client.removeGroup(getNames(args, 1));
System.out.println("Group deleted");
break;
case "add-member":
if (args.length < 3) {
displayUsage();
}
client.addMember(getNames(args, 1, args.length - 2), args[args.length - 1]);
System.out.println("Member added");
break;
case "remove-member":
if (args.length < 3) {
displayUsage();
}
client.removeMember(getNames(args, 1, args.length - 2), args[args.length - 1]);
System.out.println("Member removed");
break;
case "add-permission":
if (args.length < 4) {
displayUsage();
}
client.addPermission(getNames(args, 1, args.length - 3), args[args.length - 2], args[args.length - 1]);
System.out.println("Permission added");
break;
case "delete-permission":
if (args.length < 4) {
displayUsage();
}
client.removePermission(getNames(args, 1, args.length - 2), args[args.length - 1]);
System.out.println("Permission removed");
break;
default:
displayUsage();
break;
}
}
private void displayUsage() {
System.out.println("java -jar gms-client.jar\n"
+ " create-group \n"
+ " delete-group \n"
+ " add-member \n"
+ " remove-member \n"
+ " add-permission \n"
+ " delete-permission ");
System.exit(0);
}
private List getNames(String[] args, int startIndex) {
return getNames(args, startIndex, args.length - 1);
}
private List getNames(String[] args, int startIndex, int endIndex) {
List names = new ArrayList<>();
for (int i = startIndex; i <= endIndex; i++) {
names.add(args[i]);
}
return names;
}
}
GmsCliApplication.java 0000664 0000000 0000000 00000000470 13645630721 0035562 0 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/main/java/it/inaf/ia2/gms/cli package it.inaf.ia2.gms.cli;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class GmsCliApplication {
public static void main(String[] args) {
SpringApplication.run(GmsCliApplication.class, args);
}
}
ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/main/resources/ 0000775 0000000 0000000 00000000000 13645630721 0027163 5 ustar 00root root 0000000 0000000 application.properties 0000664 0000000 0000000 00000000062 13645630721 0033523 0 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/main/resources spring.main.banner-mode=off
logging.level.root=OFF ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/test/ 0000775 0000000 0000000 00000000000 13645630721 0025204 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/test/java/ 0000775 0000000 0000000 00000000000 13645630721 0026125 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/test/java/it/ 0000775 0000000 0000000 00000000000 13645630721 0026541 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/test/java/it/inaf/ 0000775 0000000 0000000 00000000000 13645630721 0027456 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/test/java/it/inaf/ia2/ 0000775 0000000 0000000 00000000000 13645630721 0030131 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/test/java/it/inaf/ia2/gms/ 0000775 0000000 0000000 00000000000 13645630721 0030717 5 ustar 00root root 0000000 0000000 cli/ 0000775 0000000 0000000 00000000000 13645630721 0031407 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/test/java/it/inaf/ia2/gms GmsCliApplicationTests.java 0000664 0000000 0000000 00000000520 13645630721 0036634 0 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-cli/src/test/java/it/inaf/ia2/gms/cli package it.inaf.ia2.gms.cli;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class GmsCliApplicationTests {
@Test
public void contextLoads() {
}
}
ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-client-lib/ 0000775 0000000 0000000 00000000000 13645630721 0024711 5 ustar 00root root 0000000 0000000 ia2-gms-a989ae7c3754af823b34dfc4a28e30e9c1060fb1/gms-client/gms-client-lib/pom.xml 0000664 0000000 0000000 00000002115 13645630721 0026225 0 ustar 00root root 0000000 0000000
4.0.0
it.inaf.ia2
gms-client-lib
1.0-SNAPSHOT
jar
UTF-8
12
12
junit
junit
4.12
test
org.mockito
mockito-core
2.23.4
test