Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
307a091178 | ||
2fcb9403bb | |||
bee72ee8a3 | |||
83e019c8fa | |||
396455d611 | |||
cbc0705a79 | |||
24c7f83629 | |||
0422f0dfe2 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -62,3 +62,6 @@ __pycache__
|
|||||||
back/env_dev/data/
|
back/env_dev/data/
|
||||||
*.sql
|
*.sql
|
||||||
public_key*
|
public_key*
|
||||||
|
back/env_dev/data
|
||||||
|
front/tsconfig.tsbuildinfo
|
||||||
|
back/pom.xml.versionsBackup
|
||||||
|
88
Dockerfile
88
Dockerfile
@ -3,22 +3,30 @@
|
|||||||
## buyilding-end install applications:
|
## buyilding-end install applications:
|
||||||
##
|
##
|
||||||
######################################################################################
|
######################################################################################
|
||||||
FROM archlinux:base-devel AS builder
|
FROM archlinux:base-devel AS common
|
||||||
# update system
|
# update system
|
||||||
RUN pacman -Syu --noconfirm && pacman-db-upgrade \
|
RUN pacman -Syu --noconfirm && pacman-db-upgrade \
|
||||||
&& pacman -S --noconfirm jdk-openjdk maven pnpm \
|
&& pacman -S --noconfirm jdk-openjdk wget\
|
||||||
&& pacman -Scc --noconfirm
|
&& pacman -Scc --noconfirm
|
||||||
|
|
||||||
ENV PATH /workspace/node_modules/.bin:$PATH
|
WORKDIR /tmp
|
||||||
WORKDIR /workspace
|
|
||||||
|
FROM common AS builder
|
||||||
|
# update system
|
||||||
|
RUN pacman -Syu --noconfirm && pacman-db-upgrade \
|
||||||
|
&& pacman -S --noconfirm maven npm pnpm \
|
||||||
|
&& pacman -Scc --noconfirm
|
||||||
|
|
||||||
|
ENV PATH /tmp/node_modules/.bin:$PATH
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
##
|
##
|
||||||
## Build back:
|
## Build back:
|
||||||
##
|
##
|
||||||
######################################################################################
|
######################################################################################
|
||||||
FROM builder AS buildBack
|
FROM builder AS build_back
|
||||||
COPY back/pom.xml back/Formatter.xml ./
|
COPY back/pom.xml ./
|
||||||
|
COPY back/Formatter.xml ./
|
||||||
COPY back/src ./src/
|
COPY back/src ./src/
|
||||||
RUN mvn clean compile assembly:single
|
RUN mvn clean compile assembly:single
|
||||||
|
|
||||||
@ -27,27 +35,43 @@ RUN mvn clean compile assembly:single
|
|||||||
## Build front:
|
## Build front:
|
||||||
##
|
##
|
||||||
######################################################################################
|
######################################################################################
|
||||||
FROM builder AS buildFront
|
FROM builder AS dependency_front
|
||||||
|
|
||||||
RUN echo "@kangaroo-and-rabbit:registry=https://gitea.atria-soft.org/api/packages/kangaroo-and-rabbit/npm/" > /root/.npmrc
|
RUN echo "@kangaroo-and-rabbit:registry=https://gitea.atria-soft.org/api/packages/kangaroo-and-rabbit/npm/" > /root/.npmrc
|
||||||
|
|
||||||
ADD front/package.json \
|
ADD front/package.json \
|
||||||
front/karma.conf.js \
|
front/pnpm-lock.yaml \
|
||||||
front/protractor.conf.js \
|
|
||||||
./
|
./
|
||||||
|
ADD front/src/theme ./src/theme
|
||||||
|
|
||||||
# install and cache app dependencies
|
# install and cache app dependencies
|
||||||
RUN pnpm install
|
RUN pnpm install --prod=false
|
||||||
|
|
||||||
ADD front/e2e \
|
###############################################################
|
||||||
front/tsconfig.json \
|
## Install sources
|
||||||
front/tslint.json \
|
###############################################################
|
||||||
front/angular.json \
|
FROM dependency_front AS load_sources_front
|
||||||
./
|
|
||||||
ADD front/src ./src
|
|
||||||
|
|
||||||
# generate build
|
# JUST to get the version of the application and his sha...
|
||||||
RUN ng build --output-path=dist --configuration=production --base-href=/karso/ --deploy-url=/karso/ karso
|
COPY \
|
||||||
|
front/tsconfig.json \
|
||||||
|
front/tsconfig.node.json \
|
||||||
|
front/vite.config.mts \
|
||||||
|
front/index.html \
|
||||||
|
./
|
||||||
|
COPY front/public ./public
|
||||||
|
COPY front/src ./src
|
||||||
|
|
||||||
|
#We are not in prod mode ==> we need to overwrite the production env.
|
||||||
|
ARG env=front/.env.production
|
||||||
|
COPY ${env} .env
|
||||||
|
|
||||||
|
###############################################################
|
||||||
|
## Build the sources
|
||||||
|
###############################################################
|
||||||
|
FROM load_sources_front AS build_front
|
||||||
|
# build in bundle mode all the application
|
||||||
|
RUN pnpm static:build
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
##
|
##
|
||||||
@ -55,21 +79,31 @@ RUN ng build --output-path=dist --configuration=production --base-href=/karso/ -
|
|||||||
##
|
##
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
FROM bellsoft/liberica-openjdk-alpine:latest
|
#FROM bellsoft/liberica-openjdk-alpine:latest
|
||||||
# add wget to manage the health check...
|
## add wget to manage the health check...
|
||||||
RUN apk add --no-cache wget
|
#RUN apk add --no-cache wget
|
||||||
|
FROM common
|
||||||
|
|
||||||
ENV LANG=C.UTF-8
|
#FROM archlinux:base
|
||||||
|
#RUN pacman -Syu --noconfirm && pacman-db-upgrade
|
||||||
|
## install package
|
||||||
|
#RUN pacman -S --noconfirm jdk-openjdk wget
|
||||||
|
## intall npm
|
||||||
|
#RUN pacman -S --noconfirm npm
|
||||||
|
## clean all the caches Need only on the release environment
|
||||||
|
#RUN pacman -Scc --noconfirm
|
||||||
|
|
||||||
COPY --from=buildBack /workspace/out/maven/*.jar /application/application.jar
|
ENV LANG C.UTF-8
|
||||||
COPY --from=buildFront /workspace/dist /application/front/
|
|
||||||
|
COPY --from=build_back /tmp/out/maven/*.jar /application/application.jar
|
||||||
|
COPY --from=build_front /tmp/dist /application/front/
|
||||||
|
|
||||||
WORKDIR /application/
|
WORKDIR /application/
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
# To verify health-check: docker inspect --format "{{json .State.Health }}" YOUR_SERVICE_NAME | jq
|
# To verify health-check: docker inspect --format "{{json .State.Health }}" YOUR_SERVICE_NAME | jq
|
||||||
HEALTHCHECK --start-period=30s --start-interval=5s --interval=30s --timeout=5s --retries=10 \
|
HEALTHCHECK --start-period=10s --start-interval=2s --interval=30s --timeout=5s --retries=10 \
|
||||||
CMD wget --no-verbose --tries=1 --spider http://localhost:80/karso/api/health_check || exit 1
|
CMD wget --no-verbose --tries=1 --spider http://localhost:80/api/health_check || exit 1
|
||||||
|
|
||||||
CMD ["java", "-Xms64M", "-Xmx1G", "-cp", "/application/application.jar", "org.kar.karso.WebLauncher"]
|
CMD ["java", "-Xms64M", "-Xmx1G", "-cp", "/application/application.jar", "org.atriasoft.karso.WebLauncher"]
|
||||||
|
183
README.md
183
README.md
@ -1,103 +1,128 @@
|
|||||||
Karauth
|
Karso
|
||||||
=======
|
=====
|
||||||
|
|
||||||
This repository manage 3 elements:
|
**K**angaroo **A**nd **R**abbit (S)SO is a simple SSO interface that manage multiple application authentication.
|
||||||
- The SSO backend: jersey REST server
|
|
||||||
- The SSO front-end: Angular login interface (KARSO)
|
|
||||||
- The adminitrator of the SSO: Angular adminitration interface of the SSO (KARSO)
|
|
||||||
|
|
||||||
To build the docker image:
|
|
||||||
--------------------------
|
Run in local:
|
||||||
|
=============
|
||||||
|
|
||||||
|
Start tools
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Start the server basic interfaces: (DB(mySQL), Adminer)
|
||||||
|
|
||||||
```{.bash}
|
```{.bash}
|
||||||
gitea.atria-soft.org/kangaroo-and-rabbit/karso:latest
|
# start the Bdd interface (no big data > 50Mo)
|
||||||
|
docker compose -f env_dev/docker-compose.yaml up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
MySql manage multiple users:
|
Start the Back-end:
|
||||||
----------------------------
|
-------------------
|
||||||
|
|
||||||
It is better to not use root user and mange user for each service.
|
backend is developed in JAVA
|
||||||
|
|
||||||
Add a new user
|
The first step is configuring your JAVA version (or select the JVM with the OS)
|
||||||
```sql
|
```bash
|
||||||
CREATE USER 'karso'@'%' IDENTIFIED BY 'base_db_password';
|
export PATH=$(ls -d --color=never /usr/lib/jvm/java-2*-openjdk)/bin:$PATH
|
||||||
GRANT ALL PRIVILEGES ON `karso`.* TO 'karso'@'%';
|
|
||||||
FLUSH PRIVILEGES;
|
|
||||||
```
|
```
|
||||||
> **_Note_** the `base_db_password` with the production password. this one is for development environment
|
|
||||||
|
|
||||||
|
Install the dependency:
|
||||||
|
```bash
|
||||||
|
mvn install
|
||||||
|
```
|
||||||
|
|
||||||
To start the service
|
Run the test
|
||||||
|
```bash
|
||||||
|
mvn test
|
||||||
|
```
|
||||||
|
|
||||||
|
Install it for external use
|
||||||
|
```bash
|
||||||
|
mvn install
|
||||||
|
```
|
||||||
|
|
||||||
|
Execute the local server:
|
||||||
|
```bash
|
||||||
|
mvn exec:java@dev-mode
|
||||||
|
```
|
||||||
|
|
||||||
|
Start the Front-end:
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
```{.bash}
|
backend is developed in JAVA
|
||||||
docker-compose up -d
|
```bash
|
||||||
|
cd front
|
||||||
|
pnpm install
|
||||||
|
pnpm dev
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** you can manage a single Docker interface to manage all the KAR engine
|
Display the result:
|
||||||
|
-------------------
|
||||||
|
|
||||||
docker login gitea.atria-soft.org
|
[show the webpage: http://localhost:4200](http://localhost:4200)
|
||||||
|
|
||||||
docker pull archlinux:base-devel
|
|
||||||
docker pull bellsoft/liberica-openjdk-alpine:latest
|
|
||||||
|
|
||||||
docker build -t gitea.atria-soft.org/kangaroo-and-rabbit/karso:latest .
|
|
||||||
|
|
||||||
docker push gitea.atria-soft.org/kangaroo-and-rabbit/karso:latest
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
npx playwright test
|
|
||||||
Runs the end-to-end tests.
|
|
||||||
|
|
||||||
npx playwright test --project=firefox
|
|
||||||
Runs the tests only on Desktop Chrome.
|
|
||||||
|
|
||||||
npx playwright test example
|
|
||||||
Runs the tests in a specific file.
|
|
||||||
|
|
||||||
npx playwright test --debug
|
|
||||||
Runs the tests in debug mode.
|
|
||||||
|
|
||||||
npx playwright codegen
|
|
||||||
Auto generate tests with Codegen.
|
|
||||||
|
|
||||||
We suggest that you begin by typing:
|
|
||||||
|
|
||||||
npx playwright test
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Action a faire d'urgence:
|
|
||||||
- Mettre un jenkins en place
|
|
||||||
- dev sur develop et non master
|
|
||||||
- concevoir un système de migration et d'initialisation.
|
|
||||||
- ajouter une interface a sqlWrapper pour supporter sqlite ==> plus facile pour les tests
|
|
||||||
- mettre des test unitaire sur les API REST:
|
|
||||||
- securité des interfaces
|
|
||||||
- viole des token
|
|
||||||
- Fin de validité d'un tocken
|
|
||||||
- Addaque d-DOS
|
|
||||||
- Publier toutes les semaine une version a jour
|
|
||||||
- faire de la documentation pour l'aide
|
|
||||||
- revoir l'interface des paramètre pour la ganérisé
|
|
||||||
- Mettre en place une meilleur page d'acceuil
|
|
||||||
- mettre en config le nom du site
|
|
||||||
- faire un tool qui permet de savoir si le serveur est UP et si ce n'est pas le cas, bloquer l'affichage
|
|
||||||
- mettre en place les coors pour les pages d'administration ==> ca vas ètre coton...
|
|
||||||
- améliorer la gestion et l'affichages des erreur
|
|
||||||
- mettre en place des pop-up de détection d'erreur
|
|
||||||
- mise en place d'envoie d'email pour faire une autentification plus sérieuse.
|
|
||||||
- mettre un place un back-end LDAP
|
|
||||||
|
|
||||||
|
|
||||||
|
Some other dev tools:
|
||||||
|
=====================
|
||||||
|
|
||||||
|
Format code:
|
||||||
|
------------
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export PATH=$(ls -d --color=never /usr/lib/jvm/java-2*-openjdk)/bin:$PATH
|
export PATH=$(ls -d --color=never /usr/lib/jvm/java-2*-openjdk)/bin:$PATH
|
||||||
mvn formatter:format
|
mvn formatter:format
|
||||||
mvn test
|
mvn test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Tools in production mode
|
||||||
|
========================
|
||||||
|
|
||||||
|
Changing the Log Level
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
In a production environment, you can adjust the log level to help diagnose bugs more effectively.
|
||||||
|
|
||||||
|
The available log levels are:
|
||||||
|
| **Log Level Tag** | **org.kar.karso** | **org.kar.archidata** | **other** |
|
||||||
|
| ----------------- | ------------------- | --------------------- | --------- |
|
||||||
|
| `prod` | INFO | INFO | INFO |
|
||||||
|
| `prod-debug` | DEBUG | INFO | INFO |
|
||||||
|
| `prod-trace` | TRACE | DEBUG | INFO |
|
||||||
|
| `prod-trace-full` | TRACE | TRACE | INFO |
|
||||||
|
| `dev` | TRACE | DEBUG | INFO |
|
||||||
|
|
||||||
|
|
||||||
|
Manual set in production:
|
||||||
|
=========================
|
||||||
|
|
||||||
|
Connect on the registry
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
To log-in and log-out from the registry:
|
||||||
|
```bash
|
||||||
|
export REGISTRY_ADDRESS=gitea.atria-soft.org
|
||||||
|
docker login -u <<YOUR_USER_NAME>> ${REGISTRY_ADDRESS}
|
||||||
|
docker logout ${REGISTRY_ADDRESS}
|
||||||
|
```
|
||||||
|
|
||||||
|
pull the root image of dockers
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull archlinux:base-devel
|
||||||
|
docker pull bellsoft/liberica-openjdk-alpine:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Create the version
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Execute in the local folder: (use ```dev``` for development and ```latest``` for production release)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export TAG_DOCKER=latest
|
||||||
|
export REGISTRY_ADDRESS=gitea.atria-soft.org
|
||||||
|
docker build -t ${REGISTRY_ADDRESS}/kangaroo-and-rabbit/karso:${TAG_DOCKER} .
|
||||||
|
docker push ${REGISTRY_ADDRESS}/kangaroo-and-rabbit/karso:${TAG_DOCKER}
|
||||||
|
```
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
<name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name>
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
@ -53,6 +53,9 @@ Checkstyle configuration that checks the sun coding conventions.
|
|||||||
<module name="LambdaParameterName"/>
|
<module name="LambdaParameterName"/>
|
||||||
<module name="Regexp"/>
|
<module name="Regexp"/>
|
||||||
<module name="RegexpSinglelineJava"/>
|
<module name="RegexpSinglelineJava"/>
|
||||||
|
<module name="UnusedPrivateField">
|
||||||
|
<property name="ignorePattern" value="LOGGER"/>
|
||||||
|
</module>
|
||||||
</module>
|
</module>
|
||||||
<module name="BeforeExecutionExclusionFileFilter">
|
<module name="BeforeExecutionExclusionFileFilter">
|
||||||
<property name="fileNamePattern" value="module\-info\.java$"/>
|
<property name="fileNamePattern" value="module\-info\.java$"/>
|
||||||
|
@ -11,7 +11,7 @@ mvn package
|
|||||||
// download all dependency in out/maven/dependency
|
// download all dependency in out/maven/dependency
|
||||||
mvn dependency:copy-dependencies
|
mvn dependency:copy-dependencies
|
||||||
|
|
||||||
java -cp out/maven/kar-karso-0.1.0.jar org.kar.karso.WebLauncher
|
java -cp out/maven/kar-karso-0.1.0.jar org.atriasoft.karso.WebLauncher
|
||||||
|
|
||||||
|
|
||||||
// create a single package jar
|
// create a single package jar
|
||||||
@ -19,7 +19,7 @@ mvn clean compile assembly:single
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
java -cp out/maven/karso-0.1.0-jar-with-dependencies.jar org.kar.karso.WebLauncher
|
java -cp out/maven/karso-0.1.0-jar-with-dependencies.jar org.atriasoft.karso.WebLauncher
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
91
back/pom.xml
91
back/pom.xml
@ -1,36 +1,42 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.kar</groupId>
|
<groupId>org.atriasoft</groupId>
|
||||||
<artifactId>karso</artifactId>
|
<artifactId>karso</artifactId>
|
||||||
<version>0.8.0</version>
|
<version>0.8.0-SNAPSHOT</version>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.version>3.1</maven.compiler.version>
|
<maven.compiler.version>3.1</maven.compiler.version>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
<maven.compiler.target>21</maven.compiler.target>
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
<maven.dependency.version>3.1.1</maven.dependency.version>
|
<maven.dependency.version>3.1.1</maven.dependency.version>
|
||||||
</properties>
|
</properties>
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>gitea</id>
|
|
||||||
<url>https://gitea.atria-soft.org/api/packages/kangaroo-and-rabbit/maven</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>kangaroo-and-rabbit</groupId>
|
<groupId>org.atria-soft</groupId>
|
||||||
<artifactId>archidata</artifactId>
|
<artifactId>archidata</artifactId>
|
||||||
<version>0.11.0</version>
|
<version>0.28.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Loopback of logger JDK logging API to SLF4J -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-simple</artifactId>
|
<artifactId>jul-to-slf4j</artifactId>
|
||||||
<version>2.1.0-alpha1</version>
|
<version>2.0.9</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- generic logger of SLF4J to console (in color) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<version>1.4.11</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>xerces</groupId>
|
||||||
|
<artifactId>xercesImpl</artifactId>
|
||||||
|
<version>2.12.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
<version>2.17.1</version>
|
<version>2.18.0-rc1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--
|
<!--
|
||||||
************************************************************
|
************************************************************
|
||||||
@ -40,15 +46,25 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
<version>5.11.0-M2</version>
|
<version>5.11.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
<version>5.11.0-M2</version>
|
<version>5.11.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.revelc.code.formatter</groupId>
|
||||||
|
<artifactId>formatter-maven-plugin</artifactId>
|
||||||
|
<version>2.24.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.5.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
@ -79,7 +95,7 @@
|
|||||||
<artifactId>exec-maven-plugin</artifactId>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
<version>1.4.0</version>
|
<version>1.4.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<mainClass>org.kar.karso.WebLauncher</mainClass>
|
<mainClass>org.atriasoft.karso.WebLauncher</mainClass>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Create the source bundle -->
|
<!-- Create the source bundle -->
|
||||||
@ -166,6 +182,23 @@
|
|||||||
<nohelp>true</nohelp>
|
<nohelp>true</nohelp>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>exec-application</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>java</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>org.atriasoft.karso.WebLauncher</mainClass>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<!-- Check the style of the code -->
|
<!-- Check the style of the code -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@ -207,20 +240,20 @@
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>com.github.spotbugs</groupId>
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
<artifactId>spotbugs-maven-plugin</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>4.8.5.0</version>
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>exec-application</id>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>java</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<mainClass>org.kar.karso.WebLauncher</mainClass>
|
<includeFilterFile>spotbugs-security-include.xml</includeFilterFile>
|
||||||
|
<excludeFilterFile>spotbugs-security-exclude.xml</excludeFilterFile>
|
||||||
|
<!--<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.h3xstream.findsecbugs</groupId>
|
||||||
|
<artifactId>findsecbugs-plugin</artifactId>
|
||||||
|
<version>1.12.0</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
-->
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
org.kar..karso.db.host=localhost
|
org.atriasoft..karso.db.host=localhost
|
||||||
org.kar..karso.db.port=15306
|
org.atriasoft..karso.db.port=15306
|
||||||
org.kar..karso.db.login=root
|
org.atriasoft..karso.db.login=root
|
||||||
org.kar..karso.db.password=klkhj456gkgtkhjgvkujfhjgkjhgsdfhb3467465fgdhdesfgh
|
org.atriasoft..karso.db.password=klkhj456gkgtkhjgvkujfhjgkjhgsdfhb3467465fgdhdesfgh
|
||||||
org.kar..karso.db.name=oauth
|
org.atriasoft..karso.db.name=oauth
|
||||||
org.kar..karso.address=http://localhost:17080/oauth/api/
|
org.atriasoft..karso.address=http://localhost:17080/oauth/api/
|
||||||
|
@ -1,175 +0,0 @@
|
|||||||
package org.kar.karso;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import org.glassfish.grizzly.http.server.HttpServer;
|
|
||||||
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
|
|
||||||
import org.glassfish.jersey.jackson.JacksonFeature;
|
|
||||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
|
||||||
import org.glassfish.jersey.server.ResourceConfig;
|
|
||||||
import org.kar.archidata.GlobalConfiguration;
|
|
||||||
import org.kar.archidata.UpdateJwtPublicKey;
|
|
||||||
import org.kar.archidata.api.DataResource;
|
|
||||||
import org.kar.archidata.backup.BackupEngine;
|
|
||||||
import org.kar.archidata.backup.BackupEngine.StoreMode;
|
|
||||||
import org.kar.archidata.catcher.GenericCatcher;
|
|
||||||
import org.kar.archidata.db.DBConfig;
|
|
||||||
import org.kar.archidata.filter.CORSFilter;
|
|
||||||
import org.kar.archidata.filter.OptionFilter;
|
|
||||||
import org.kar.archidata.migration.MigrationEngine;
|
|
||||||
import org.kar.archidata.migration.model.Migration;
|
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
|
||||||
import org.kar.archidata.tools.JWTWrapper;
|
|
||||||
import org.kar.karso.api.ApplicationResource;
|
|
||||||
import org.kar.karso.api.ApplicationTokenResource;
|
|
||||||
import org.kar.karso.api.Front;
|
|
||||||
import org.kar.karso.api.HealthCheck;
|
|
||||||
import org.kar.karso.api.PublicKeyResource;
|
|
||||||
import org.kar.karso.api.RightResource;
|
|
||||||
import org.kar.karso.api.SystemConfigResource;
|
|
||||||
import org.kar.karso.api.UserResource;
|
|
||||||
import org.kar.karso.filter.KarsoAuthenticationFilter;
|
|
||||||
import org.kar.karso.migration.Initialization;
|
|
||||||
import org.kar.karso.migration.Migration20231015;
|
|
||||||
import org.kar.karso.migration.Migration20231126;
|
|
||||||
import org.kar.karso.migration.Migration20240515;
|
|
||||||
import org.kar.karso.model.Application;
|
|
||||||
import org.kar.karso.model.ApplicationToken;
|
|
||||||
import org.kar.karso.model.Right;
|
|
||||||
import org.kar.karso.model.RightDescription;
|
|
||||||
import org.kar.karso.model.Settings;
|
|
||||||
import org.kar.karso.model.UserAuth;
|
|
||||||
import org.kar.karso.util.ConfigVariable;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import jakarta.ws.rs.core.UriBuilder;
|
|
||||||
|
|
||||||
public class WebLauncher {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
|
|
||||||
public static DBConfig dbConfig;
|
|
||||||
protected UpdateJwtPublicKey keyUpdater = null;
|
|
||||||
protected HttpServer server = null;
|
|
||||||
protected BackupEngine backupEngine = new BackupEngine("./backup", StoreMode.JSON);
|
|
||||||
|
|
||||||
public WebLauncher() {
|
|
||||||
ConfigBaseVariable.bdDatabase = "karso";
|
|
||||||
|
|
||||||
this.backupEngine.addClass(Migration.class);
|
|
||||||
this.backupEngine.addClass(Settings.class);
|
|
||||||
this.backupEngine.addClass(UserAuth.class);
|
|
||||||
this.backupEngine.addClass(Application.class);
|
|
||||||
this.backupEngine.addClass(ApplicationToken.class);
|
|
||||||
this.backupEngine.addClass(RightDescription.class);
|
|
||||||
this.backupEngine.addClass(Right.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static URI getBaseURI() {
|
|
||||||
return UriBuilder.fromUri(ConfigBaseVariable.getlocalAddress()).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void migrateDB() throws Exception {
|
|
||||||
WebLauncher.LOGGER.info("Create migration engine");
|
|
||||||
final MigrationEngine migrationEngine = new MigrationEngine();
|
|
||||||
WebLauncher.LOGGER.info("Add initialization");
|
|
||||||
migrationEngine.setInit(new Initialization());
|
|
||||||
WebLauncher.LOGGER.info("Add migration since last version");
|
|
||||||
migrationEngine.add(new Migration20231015());
|
|
||||||
migrationEngine.add(new Migration20231126());
|
|
||||||
migrationEngine.add(new Migration20240515());
|
|
||||||
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
|
||||||
migrationEngine.migrateWaitAdmin(GlobalConfiguration.dbConfig);
|
|
||||||
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(final String[] args) throws Exception {
|
|
||||||
WebLauncher.LOGGER.info("[START] application wake UP");
|
|
||||||
final WebLauncher launcher = new WebLauncher();
|
|
||||||
launcher.migrateDB();
|
|
||||||
launcher.process();
|
|
||||||
WebLauncher.LOGGER.info("end-configure the server & wait finish process:");
|
|
||||||
Thread.currentThread().join();
|
|
||||||
WebLauncher.LOGGER.info("STOP the REST server");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void process() throws InterruptedException {
|
|
||||||
try {
|
|
||||||
JWTWrapper.initLocalToken(ConfigVariable.getUUIDKeyRoot());
|
|
||||||
} catch (final Exception e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
LOGGER.info("Wait 10 seconds ....");
|
|
||||||
Thread.sleep(10000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
// Configure resources
|
|
||||||
// ===================================================================
|
|
||||||
final ResourceConfig rc = new ResourceConfig();
|
|
||||||
|
|
||||||
// add multi-part models ..
|
|
||||||
rc.register(MultiPartFeature.class);
|
|
||||||
// global authentication system
|
|
||||||
rc.register(OptionFilter.class);
|
|
||||||
// remove cors ==> all time called by an other system...
|
|
||||||
rc.register(CORSFilter.class);
|
|
||||||
// global authentication system
|
|
||||||
rc.register(KarsoAuthenticationFilter.class);
|
|
||||||
// register exception catcher
|
|
||||||
GenericCatcher.addAll(rc);
|
|
||||||
// add default resource:
|
|
||||||
rc.register(DataResource.class);
|
|
||||||
rc.register(ApplicationResource.class);
|
|
||||||
rc.register(ApplicationTokenResource.class);
|
|
||||||
rc.register(PublicKeyResource.class);
|
|
||||||
rc.register(RightResource.class);
|
|
||||||
rc.register(SystemConfigResource.class);
|
|
||||||
rc.register(UserResource.class);
|
|
||||||
|
|
||||||
rc.register(HealthCheck.class);
|
|
||||||
rc.register(Front.class);
|
|
||||||
|
|
||||||
// add jackson to be discover when we are ins stand-alone server
|
|
||||||
rc.register(JacksonFeature.class);
|
|
||||||
// enable this to show low level request
|
|
||||||
//rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
|
|
||||||
|
|
||||||
this.server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
|
|
||||||
final HttpServer serverLink = this.server;
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
System.out.println("Stopping server..");
|
|
||||||
serverLink.shutdownNow();
|
|
||||||
}
|
|
||||||
}, "shutdownHook"));
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
// run JERSEY
|
|
||||||
// ===================================================================
|
|
||||||
try {
|
|
||||||
this.server.start();
|
|
||||||
LOGGER.info("Jersey app started at {}", getBaseURI());
|
|
||||||
} catch (final Exception e) {
|
|
||||||
LOGGER.error("There was an error while starting Grizzly HTTP server.");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stop() {
|
|
||||||
if (this.server != null) {
|
|
||||||
this.server.shutdownNow();
|
|
||||||
while (this.server.isStarted()) {
|
|
||||||
LOGGER.info("wait stop");
|
|
||||||
try {
|
|
||||||
Thread.sleep(200);
|
|
||||||
} catch (final InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.server = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
|
|
||||||
package org.kar.karso;
|
|
||||||
|
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
|
||||||
import org.kar.karso.util.ConfigVariable;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class WebLauncherEdgeLocal {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(WebLauncherEdgeLocal.class);
|
|
||||||
|
|
||||||
private WebLauncherEdgeLocal() {}
|
|
||||||
|
|
||||||
public static void main(final String[] args) throws Exception {
|
|
||||||
if (true) {
|
|
||||||
// for local test:
|
|
||||||
ConfigBaseVariable.apiAdress = "http://0.0.0.0:15080/karso/api/";
|
|
||||||
ConfigBaseVariable.dbPort = "3306";
|
|
||||||
ConfigVariable.edge = "true";
|
|
||||||
//ConfigBaseVariable.dbType = "sqlite";
|
|
||||||
//ConfigBaseVariable.dbHost = "./bdd_base.sqlite";
|
|
||||||
|
|
||||||
}
|
|
||||||
WebLauncher.main(args);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
|
|
||||||
package org.kar.karso;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.kar.archidata.api.DataResource;
|
|
||||||
import org.kar.archidata.externalRestApi.AnalyzeApi;
|
|
||||||
import org.kar.archidata.externalRestApi.TsGenerateApi;
|
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
|
||||||
import org.kar.karso.api.ApplicationResource;
|
|
||||||
import org.kar.karso.api.ApplicationTokenResource;
|
|
||||||
import org.kar.karso.api.Front;
|
|
||||||
import org.kar.karso.api.PublicKeyResource;
|
|
||||||
import org.kar.karso.api.RightResource;
|
|
||||||
import org.kar.karso.api.SystemConfigResource;
|
|
||||||
import org.kar.karso.api.UserResource;
|
|
||||||
import org.kar.karso.util.ConfigVariable;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class WebLauncherLocal extends WebLauncher {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(WebLauncherLocal.class);
|
|
||||||
|
|
||||||
private WebLauncherLocal() {}
|
|
||||||
|
|
||||||
public static void generateObjects() throws Exception {
|
|
||||||
LOGGER.info("Generate APIs");
|
|
||||||
final List<Class<?>> listOfResources = List.of(Front.class, DataResource.class, ApplicationResource.class,
|
|
||||||
ApplicationTokenResource.class, PublicKeyResource.class, RightResource.class, UserResource.class,
|
|
||||||
SystemConfigResource.class);
|
|
||||||
final AnalyzeApi api = new AnalyzeApi();
|
|
||||||
api.addAllApi(listOfResources);
|
|
||||||
TsGenerateApi.generateApi(api, "../front/src/back-api/");
|
|
||||||
LOGGER.info("Generate APIs (DONE)");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(final String[] args) throws Exception {
|
|
||||||
generateObjects();
|
|
||||||
final WebLauncherLocal launcher = new WebLauncherLocal();
|
|
||||||
launcher.process();
|
|
||||||
LOGGER.info("end-configure the server & wait finish process:");
|
|
||||||
Thread.currentThread().join();
|
|
||||||
LOGGER.info("STOP the REST server:");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process() throws InterruptedException {
|
|
||||||
if (true) {
|
|
||||||
ConfigBaseVariable.apiAdress = "http://0.0.0.0:15080/karso/api/";
|
|
||||||
ConfigBaseVariable.dbPort = "3906";
|
|
||||||
// create a unique key for test ==> not retrieve the token every load...
|
|
||||||
ConfigVariable.uuid_for_key_generation = "lkjlkjlkjlmkjqmwlsdkjqfsdlkf88QJSDMLQKSndmLQKZNERMAL";
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
super.migrateDB();
|
|
||||||
} catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
while (true) {
|
|
||||||
LOGGER.error("============================================================================");
|
|
||||||
LOGGER.error("== Migration fail ==> waiting intervention of administrator...");
|
|
||||||
LOGGER.error("============================================================================");
|
|
||||||
Thread.sleep(60 * 60 * 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.process();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,342 +0,0 @@
|
|||||||
package org.kar.karso.api;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.AsyncType;
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
|
||||||
import org.kar.archidata.dataAccess.QueryAnd;
|
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
|
||||||
import org.kar.archidata.exception.InputException;
|
|
||||||
import org.kar.archidata.exception.SystemException;
|
|
||||||
import org.kar.archidata.filter.GenericContext;
|
|
||||||
import org.kar.archidata.tools.JWTWrapper;
|
|
||||||
import org.kar.karso.model.AddUserData;
|
|
||||||
import org.kar.karso.model.Application;
|
|
||||||
import org.kar.karso.model.ApplicationSmall;
|
|
||||||
import org.kar.karso.model.ClientToken;
|
|
||||||
import org.kar.karso.model.RightDescription;
|
|
||||||
import org.kar.karso.model.UserAuth;
|
|
||||||
import org.kar.karso.model.UserLinkApplication;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import jakarta.annotation.security.RolesAllowed;
|
|
||||||
import jakarta.ws.rs.Consumes;
|
|
||||||
import jakarta.ws.rs.DELETE;
|
|
||||||
import jakarta.ws.rs.GET;
|
|
||||||
import jakarta.ws.rs.PATCH;
|
|
||||||
import jakarta.ws.rs.POST;
|
|
||||||
import jakarta.ws.rs.Path;
|
|
||||||
import jakarta.ws.rs.PathParam;
|
|
||||||
import jakarta.ws.rs.Produces;
|
|
||||||
import jakarta.ws.rs.QueryParam;
|
|
||||||
import jakarta.ws.rs.core.Context;
|
|
||||||
import jakarta.ws.rs.core.MediaType;
|
|
||||||
import jakarta.ws.rs.core.SecurityContext;
|
|
||||||
|
|
||||||
@Path("/application")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public class ApplicationResource {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationResource.class);
|
|
||||||
|
|
||||||
public ApplicationResource() {}
|
|
||||||
|
|
||||||
public List<Long> getUserListOfApplication(final Long userId) {
|
|
||||||
final List<Long> out = new ArrayList<>();
|
|
||||||
List<UserLinkApplication> links = null;
|
|
||||||
try {
|
|
||||||
links = DataAccess.getsWhere(UserLinkApplication.class,
|
|
||||||
new Condition(new QueryCondition("object1id", "=", userId)));
|
|
||||||
} catch (final Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
final String result = "SERVER Internal error";
|
|
||||||
LOGGER.error(" result: {}", result);
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
for (final UserLinkApplication app : links) {
|
|
||||||
out.add(app.applicationId);
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Long> getListOfUsers(final Long applicationId) {
|
|
||||||
final List<Long> out = new ArrayList<>();
|
|
||||||
List<UserLinkApplication> links = null;
|
|
||||||
try {
|
|
||||||
links = DataAccess.getsWhere(UserLinkApplication.class,
|
|
||||||
new Condition(new QueryCondition("object2id", "=", applicationId)));
|
|
||||||
} catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
final String result = "SERVER Internal error";
|
|
||||||
LOGGER.error(" result: {}", result);
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
LOGGER.debug("Find list of user for an application: {}", links);
|
|
||||||
for (final UserLinkApplication app : links) {
|
|
||||||
out.add(app.userId);
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Generic /application/
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
|
||||||
public List<Application> gets(@Context final SecurityContext sc) throws Exception {
|
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
|
||||||
LOGGER.debug("getApplications");
|
|
||||||
// TODO filter with the list of element available in his authorizations ...
|
|
||||||
final List<Application> tmp = DataAccess.gets(Application.class);
|
|
||||||
if (gc.userByToken.hasRight("ADMIN", true)) {
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
final List<Long> regular = getUserListOfApplication(gc.userByToken.id);
|
|
||||||
final List<Application> out = new ArrayList<>();
|
|
||||||
for (final Application app : tmp) {
|
|
||||||
if (regular.indexOf(app.id) != -1) {
|
|
||||||
out.add(app);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public Application create(final Application application) throws Exception {
|
|
||||||
LOGGER.debug("create new application {}", application);
|
|
||||||
// verify login or email is correct:
|
|
||||||
if (application.name == null || application.name.length() < 5) {
|
|
||||||
throw new InputException("name", "create application (name too small: '" + application.name + "')");
|
|
||||||
}
|
|
||||||
if (application.redirect == null || application.redirect.length() < 6) {
|
|
||||||
throw new InputException("redirect",
|
|
||||||
"create application (redirect too small: '" + application.redirect + "')");
|
|
||||||
}
|
|
||||||
application.id = null;
|
|
||||||
application.createdAt = null;
|
|
||||||
application.deleted = null;
|
|
||||||
application.updatedAt = null;
|
|
||||||
final Application tmp = DataAccess.insert(application);
|
|
||||||
return get(tmp.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Generic /application/{id}
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{id}")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
public Application get(@PathParam("id") final Long id) throws Exception {
|
|
||||||
return DataAccess.get(Application.class, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PATCH
|
|
||||||
@Path("{id}")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public Application patch(@PathParam("id") final Long id, @AsyncType(Application.class) final String jsonRequest)
|
|
||||||
throws Exception {
|
|
||||||
DataAccess.updateWithJson(Application.class, id, jsonRequest);
|
|
||||||
return DataAccess.get(Application.class, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DELETE
|
|
||||||
@Path("{id}")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
@Produces(value = MediaType.TEXT_PLAIN)
|
|
||||||
public void remove(@Context final SecurityContext sc, @PathParam("id") final long applicationId) throws Exception {
|
|
||||||
DataAccess.delete(Application.class, applicationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Generic /{id}/*
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{id}/users")
|
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
|
||||||
public List<Long> getApplicationUsers(@PathParam("id") final Long applicationId) throws Exception {
|
|
||||||
// special case for SSO: (all user have access on the SSO...).
|
|
||||||
|
|
||||||
LOGGER.debug("Request list of user for an applciation: {}", applicationId);
|
|
||||||
return getListOfUsers(applicationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Generic /application/*
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("small")
|
|
||||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
|
||||||
public List<ApplicationSmall> getApplicationsSmall(@Context final SecurityContext sc) throws Exception {
|
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
|
||||||
LOGGER.debug("getApplications");
|
|
||||||
final List<Application> tmp = DataAccess.gets(Application.class);
|
|
||||||
final List<Long> regular = getUserListOfApplication(gc.userByToken.id);
|
|
||||||
final List<ApplicationSmall> out = new ArrayList<>();
|
|
||||||
for (final Application app : tmp) {
|
|
||||||
if (regular.indexOf(app.id) != -1) {
|
|
||||||
out.add(new ApplicationSmall(app.id, app.name, app.description, app.redirect));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("{id}/users")
|
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public void addUser(@PathParam("id") final Long applicationId, final AddUserData data) throws Exception {
|
|
||||||
LOGGER.debug("getApplications");
|
|
||||||
AddOnManyToMany.addLink(UserAuth.class, data.userId, "application", applicationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DELETE
|
|
||||||
@Path("{id}/users/${userId}")
|
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
|
||||||
public void removeUser(@PathParam("id") final Long applicationId, @PathParam("userId") final Long userId)
|
|
||||||
throws Exception {
|
|
||||||
LOGGER.debug("getApplications");
|
|
||||||
AddOnManyToMany.removeLink(UserAuth.class, userId, "application", applicationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{id}/rights")
|
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
|
||||||
public List<RightDescription> getRightsDescription(@PathParam("id") final Long applicationId) throws Exception {
|
|
||||||
LOGGER.debug("getApplications rights");
|
|
||||||
return DataAccess.getsWhere(RightDescription.class,
|
|
||||||
new Condition(new QueryCondition("applicationId", "=", applicationId)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("get_token")
|
|
||||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
|
||||||
public ClientToken getClientToken(
|
|
||||||
@Context final SecurityContext sc,
|
|
||||||
@QueryParam("application") final String application) throws Exception {
|
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
|
||||||
LOGGER.info("get application TOKEN application name='{}'", application);
|
|
||||||
LOGGER.debug("== USER ? {}", gc.userByToken.name);
|
|
||||||
|
|
||||||
if (application == null) {
|
|
||||||
throw new InputException("application", "Input error missing parameter");
|
|
||||||
}
|
|
||||||
String applicationName = application;
|
|
||||||
boolean isDev = false;
|
|
||||||
if (applicationName.endsWith("-dev")) {
|
|
||||||
applicationName = applicationName.substring(0, applicationName.length() - 4);
|
|
||||||
isDev = true;
|
|
||||||
}
|
|
||||||
LOGGER.debug("Search for '{}' base of '{}'", applicationName, application);
|
|
||||||
|
|
||||||
Application appl = null;
|
|
||||||
try {
|
|
||||||
appl = DataAccess.getWhere(Application.class,
|
|
||||||
new Condition(new QueryCondition("name", "=", applicationName)));
|
|
||||||
} catch (final Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
final String result = "SERVER Internal error";
|
|
||||||
LOGGER.debug(" result: {}", result);
|
|
||||||
throw new SystemException("Internal fail request");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (appl == null) {
|
|
||||||
final String result = "Authentiocate-wrong email/login '" + applicationName + "')";
|
|
||||||
LOGGER.error(" result: {}", result);
|
|
||||||
throw new InputException("email/login", "Authentiocate-wrong email/login '" + applicationName + "'");
|
|
||||||
}
|
|
||||||
UserLinkApplication links = null;
|
|
||||||
try {
|
|
||||||
links = DataAccess.getWhere(UserLinkApplication.class,
|
|
||||||
new Condition(new QueryAnd(new QueryCondition("object1id", "=", gc.userByToken.id),
|
|
||||||
new QueryCondition("deleted", "=", 0), new QueryCondition("object2id", "=", appl.id))));
|
|
||||||
} catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new SystemException("Fail to insert Link");
|
|
||||||
}
|
|
||||||
if (links == null) {
|
|
||||||
throw new SystemException(
|
|
||||||
"Authenticate impossible ==> application not accessible '" + applicationName + "'");
|
|
||||||
}
|
|
||||||
// Get the USER Right
|
|
||||||
final Map<String, Object> applicationRight = RightResource.getUserRight(gc.userByToken.id, appl.id);
|
|
||||||
if (!applicationRight.containsKey("USER")) {
|
|
||||||
// If the USER is not override, the system add by default USER
|
|
||||||
applicationRight.put("USER", true);
|
|
||||||
}
|
|
||||||
final Map<String, Object> outRight = new HashMap<>();
|
|
||||||
// we set the right in the under map to manage multiple application group right.
|
|
||||||
// and in some application user can see other user or all user of the
|
|
||||||
// application
|
|
||||||
outRight.put(applicationName, applicationRight);
|
|
||||||
final String ret = JWTWrapper.generateJWToken(gc.userByToken.id, gc.userByToken.name, "KarAuth",
|
|
||||||
applicationName, outRight, -appl.ttl);
|
|
||||||
// logger.debug(" ==> generate token: {}", ret);
|
|
||||||
String returnAdress = appl.redirect;
|
|
||||||
if (isDev) {
|
|
||||||
returnAdress = appl.redirectDev;
|
|
||||||
}
|
|
||||||
return new ClientToken(returnAdress, ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("return")
|
|
||||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
|
||||||
public String logOut(@Context final SecurityContext sc, @QueryParam("application") final String application)
|
|
||||||
throws SystemException, InputException {
|
|
||||||
LOGGER.debug("=====================================");
|
|
||||||
LOGGER.debug("Get log_out()");
|
|
||||||
LOGGER.debug("=====================================");
|
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
|
||||||
LOGGER.debug("== USER ? {}", gc.userByToken);
|
|
||||||
|
|
||||||
if (application == null) {
|
|
||||||
throw new InputException("application", "Input error missing parameter");
|
|
||||||
}
|
|
||||||
String applicationName = application;
|
|
||||||
boolean isDev = false;
|
|
||||||
if (applicationName.endsWith("-dev")) {
|
|
||||||
applicationName = applicationName.substring(0, applicationName.length() - 4);
|
|
||||||
isDev = true;
|
|
||||||
}
|
|
||||||
LOGGER.debug("Search for '{}' base of '{}'", applicationName, application);
|
|
||||||
|
|
||||||
Application appl = null;
|
|
||||||
try {
|
|
||||||
appl = DataAccess.getWhere(Application.class,
|
|
||||||
new Condition(new QueryCondition("name", "=", applicationName)));
|
|
||||||
} catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new SystemException("Fail to log-Out...");
|
|
||||||
}
|
|
||||||
if (appl == null) {
|
|
||||||
throw new SystemException("Authentiocate-wrong email/login '" + applicationName + "'");
|
|
||||||
}
|
|
||||||
String returnAdress = appl.redirect;
|
|
||||||
if (isDev) {
|
|
||||||
returnAdress = appl.redirectDev;
|
|
||||||
}
|
|
||||||
return returnAdress;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,144 +0,0 @@
|
|||||||
package org.kar.karso.api;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
|
||||||
import org.kar.archidata.dataAccess.QueryAnd;
|
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
|
||||||
import org.kar.archidata.exception.DataAccessException;
|
|
||||||
import org.kar.archidata.exception.InputException;
|
|
||||||
import org.kar.karso.model.ApplicationToken;
|
|
||||||
import org.kar.karso.model.CreateTokenRequest;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import jakarta.annotation.security.RolesAllowed;
|
|
||||||
import jakarta.ws.rs.Consumes;
|
|
||||||
import jakarta.ws.rs.DELETE;
|
|
||||||
import jakarta.ws.rs.GET;
|
|
||||||
import jakarta.ws.rs.POST;
|
|
||||||
import jakarta.ws.rs.Path;
|
|
||||||
import jakarta.ws.rs.PathParam;
|
|
||||||
import jakarta.ws.rs.Produces;
|
|
||||||
import jakarta.ws.rs.core.Context;
|
|
||||||
import jakarta.ws.rs.core.MediaType;
|
|
||||||
import jakarta.ws.rs.core.SecurityContext;
|
|
||||||
|
|
||||||
@Path("/application_token")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public class ApplicationTokenResource {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationTokenResource.class);
|
|
||||||
|
|
||||||
public ApplicationTokenResource() {}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Generic /application_token/{applicationId}
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{applicationId}")
|
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
|
||||||
public List<ApplicationToken> gets(
|
|
||||||
@Context final SecurityContext sc,
|
|
||||||
@PathParam("applicationId") final Long applicationId) throws Exception {
|
|
||||||
final List<ApplicationToken> values = DataAccess.getsWhere(ApplicationToken.class,
|
|
||||||
new Condition(new QueryCondition("parentId", "=", applicationId)));
|
|
||||||
// clean all tokens this is a secret:
|
|
||||||
for (final ApplicationToken elem : values) {
|
|
||||||
elem.token = null;
|
|
||||||
}
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
@DELETE
|
|
||||||
@Path("{applicationId}/{tokenId}")
|
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
|
||||||
public void remove(
|
|
||||||
@Context final SecurityContext sc,
|
|
||||||
@PathParam("applicationId") final Long applicationId,
|
|
||||||
@PathParam("tokenId") final Integer tokenId) throws Exception {
|
|
||||||
final int nbRemoved = DataAccess.deleteWhere(ApplicationToken.class,
|
|
||||||
new Condition(new QueryAnd(new QueryCondition("parentId", "=", applicationId),
|
|
||||||
new QueryCondition("id", "=", tokenId))));
|
|
||||||
if (nbRemoved == 0) {
|
|
||||||
throw new DataAccessException("Fail to remove token");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String multipartCorrection(final String data) {
|
|
||||||
if (data == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (data.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (data.contentEquals("null")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
static String randomToken() {
|
|
||||||
final int len = 48;
|
|
||||||
final String valid_element = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz0123456789#_@-~*!?";
|
|
||||||
// creating a StringBuffer size of AlphaNumericStr
|
|
||||||
final StringBuilder out = new StringBuilder(len);
|
|
||||||
int iii;
|
|
||||||
for (iii = 0; iii < len; iii++) {
|
|
||||||
//generating a random number using math.random()
|
|
||||||
final int ch = (int) (valid_element.length() * Math.random());
|
|
||||||
//adding Random character one by one at the end of s
|
|
||||||
out.append(valid_element.charAt(ch));
|
|
||||||
}
|
|
||||||
return out.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("{applicationId}/create")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public ApplicationToken create(
|
|
||||||
@Context final SecurityContext sc,
|
|
||||||
@PathParam("applicationId") final Long applicationId,
|
|
||||||
final CreateTokenRequest request) throws Exception {
|
|
||||||
LOGGER.info("get user application TOKEN: app='{}' user='???'", applicationId);
|
|
||||||
// correct input string stream :
|
|
||||||
final String name = multipartCorrection(request.name);
|
|
||||||
//validity = multipartCorrection(validity);
|
|
||||||
LOGGER.debug("create a new token...");
|
|
||||||
if (applicationId == null) {
|
|
||||||
throw new InputException("applicationId", "can not be null");
|
|
||||||
}
|
|
||||||
final int maximum = 365 * 5;
|
|
||||||
Integer validity = request.validity;
|
|
||||||
if (validity == null || validity < 0 || validity > maximum) {
|
|
||||||
validity = maximum;
|
|
||||||
}
|
|
||||||
LOGGER.warn("validity= {}", validity);
|
|
||||||
// todo: set validity timestamp ...
|
|
||||||
// TODO: check if application exist ...
|
|
||||||
ApplicationToken token = new ApplicationToken();
|
|
||||||
token.token = randomToken();
|
|
||||||
token.name = multipartCorrection(name);
|
|
||||||
token.parentId = applicationId;
|
|
||||||
final OffsetDateTime now = OffsetDateTime.now(ZoneOffset.UTC);
|
|
||||||
LOGGER.warn("Check Timestamp now = {}", now);
|
|
||||||
token.endValidityTime = Timestamp.from(now.plusDays(validity).toInstant());
|
|
||||||
LOGGER.warn("token.endValidityTime = {}", token.endValidityTime);
|
|
||||||
|
|
||||||
// insert in the BDD
|
|
||||||
token = DataAccess.insert(token);
|
|
||||||
// here we return the token to permit to the user to see it to set it in the application.
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
Cannot find a deserializer for non-concrete Map type [map type; class jakarta.ws.rs.core.MultivaluedMap, [simple type, class java.lang.String] -> [collection type; class java.util.List, contains [simple type, class java.lang.String]]]
|
|
||||||
at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 1]
|
|
||||||
*/
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package org.kar.karso.api;
|
|
||||||
|
|
||||||
import org.kar.archidata.api.FrontGeneric;
|
|
||||||
import org.kar.karso.util.ConfigVariable;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import jakarta.ws.rs.Path;
|
|
||||||
|
|
||||||
@Path("/front")
|
|
||||||
public class Front extends FrontGeneric {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(FrontGeneric.class);
|
|
||||||
|
|
||||||
public Front() {
|
|
||||||
this.baseFrontFolder = ConfigVariable.getFrontFolder();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package org.kar.karso.api;
|
|
||||||
|
|
||||||
import org.kar.archidata.exception.FailException;
|
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
|
||||||
import org.kar.archidata.tools.JWTWrapper;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import jakarta.annotation.security.PermitAll;
|
|
||||||
import jakarta.ws.rs.GET;
|
|
||||||
import jakarta.ws.rs.Path;
|
|
||||||
import jakarta.ws.rs.Produces;
|
|
||||||
import jakarta.ws.rs.core.MediaType;
|
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
|
|
||||||
@Path("/health_check")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public class HealthCheck {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(HealthCheck.class);
|
|
||||||
|
|
||||||
public record HealthResult(
|
|
||||||
String value) {};
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@PermitAll
|
|
||||||
public HealthResult getHealth() throws FailException {
|
|
||||||
if (JWTWrapper.getPublicKeyJson() == null && !ConfigBaseVariable.getTestMode()) {
|
|
||||||
throw new FailException(Response.Status.INTERNAL_SERVER_ERROR, "Missing Jwt public token");
|
|
||||||
}
|
|
||||||
return new HealthResult("alive and kicking");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
package org.kar.karso.api;
|
|
||||||
|
|
||||||
import java.security.interfaces.RSAPublicKey;
|
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
import org.kar.archidata.tools.JWTWrapper;
|
|
||||||
import org.kar.archidata.tools.JWTWrapper.PublicKey;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.nimbusds.jose.JOSEException;
|
|
||||||
|
|
||||||
import jakarta.annotation.security.RolesAllowed;
|
|
||||||
import jakarta.ws.rs.GET;
|
|
||||||
import jakarta.ws.rs.Path;
|
|
||||||
import jakarta.ws.rs.Produces;
|
|
||||||
import jakarta.ws.rs.core.MediaType;
|
|
||||||
|
|
||||||
@Path("/public_key")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public class PublicKeyResource {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PublicKeyResource.class);
|
|
||||||
|
|
||||||
public PublicKeyResource() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is for java server that use the same implementation
|
|
||||||
// curl http://localhost:9993/public_key
|
|
||||||
@GET
|
|
||||||
@RolesAllowed(value = { "APPLICATION" })
|
|
||||||
public PublicKey getKey() {
|
|
||||||
return new PublicKey(JWTWrapper.getPublicKeyJson());
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is for common other interface that support public PEM stream.
|
|
||||||
// curl http://localhost:9993/public_key/pem
|
|
||||||
@GET
|
|
||||||
@Path("/pem")
|
|
||||||
@RolesAllowed(value = { "APPLICATION" })
|
|
||||||
public String getKeyPem() throws JOSEException {
|
|
||||||
final RSAPublicKey keyPub = JWTWrapper.getPublicKeyJava();
|
|
||||||
final byte[] data = keyPub.getEncoded();
|
|
||||||
final String base64encoded = new String(Base64.getEncoder().encode(data));
|
|
||||||
return "-----BEGIN PUBLIC KEY-----\n" + base64encoded + "\n-----END PUBLIC KEY-----\n";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,177 +0,0 @@
|
|||||||
package org.kar.karso.api;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.AsyncType;
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
|
||||||
import org.kar.archidata.dataAccess.QueryAnd;
|
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
|
||||||
import org.kar.karso.model.Right;
|
|
||||||
import org.kar.karso.model.RightDescription;
|
|
||||||
import org.kar.karso.util.Transform;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import jakarta.annotation.security.RolesAllowed;
|
|
||||||
import jakarta.ws.rs.Consumes;
|
|
||||||
import jakarta.ws.rs.DELETE;
|
|
||||||
import jakarta.ws.rs.GET;
|
|
||||||
import jakarta.ws.rs.PATCH;
|
|
||||||
import jakarta.ws.rs.POST;
|
|
||||||
import jakarta.ws.rs.Path;
|
|
||||||
import jakarta.ws.rs.PathParam;
|
|
||||||
import jakarta.ws.rs.Produces;
|
|
||||||
import jakarta.ws.rs.core.MediaType;
|
|
||||||
|
|
||||||
@Path("/right")
|
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
|
||||||
public class RightResource {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(RightResource.class);
|
|
||||||
|
|
||||||
public static List<RightDescription> getApplicationRightDecription(final long applicationId) throws Exception {
|
|
||||||
return DataAccess.getsWhere(RightDescription.class,
|
|
||||||
new Condition(new QueryCondition("applicationId", "=", applicationId)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Right> getRawUserRight(final long userId, final long applicationId) throws Exception {
|
|
||||||
// Formatter:off
|
|
||||||
return DataAccess.getsWhere(Right.class,
|
|
||||||
new Condition(new QueryAnd(new QueryCondition("applicationId", "=", applicationId),
|
|
||||||
new QueryCondition("userId", "=", userId))));
|
|
||||||
// Formatter:on
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, Object> getUserRight(final long userId, final long applicationId) throws Exception {
|
|
||||||
final Map<String, Object> out = new HashMap<>();
|
|
||||||
final List<RightDescription> rightsDescriptions = getApplicationRightDecription(applicationId);
|
|
||||||
LOGGER.trace("Get some descriptions: {} applicationId={}", rightsDescriptions.size(), applicationId);
|
|
||||||
if (rightsDescriptions != null && rightsDescriptions.size() != 0) {
|
|
||||||
final List<Right> rights = getRawUserRight(userId, applicationId);
|
|
||||||
LOGGER.trace("Get some user right: count={} userID={} applicationId={}", rights.size(), userId,
|
|
||||||
applicationId);
|
|
||||||
LOGGER.trace("Rights:");
|
|
||||||
for (final Right elem : rights) {
|
|
||||||
LOGGER.trace(" - applId={} rightDescriptionId={} value={}", elem.applicationId,
|
|
||||||
elem.rightDescriptionId, elem.value);
|
|
||||||
}
|
|
||||||
LOGGER.trace("RightDescription:");
|
|
||||||
for (final RightDescription description : rightsDescriptions) {
|
|
||||||
if (description == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
LOGGER.trace(" - id={} key={} type={} default={}", description.id, description.key, description.type,
|
|
||||||
description.defaultValue);
|
|
||||||
}
|
|
||||||
for (final RightDescription description : rightsDescriptions) {
|
|
||||||
if (description == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final Right right = rights.stream().filter(elem -> elem.rightDescriptionId.equals(description.id))
|
|
||||||
.findAny().orElse(null);
|
|
||||||
if (right != null) {
|
|
||||||
out.put(description.key, Transform.convertToType(description.type, right.value));
|
|
||||||
} else if (description.defaultValue != null) {
|
|
||||||
out.put(description.key, Transform.convertToType(description.type, description.defaultValue));
|
|
||||||
} else {
|
|
||||||
out.put(description.key, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// the application does not manage right with Karso (normal use-case)
|
|
||||||
LOGGER.debug("Does not manage Karso right...");
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateUserRight(final long userId, final long applicationId, final Map<String, Object> delta)
|
|
||||||
throws Exception {
|
|
||||||
final List<RightDescription> rightsDescriptions = getApplicationRightDecription(applicationId);
|
|
||||||
LOGGER.debug("Get some descriptions: {} applicationId={}", rightsDescriptions.size(), applicationId);
|
|
||||||
if (rightsDescriptions == null || rightsDescriptions.size() == 0) {
|
|
||||||
throw new IllegalArgumentException("Request change right on an application that does not manage any right");
|
|
||||||
}
|
|
||||||
final List<Right> rights = getRawUserRight(userId, applicationId);
|
|
||||||
LOGGER.debug("Get some user right: count={} userID={}", rights.size(), userId);
|
|
||||||
for (final RightDescription description : rightsDescriptions) {
|
|
||||||
if (description == null) {
|
|
||||||
// TODO: this is a really strange case to manage later...
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final Object newValue = delta.get(description.key);
|
|
||||||
if (newValue == null) {
|
|
||||||
//No need to update or create...
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final String convertedValue = Transform.convertToStringCheck(description.type, newValue);
|
|
||||||
if (convertedValue == null) {
|
|
||||||
throw new IllegalArgumentException("Uncompatible value:'" + description.type + "'");
|
|
||||||
}
|
|
||||||
final List<Right> allRights = rights.stream().filter(elem -> elem.rightDescriptionId.equals(description.id))
|
|
||||||
.toList();
|
|
||||||
if (allRights.size() > 1) {
|
|
||||||
// special case of error somewhere else ... ==> remove all elements (except the first)
|
|
||||||
for (int iii = 1; iii < allRights.size(); iii++) {
|
|
||||||
LOGGER.error("Remove starnge element in Right id={} ", allRights.get(iii).id);
|
|
||||||
DataAccess.delete(Right.class, allRights.get(iii).id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (allRights.size() == 1) {
|
|
||||||
final Right right = allRights.get(0);
|
|
||||||
// The value exist, we need to update it
|
|
||||||
LOGGER.debug("Request update a knonwn parameter: {} with {}", description.key, newValue);
|
|
||||||
right.value = convertedValue;
|
|
||||||
DataAccess.update(right, right.id, List.of("value"));
|
|
||||||
} else {
|
|
||||||
// we need to create it
|
|
||||||
LOGGER.debug("Request create parameter: {} with {}", description.key, newValue);
|
|
||||||
final Right right = new Right();
|
|
||||||
right.applicationId = applicationId;
|
|
||||||
right.userId = userId;
|
|
||||||
right.rightDescriptionId = description.id;
|
|
||||||
right.value = convertedValue;
|
|
||||||
DataAccess.insert(right);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
public List<Right> gets() throws Exception {
|
|
||||||
return DataAccess.gets(Right.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public Right post(final Right request) throws Exception {
|
|
||||||
return DataAccess.insert(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{id}")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
public static Right get(@PathParam("id") final Long id) throws Exception {
|
|
||||||
return DataAccess.get(Right.class, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PATCH
|
|
||||||
@Path("{id}")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public Right patch(@PathParam("id") final Long id, @AsyncType(Right.class) final String jsonRequest)
|
|
||||||
throws Exception {
|
|
||||||
DataAccess.updateWithJson(Right.class, id, jsonRequest);
|
|
||||||
return DataAccess.get(Right.class, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DELETE
|
|
||||||
@Path("{id}")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
public void remove(@PathParam("id") final Long id) throws Exception {
|
|
||||||
DataAccess.delete(Right.class, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
package org.kar.karso.api;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.AsyncType;
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
|
||||||
import org.kar.archidata.exception.NotFoundException;
|
|
||||||
import org.kar.karso.model.Settings;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
|
|
||||||
import jakarta.annotation.security.PermitAll;
|
|
||||||
import jakarta.annotation.security.RolesAllowed;
|
|
||||||
import jakarta.ws.rs.Consumes;
|
|
||||||
import jakarta.ws.rs.GET;
|
|
||||||
import jakarta.ws.rs.PATCH;
|
|
||||||
import jakarta.ws.rs.Path;
|
|
||||||
import jakarta.ws.rs.PathParam;
|
|
||||||
import jakarta.ws.rs.Produces;
|
|
||||||
import jakarta.ws.rs.core.Context;
|
|
||||||
import jakarta.ws.rs.core.MediaType;
|
|
||||||
import jakarta.ws.rs.core.SecurityContext;
|
|
||||||
|
|
||||||
@Path("/system_config")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public class SystemConfigResource {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(SystemConfigResource.class);
|
|
||||||
|
|
||||||
public static class GetSignUpAvailable {
|
|
||||||
public boolean signup;
|
|
||||||
|
|
||||||
public GetSignUpAvailable(final boolean availlable) {
|
|
||||||
this.signup = availlable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GetSignUpAvailable() {
|
|
||||||
this.signup = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SystemConfigResource() {}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("is_sign_up_availlable")
|
|
||||||
@PermitAll
|
|
||||||
public GetSignUpAvailable isSignUpAvailable() throws Exception {
|
|
||||||
final Settings set = DataAccess.getWhere(Settings.class,
|
|
||||||
new Condition(new QueryCondition("key", "=", "SIGN_UP_ENABLE")));
|
|
||||||
if (set == null) {
|
|
||||||
throw new NotFoundException("Value does not exist");
|
|
||||||
}
|
|
||||||
final boolean availlable = "true".equalsIgnoreCase(set.value);
|
|
||||||
final GetSignUpAvailable tmp = new GetSignUpAvailable(availlable);
|
|
||||||
LOGGER.debug("mlkmlk {}", tmp.signup);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("key/{key}")
|
|
||||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
|
||||||
public Map<String, Object> getKey(@Context final SecurityContext sc, @PathParam("key") final String key)
|
|
||||||
throws Exception {
|
|
||||||
final Settings set = DataAccess.getWhere(Settings.class, new Condition(new QueryCondition("key", "=", key)));
|
|
||||||
if (set == null) {
|
|
||||||
throw new NotFoundException("Value does not exist");
|
|
||||||
}
|
|
||||||
final Map<String, Object> out = new HashMap<>();
|
|
||||||
if ("BOOLEAN".equals(set.type)) {
|
|
||||||
final boolean available = "true".equalsIgnoreCase(set.value);
|
|
||||||
out.put("value", available);
|
|
||||||
} else if ("NUMBER".equals(set.type)) {
|
|
||||||
final double value = Double.parseDouble(set.value);
|
|
||||||
out.put("value", value);
|
|
||||||
} else {
|
|
||||||
out.put("value", set.value);
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PATCH
|
|
||||||
@Path("key/{key}")
|
|
||||||
@RolesAllowed(value = { "ADMIN" })
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public void setKey(
|
|
||||||
@Context final SecurityContext sc,
|
|
||||||
@PathParam("key") final String key,
|
|
||||||
@AsyncType(Object.class) final String jsonRequest) throws Exception {
|
|
||||||
Settings res = null;
|
|
||||||
try {
|
|
||||||
res = DataAccess.getWhere(Settings.class, new Condition(new QueryCondition("key", "=", key)));
|
|
||||||
} catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
final String result = "Can not find the Key: '" + key + "'";
|
|
||||||
throw new NotFoundException(result);
|
|
||||||
}
|
|
||||||
final ObjectMapper mapper = new ObjectMapper();
|
|
||||||
// Read the tree to filter injection of data:
|
|
||||||
final JsonNode root = mapper.readTree(jsonRequest);
|
|
||||||
final JsonNode value = root.findPath("value");
|
|
||||||
|
|
||||||
res.value = value.asText();
|
|
||||||
LOGGER.debug("Update value : {}", res.value);
|
|
||||||
DataAccess.update(res, res.id, List.of("value"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,349 +0,0 @@
|
|||||||
package org.kar.karso.api;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
|
||||||
import org.kar.archidata.exception.FailException;
|
|
||||||
import org.kar.archidata.exception.InputException;
|
|
||||||
import org.kar.archidata.exception.SystemException;
|
|
||||||
import org.kar.archidata.filter.GenericContext;
|
|
||||||
import org.kar.archidata.model.GetToken;
|
|
||||||
import org.kar.archidata.tools.JWTWrapper;
|
|
||||||
import org.kar.karso.migration.Initialization;
|
|
||||||
import org.kar.karso.model.ChangePassword;
|
|
||||||
import org.kar.karso.model.DataGetToken;
|
|
||||||
import org.kar.karso.model.UserAuth;
|
|
||||||
import org.kar.karso.model.UserAuthGet;
|
|
||||||
import org.kar.karso.model.UserCreate;
|
|
||||||
import org.kar.karso.util.ConfigVariable;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import jakarta.annotation.security.PermitAll;
|
|
||||||
import jakarta.annotation.security.RolesAllowed;
|
|
||||||
import jakarta.ws.rs.Consumes;
|
|
||||||
import jakarta.ws.rs.GET;
|
|
||||||
import jakarta.ws.rs.PATCH;
|
|
||||||
import jakarta.ws.rs.POST;
|
|
||||||
import jakarta.ws.rs.Path;
|
|
||||||
import jakarta.ws.rs.PathParam;
|
|
||||||
import jakarta.ws.rs.Produces;
|
|
||||||
import jakarta.ws.rs.QueryParam;
|
|
||||||
import jakarta.ws.rs.core.Context;
|
|
||||||
import jakarta.ws.rs.core.MediaType;
|
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
import jakarta.ws.rs.core.SecurityContext;
|
|
||||||
|
|
||||||
@Path("/users")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public class UserResource {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public static class UserOut {
|
|
||||||
public long id;
|
|
||||||
public String login;
|
|
||||||
|
|
||||||
public UserOut(final long id, final String login) {
|
|
||||||
this.id = id;
|
|
||||||
this.login = login;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserResource() {}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
public List<UserAuthGet> getUsers() throws Exception {
|
|
||||||
return DataAccess.gets(UserAuthGet.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{id}")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
public UserAuthGet getUser(@Context final SecurityContext sc, @PathParam("id") final long userId) throws Exception {
|
|
||||||
//GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
|
||||||
return DataAccess.get(UserAuthGet.class, userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("{userId}/application/{applicationId}/link")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
public UserAuth linkApplication(
|
|
||||||
@Context final SecurityContext sc,
|
|
||||||
@PathParam("userId") final long userId,
|
|
||||||
@PathParam("applicationId") final long applicationId,
|
|
||||||
final boolean data) throws Exception {
|
|
||||||
LOGGER.debug("Find typeNode");
|
|
||||||
if (data) {
|
|
||||||
AddOnManyToMany.addLink(UserAuth.class, userId, "application", applicationId);
|
|
||||||
} else {
|
|
||||||
AddOnManyToMany.removeLink(UserAuth.class, userId, "application", applicationId);
|
|
||||||
}
|
|
||||||
return DataAccess.get(UserAuth.class, userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{userId}/application/{applicationId}/rights")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
public Map<String, Object> getApplicationRight(
|
|
||||||
@Context final SecurityContext sc,
|
|
||||||
@PathParam("userId") final long userId,
|
|
||||||
@PathParam("applicationId") final long applicationId) throws Exception {
|
|
||||||
return RightResource.getUserRight(userId, applicationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PATCH
|
|
||||||
@Path("{userId}/application/{applicationId}/rights")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public Map<String, Object> patchApplicationRight(
|
|
||||||
@Context final SecurityContext sc,
|
|
||||||
@PathParam("userId") final long userId,
|
|
||||||
@PathParam("applicationId") final long applicationId,
|
|
||||||
final Map<String, Object> data) throws Exception {
|
|
||||||
this.LOGGER.info("Patch data from FRONT: {}", data);
|
|
||||||
RightResource.updateUserRight(userId, applicationId, data);
|
|
||||||
return RightResource.getUserRight(userId, applicationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: check this it might be deprecated ...
|
|
||||||
@POST
|
|
||||||
@Path("{id}/set_admin")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public void setAdmin(@Context final SecurityContext sc, @PathParam("id") final long userId, final boolean data)
|
|
||||||
throws Exception {
|
|
||||||
final UserAuth user = new UserAuth();
|
|
||||||
user.admin = data;
|
|
||||||
final int ret = DataAccess.update(user, userId, List.of("admin"));
|
|
||||||
if (ret == 0) {
|
|
||||||
throw new FailException(Response.Status.NOT_MODIFIED, "Fail to modify user as an admin.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("{id}/set_blocked")
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public void setBlocked(@Context final SecurityContext sc, @PathParam("id") final long userId, final boolean data)
|
|
||||||
throws Exception {
|
|
||||||
final UserAuth user = new UserAuth();
|
|
||||||
user.blocked = data;
|
|
||||||
final int ret = DataAccess.update(user, userId, List.of("blocked"));
|
|
||||||
if (ret == 0) {
|
|
||||||
throw new FailException(Response.Status.NOT_MODIFIED, "Fail to block the User.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@RolesAllowed("ADMIN")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public UserAuthGet create(final UserCreate user) throws Exception {
|
|
||||||
LOGGER.debug("create new User email={} login={}", user.email, user.login);
|
|
||||||
// verify login or email is correct:
|
|
||||||
if (user.login == null || user.login.length() < 6) {
|
|
||||||
throw new InputException("login", "Authentiocate-method-error (login too small: '" + user.login + "')");
|
|
||||||
}
|
|
||||||
// TODO: check login format
|
|
||||||
|
|
||||||
if (user.email == null || user.email.length() < 6) {
|
|
||||||
throw new InputException("email", "Authentiocate-method-error (email too small: '" + user.email + "')");
|
|
||||||
}
|
|
||||||
// TODO: check email format
|
|
||||||
|
|
||||||
if (user.password == null || user.password.length() != 128) {
|
|
||||||
throw new InputException("password", "null password, or wrong hash size");
|
|
||||||
}
|
|
||||||
// TODO: verify if the data are a hash ...
|
|
||||||
|
|
||||||
// Check login does not exist
|
|
||||||
List<UserAuth> out = DataAccess.getsWhere(UserAuth.class,
|
|
||||||
new Condition(new QueryCondition("login", "=", user.login)));
|
|
||||||
if (out.size() >= 1) {
|
|
||||||
throw new FailException(Response.Status.BAD_REQUEST, "Login already used !!!");
|
|
||||||
}
|
|
||||||
// Check email does not exist
|
|
||||||
out = DataAccess.getsWhere(UserAuth.class, new Condition(new QueryCondition("email", "=", user.email)));
|
|
||||||
if (out.size() >= 1) {
|
|
||||||
throw new FailException(Response.Status.BAD_REQUEST, "e-mail already used !!!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new user and return formated data.
|
|
||||||
final UserAuth newUser = new UserAuth();
|
|
||||||
newUser.admin = false;
|
|
||||||
newUser.removed = false;
|
|
||||||
newUser.blocked = false;
|
|
||||||
newUser.avatar = false;
|
|
||||||
newUser.login = user.login;
|
|
||||||
newUser.password = user.password;
|
|
||||||
newUser.email = user.email;
|
|
||||||
newUser.lastConnection = Timestamp.valueOf(LocalDateTime.now());
|
|
||||||
final UserAuth tmp = DataAccess.insert(newUser);
|
|
||||||
LOGGER.debug("create new user done with id=={}", tmp.id);
|
|
||||||
return DataAccess.get(UserAuthGet.class, tmp.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("me")
|
|
||||||
@RolesAllowed("USER")
|
|
||||||
public UserOut getMe(@Context final SecurityContext sc) {
|
|
||||||
LOGGER.debug("getMe()");
|
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
|
||||||
LOGGER.debug("== USER ? {}", gc.userByToken);
|
|
||||||
return new UserOut(gc.userByToken.id, gc.userByToken.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("password")
|
|
||||||
@RolesAllowed("USER")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public void changePassword(@Context final SecurityContext sc, final ChangePassword data) throws Exception {
|
|
||||||
LOGGER.debug("ChangePassword()");
|
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
|
||||||
LOGGER.debug("== USER ? {}", gc.userByToken);
|
|
||||||
|
|
||||||
if (data == null) {
|
|
||||||
throw new InputException("data", "No data set...");
|
|
||||||
}
|
|
||||||
if (data.newPassword == null || data.newPassword.length() != 128) {
|
|
||||||
throw new InputException("newPassword", "null password, or wrong hash size");
|
|
||||||
}
|
|
||||||
final UserAuth user = checkAuthUser(data.method, data.login, data.time, data.password);
|
|
||||||
if (user == null) {
|
|
||||||
throw new SystemException("Fail to retrieve the user... (impossible case)");
|
|
||||||
}
|
|
||||||
// Process the update:
|
|
||||||
user.password = data.newPassword;
|
|
||||||
DataAccess.update(user, user.id, List.of("password"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("is_login_exist")
|
|
||||||
@PermitAll
|
|
||||||
public Boolean isLoginExist(@QueryParam("login") final String login) throws Exception {
|
|
||||||
LOGGER.debug("checkLogin: '{}'", login);
|
|
||||||
final List<UserAuth> out = DataAccess.getsWhere(UserAuth.class,
|
|
||||||
new Condition(new QueryCondition("login", "=", login)));
|
|
||||||
return out.size() >= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: add an application TOKEN and permit only 50 requested (maybe add an option to disable it).
|
|
||||||
@GET
|
|
||||||
@Path("is_email_exist")
|
|
||||||
@PermitAll
|
|
||||||
public Boolean isEmailExist(@QueryParam("email") final String email) throws Exception {
|
|
||||||
LOGGER.debug("checkEmail: {}", email);
|
|
||||||
final List<UserAuth> out = DataAccess.getsWhere(UserAuth.class,
|
|
||||||
new Condition(new QueryCondition("email", "=", email)));
|
|
||||||
return out.size() >= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private UserAuth checkAuthUser(final String method, final String login, final String time, final String password)
|
|
||||||
throws Exception {
|
|
||||||
// check good version:
|
|
||||||
if (!"v1".contentEquals(method)) {
|
|
||||||
throw new InputException("method", "Authentiocate-method-error (wrong version: '" + method + "')");
|
|
||||||
}
|
|
||||||
// verify login or email is correct:
|
|
||||||
if (login.length() < 6) {
|
|
||||||
throw new InputException("login", "Authentiocate-method-error (email or login too small: '" + login + "')");
|
|
||||||
}
|
|
||||||
if (password == null || password.length() != 128) {
|
|
||||||
throw new InputException("password", "null password, or wrong hash size");
|
|
||||||
}
|
|
||||||
// email or login?
|
|
||||||
String query = "login";
|
|
||||||
if (login.contains("@")) {
|
|
||||||
query = "email";
|
|
||||||
}
|
|
||||||
final UserAuth user = DataAccess.getWhere(UserAuth.class, new Condition(new QueryCondition(query, "=", login)));
|
|
||||||
|
|
||||||
if (user == null) {
|
|
||||||
throw new FailException(Response.Status.PRECONDITION_FAILED,
|
|
||||||
"FAIL Authentiocate-wrong email/login '" + login + "')");
|
|
||||||
}
|
|
||||||
// Check the password:
|
|
||||||
final String passwordCheck = getSHA512(
|
|
||||||
"login='" + login + "';pass='" + user.password + "';date='" + time + "'");
|
|
||||||
if (!passwordCheck.contentEquals(password)) {
|
|
||||||
throw new FailException(Response.Status.PRECONDITION_FAILED, "Password error ...");
|
|
||||||
}
|
|
||||||
LOGGER.debug(" ==> pass nearly all test : admin={} blocked={} removed={}", user.admin, user.blocked,
|
|
||||||
user.removed);
|
|
||||||
if (user.blocked || user.removed) {
|
|
||||||
throw new FailException(Response.Status.UNAUTHORIZED, "FAIL Authentiocate");
|
|
||||||
}
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("get_token")
|
|
||||||
@PermitAll
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public GetToken getToken(final DataGetToken data) throws Exception {
|
|
||||||
LOGGER.info("User Authenticate: {}", data.login());
|
|
||||||
final UserAuth user = checkAuthUser(data.method(), data.login(), data.time(), data.password());
|
|
||||||
// at the point the user has been not deleted and not blocked.
|
|
||||||
// this authentication is valid only for Karso ==> not for the application
|
|
||||||
final int expirationTimeInMinutes = ConfigVariable.getAuthExpirationTime();
|
|
||||||
|
|
||||||
// Get the USER Right (Note: by construction KARSO have application ID = KARSO_INITIALISATION_ID
|
|
||||||
final Map<String, Object> ssoRight = RightResource.getUserRight(user.id,
|
|
||||||
Initialization.KARSO_INITIALISATION_ID);
|
|
||||||
if (!ssoRight.containsKey("USER")) {
|
|
||||||
// If the USER is not override, the system add by default USER
|
|
||||||
ssoRight.put("USER", true);
|
|
||||||
}
|
|
||||||
LOGGER.debug("Get new token with right: {}", ssoRight);
|
|
||||||
final Map<String, Object> outRight = new HashMap<>();
|
|
||||||
final String applicationName = "karso";
|
|
||||||
// we set the right in the under map to manage multiple application group right. and in some application user can see other user or all user of the application
|
|
||||||
outRight.put(applicationName, ssoRight);
|
|
||||||
// TODO: maybe correct this get of TTL...
|
|
||||||
final String ret = JWTWrapper.generateJWToken(user.id, user.login, "KarAuth", applicationName, outRight,
|
|
||||||
expirationTimeInMinutes);
|
|
||||||
if (ret == null) {
|
|
||||||
throw new SystemException("Missing internal JWT system ==> can not sign anything ...");
|
|
||||||
}
|
|
||||||
// Update last connection:
|
|
||||||
final UserAuth newUser = new UserAuth();
|
|
||||||
newUser.lastConnection = Timestamp.valueOf(LocalDateTime.now());
|
|
||||||
DataAccess.update(newUser, user.id, List.of("lastConnection"));
|
|
||||||
|
|
||||||
//LOGGER.debug(" ==> generate token: {}", ret);
|
|
||||||
return new GetToken(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String bytesToHex(final byte[] bytes) {
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
|
||||||
for (final byte b : bytes) {
|
|
||||||
sb.append(String.format("%02x", b));
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSHA512(final String passwordToHash) {
|
|
||||||
try {
|
|
||||||
final MessageDigest md = MessageDigest.getInstance("SHA-512");
|
|
||||||
final byte[] bytes = md.digest(passwordToHash.getBytes(StandardCharsets.UTF_8));
|
|
||||||
return bytesToHex(bytes);
|
|
||||||
} catch (final NoSuchAlgorithmException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
package org.kar.karso.filter;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
|
||||||
import org.kar.archidata.filter.AuthenticationFilter;
|
|
||||||
import org.kar.archidata.model.UserByToken;
|
|
||||||
import org.kar.karso.model.ApplicationToken;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import jakarta.annotation.Priority;
|
|
||||||
import jakarta.ws.rs.Priorities;
|
|
||||||
import jakarta.ws.rs.ext.Provider;
|
|
||||||
|
|
||||||
//@PreMatching
|
|
||||||
@Provider
|
|
||||||
@Priority(Priorities.AUTHENTICATION)
|
|
||||||
public class KarsoAuthenticationFilter extends AuthenticationFilter {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(KarsoAuthenticationFilter.class);
|
|
||||||
|
|
||||||
//curl http://0.0.0.0:15080/karso/api/public_key/pem --output plop.txt -H "Authorization: Zota 1:U0sJM1m@-STSdfg4365fJOFUGbR4kFycBu1qGZPwf7gW6k2WWRBzTPUH7QutCgPw-SDss45_563sSDFdfg@dsf@456" --verbose
|
|
||||||
|
|
||||||
public KarsoAuthenticationFilter() {
|
|
||||||
super("karso");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected UserByToken validateToken(final String authorization) throws Exception {
|
|
||||||
if (authorization == null || authorization.length() < 25) {
|
|
||||||
System.out.println("Application authentication too short '" + authorization + "'");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final String[] elems = authorization.split(":");
|
|
||||||
if (elems.length != 2) {
|
|
||||||
System.out.println("Application authentication split error '" + authorization + "'");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final Long indexToken = Long.parseLong(elems[0]);
|
|
||||||
|
|
||||||
final ApplicationToken value = DataAccess.get(ApplicationToken.class, indexToken);
|
|
||||||
if (value == null) {
|
|
||||||
System.out.println("Application authentication can not find id '" + authorization + "'");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// TODO: hash the sent token
|
|
||||||
if (!value.token.equals(elems[1])) {
|
|
||||||
System.out.println("Application authentication mismatch '" + authorization + "'");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// TODO: check UTC !!!
|
|
||||||
if (!value.endValidityTime.after(Timestamp.from(Instant.now()))) {
|
|
||||||
System.out.println("Application authentication Time-out '" + authorization + "' " + value.endValidityTime
|
|
||||||
+ " > " + Timestamp.from(Instant.now()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// ----------------------------------
|
|
||||||
// -- All is good !!!
|
|
||||||
// ----------------------------------
|
|
||||||
// We are in transition phase the user element will be removed
|
|
||||||
final UserByToken userByToken = new UserByToken();
|
|
||||||
userByToken.id = value.id;
|
|
||||||
userByToken.name = value.name;
|
|
||||||
userByToken.parentId = value.parentId;
|
|
||||||
userByToken.type = UserByToken.TYPE_APPLICATION;
|
|
||||||
userByToken.right.put("APPLICATION", true);
|
|
||||||
return userByToken;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,117 +0,0 @@
|
|||||||
package org.kar.karso.migration;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
|
||||||
import org.kar.archidata.tools.UuidUtils;
|
|
||||||
import org.kar.karso.model.Application;
|
|
||||||
import org.kar.karso.model.ApplicationToken;
|
|
||||||
import org.kar.karso.model.Right;
|
|
||||||
import org.kar.karso.model.RightDescription;
|
|
||||||
import org.kar.karso.model.Settings;
|
|
||||||
import org.kar.karso.model.UserAuth;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class Initialization extends MigrationSqlStep {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Initialization.class);
|
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
|
||||||
|
|
||||||
public static final List<Class<?>> LIST_OF_COMMON_CLASSES = List.of(Settings.class, UserAuth.class,
|
|
||||||
Application.class, ApplicationToken.class, RightDescription.class, Right.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Initialization";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Initialization() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateStep() throws Exception {
|
|
||||||
for (final Class<?> clazz : LIST_OF_COMMON_CLASSES) {
|
|
||||||
addClass(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
addAction(
|
|
||||||
"""
|
|
||||||
INSERT INTO `application` (`id`, `name`, `description`, `redirect`, `redirectDev`, `notification`, `ttl`) VALUES
|
|
||||||
(1, 'karso', 'Root SSO interface', 'http://atria-soft/karso', '', '', 666);
|
|
||||||
""");
|
|
||||||
// default admin: "karadmin" password: "adminA@666"
|
|
||||||
addAction(
|
|
||||||
"""
|
|
||||||
INSERT INTO `user` (`id`, `login`, `password`, `email`, `admin`) VALUES
|
|
||||||
(1, 'karadmin', '0ddcac5ede3f1300a1ce5948ab15112f2810130531d578ab8bc4dc131652d7cf7a3ff6e827eb957bff43bc2c65a6a1d46722e5b3a2343ac3176a33ea7250080b',
|
|
||||||
'admin@admin.ZZZ', 1);
|
|
||||||
""");
|
|
||||||
final String data = UuidUtils.nextUUID().toString();
|
|
||||||
addAction("""
|
|
||||||
INSERT INTO `user_link_application` (`uuid`, `object1Id`, `object2Id`)
|
|
||||||
VALUES (UUID_TO_BIN('%s'), '1', '1');
|
|
||||||
""".formatted(data), "mysql");
|
|
||||||
addAction("""
|
|
||||||
INSERT INTO `user_link_application` (`uuid`, `object1Id`, `object2Id`)
|
|
||||||
VALUES ('%s', '1', '1');
|
|
||||||
""".formatted(data), "sqlite");
|
|
||||||
addAction("""
|
|
||||||
INSERT INTO `settings` (`key`, `right`, `type`, `value`) VALUES
|
|
||||||
('SIGN_UP_ENABLE', 'rwr-r-', 'BOOLEAN', 'false'),
|
|
||||||
('SIGN_IN_ENABLE', 'rwr-r-', 'BOOLEAN', 'true'),
|
|
||||||
('SIGN_UP_FILTER', 'rw----', 'STRING', '.*'),
|
|
||||||
('EMAIL_VALIDATION_REQUIRED', 'rwr-r-', 'BOOLEAN', 'false');
|
|
||||||
""");
|
|
||||||
addAction(
|
|
||||||
"""
|
|
||||||
INSERT INTO `rightDescription` (`id`, `applicationId`, `key`, `title`, `description`, `type`, `defaultValue`) VALUES
|
|
||||||
(1, 1, 'ADMIN', 'Administrator', 'Full administrator Right', 'BOOLEAN', 'false');
|
|
||||||
""");
|
|
||||||
addAction("""
|
|
||||||
INSERT INTO `right` (`applicationId`, `userId`, `rightDescriptionId`, `value`) VALUES
|
|
||||||
(1, 1, 1, 'true');
|
|
||||||
""");
|
|
||||||
// we generate an offset to permit to manage some generic upgrade in the future... (can not be done in sqlite)
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `application` AUTO_INCREMENT = 1000;
|
|
||||||
""", "mysql");
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `user` AUTO_INCREMENT = 1000;
|
|
||||||
""", "mysql");
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `settings` AUTO_INCREMENT = 1000;
|
|
||||||
""", "mysql");
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `right` AUTO_INCREMENT = 1000;
|
|
||||||
""", "mysql");
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `rightDescription` AUTO_INCREMENT = 1000;
|
|
||||||
""", "mysql");
|
|
||||||
display();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void dropAll() {
|
|
||||||
for (final Class<?> element : LIST_OF_COMMON_CLASSES) {
|
|
||||||
try {
|
|
||||||
DataAccess.drop(element);
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
LOGGER.error("Fail to drop table !!!!!!");
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void cleanAll() {
|
|
||||||
for (final Class<?> element : LIST_OF_COMMON_CLASSES) {
|
|
||||||
try {
|
|
||||||
DataAccess.cleanAll(element);
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
LOGGER.error("Fail to clean table !!!!!!");
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package org.kar.karso.migration;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
|
||||||
|
|
||||||
public class Migration20231015 extends MigrationSqlStep {
|
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "refactor creation and update time";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Migration20231015() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateStep() {
|
|
||||||
|
|
||||||
for (final String elem : List.of("application", "applicationToken", "right", "rightDescription", "settings",
|
|
||||||
"user", "user_link_application")) { //, "user_link_cover")) {
|
|
||||||
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `""" + elem + """
|
|
||||||
`
|
|
||||||
RENAME COLUMN `create_date` TO `createdAt`,
|
|
||||||
RENAME COLUMN `modify_date` TO `updatedAt`;
|
|
||||||
""");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,149 +0,0 @@
|
|||||||
package org.kar.karso.migration;
|
|
||||||
|
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
|
||||||
|
|
||||||
public class Migration20231126 extends MigrationSqlStep {
|
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "migration-2023-11-26: reorder the migration for the new API of archidata";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Migration20231126() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateStep() {
|
|
||||||
// update migration update (last one)
|
|
||||||
addAction(
|
|
||||||
"""
|
|
||||||
ALTER TABLE `KAR_migration`
|
|
||||||
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
||||||
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
||||||
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
||||||
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
||||||
ADD `version` int NOT NULL DEFAULT '2' AFTER `deleted`,
|
|
||||||
CHANGE `name` `name` varchar(256) COLLATE 'utf8mb4_0900_ai_ci' NULL COMMENT 'Name of the migration' AFTER `version`,
|
|
||||||
CHANGE `terminated` `terminated` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'if the migration is well terminated or not' AFTER `name`,
|
|
||||||
CHANGE `stepId` `stepId` int NULL COMMENT 'index in the migration progression' AFTER `terminated`,
|
|
||||||
CHANGE `count` `count` int NULL COMMENT 'number of element in the migration' AFTER `stepId`,
|
|
||||||
CHANGE `log` `log` text COLLATE 'utf8mb3_general_ci' NULL COMMENT 'Log generate by the migration' AFTER `count`;
|
|
||||||
""");
|
|
||||||
|
|
||||||
addAction(
|
|
||||||
"""
|
|
||||||
ALTER TABLE `application`
|
|
||||||
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
||||||
CHANGE `createdAt` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
||||||
CHANGE `updatedAt` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
||||||
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
||||||
CHANGE `name` `name` varchar(256) COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `deleted`,
|
|
||||||
CHANGE `description` `description` varchar(2048) COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `name`,
|
|
||||||
CHANGE `redirect` `redirect` varchar(2048) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL AFTER `description`,
|
|
||||||
CHANGE `redirectDev` `redirectDev` varchar(2048) COLLATE 'utf8mb4_0900_ai_ci' NULL DEFAULT 'http://localhost:4200/sso/' AFTER `redirect`,
|
|
||||||
CHANGE `notification` `notification` varchar(2048) COLLATE 'utf8mb4_0900_ai_ci' NULL DEFAULT 'http://localhost:4200/sso/notification' AFTER `redirectDev`,
|
|
||||||
CHANGE `ttl` `ttl` int NOT NULL DEFAULT '666' COMMENT 'Expiration time ' AFTER `notification`,
|
|
||||||
CHANGE `manageRight` `manageRight` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Right is manage with Karso' AFTER `ttl`;
|
|
||||||
""");
|
|
||||||
addAction(
|
|
||||||
"""
|
|
||||||
ALTER TABLE `applicationToken`
|
|
||||||
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
||||||
CHANGE `createdAt` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
||||||
CHANGE `updatedAt` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
||||||
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
||||||
CHANGE `parentId` `parentId` bigint NOT NULL AFTER `deleted`,
|
|
||||||
CHANGE `name` `name` text COLLATE 'utf8mb3_general_ci' NOT NULL AFTER `parentId`,
|
|
||||||
CHANGE `endValidityTime` `endValidityTime` timestamp(3) NOT NULL AFTER `name`,
|
|
||||||
CHANGE `token` `token` text COLLATE 'utf8mb3_general_ci' NOT NULL AFTER `endValidityTime`;
|
|
||||||
""");
|
|
||||||
|
|
||||||
addAction(
|
|
||||||
"""
|
|
||||||
ALTER TABLE `right`
|
|
||||||
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
||||||
CHANGE `createdAt` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
||||||
CHANGE `updatedAt` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
||||||
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
||||||
CHANGE `applicationId` `applicationId` bigint NOT NULL COMMENT 'application-ID that have the reference of the right' AFTER `deleted`,
|
|
||||||
CHANGE `userId` `userId` bigint NOT NULL COMMENT 'user-ID ' AFTER `applicationId`,
|
|
||||||
CHANGE `rightDescriptionId` `rightDescriptionId` bigint NOT NULL COMMENT 'rightDescription-ID of the right description' AFTER `userId`,
|
|
||||||
CHANGE `value` `value` varchar(1024) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL COMMENT 'Value of the right' AFTER `rightDescriptionId`;
|
|
||||||
""");
|
|
||||||
|
|
||||||
addAction(
|
|
||||||
"""
|
|
||||||
ALTER TABLE `rightDescription`
|
|
||||||
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
||||||
CHANGE `createdAt` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
||||||
CHANGE `updatedAt` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
||||||
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
||||||
CHANGE `applicationId` `applicationId` bigint NOT NULL COMMENT 'Application id that have the reference of the right' AFTER `deleted`,
|
|
||||||
CHANGE `key` `key` varchar(64) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL COMMENT 'Key of the property' AFTER `applicationId`,
|
|
||||||
CHANGE `title` `title` varchar(1024) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL COMMENT 'Title of the right' AFTER `key`,
|
|
||||||
CHANGE `description` `description` varchar(1024) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL COMMENT 'Description of the right' AFTER `title`,
|
|
||||||
CHANGE `defaultValue` `defaultValue` varchar(1024) COLLATE 'utf8mb4_0900_ai_ci' NULL COMMENT 'default value if Never set' AFTER `description`,
|
|
||||||
CHANGE `type` `type` varchar(16) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL DEFAULT 'BOOLEAN' COMMENT 'Type of the property' AFTER `defaultValue`;
|
|
||||||
""");
|
|
||||||
|
|
||||||
addAction(
|
|
||||||
"""
|
|
||||||
ALTER TABLE `settings`
|
|
||||||
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
||||||
CHANGE `createdAt` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
||||||
CHANGE `updatedAt` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
||||||
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
||||||
CHANGE `key` `key` varchar(512) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL AFTER `deleted`,
|
|
||||||
CHANGE `right` `right` varchar(6) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL DEFAULT 'rw----' COMMENT 'Right for the specific element(ADMIN [rw] USER [rw] other [rw])' AFTER `key`,
|
|
||||||
CHANGE `type` `type` varchar(10) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL COMMENT 'Type Of the data' AFTER `right`,
|
|
||||||
CHANGE `value` `value` text COLLATE 'utf8mb3_general_ci' NOT NULL COMMENT 'Value of the configuration' AFTER `type`;
|
|
||||||
""");
|
|
||||||
|
|
||||||
addAction(
|
|
||||||
"""
|
|
||||||
ALTER TABLE `user`
|
|
||||||
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
||||||
CHANGE `createdAt` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
||||||
CHANGE `updatedAt` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
||||||
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
||||||
CHANGE `login` `login` varchar(128) COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `deleted`,
|
|
||||||
CHANGE `lastConnection` `lastConnection` timestamp(3) NULL AFTER `login`,
|
|
||||||
CHANGE `admin` `admin` tinyint(1) NOT NULL DEFAULT '0' AFTER `lastConnection`,
|
|
||||||
CHANGE `blocked` `blocked` tinyint(1) NOT NULL DEFAULT '0' AFTER `admin`,
|
|
||||||
CHANGE `removed` `removed` tinyint(1) NOT NULL DEFAULT '0' AFTER `blocked`,
|
|
||||||
CHANGE `password` `password` varchar(128) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL AFTER `removed`,
|
|
||||||
CHANGE `email` `email` varchar(512) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL AFTER `password`,
|
|
||||||
CHANGE `emailValidate` `emailValidate` timestamp(3) NULL AFTER `email`,
|
|
||||||
CHANGE `newEmail` `newEmail` varchar(512) COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `emailValidate`,
|
|
||||||
CHANGE `avatar` `avatar` tinyint(1) NOT NULL DEFAULT '0' AFTER `newEmail`;
|
|
||||||
""");
|
|
||||||
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `user_link_application`
|
|
||||||
CHANGE `createdAt` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `id`,
|
|
||||||
CHANGE `updatedAt` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `createdAt`,
|
|
||||||
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' AFTER `updatedAt`,
|
|
||||||
CHANGE `user_id` `object1id` bigint NOT NULL AFTER `deleted`,
|
|
||||||
CHANGE `application_id` `object2id` bigint NOT NULL AFTER `object1id`,
|
|
||||||
ADD FOREIGN KEY (`object1id`) REFERENCES `user` (`id`);
|
|
||||||
""");
|
|
||||||
|
|
||||||
addAction(
|
|
||||||
"""
|
|
||||||
CREATE TABLE `user_link_cover` (
|
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'Primary key of the base' ,
|
|
||||||
`createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' ,
|
|
||||||
`updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'When update the object' ,
|
|
||||||
`deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' ,
|
|
||||||
`object1Id` bigint NOT NULL COMMENT 'Object reference 1' ,
|
|
||||||
`object2Id` bigint NOT NULL COMMENT 'Object reference 2' ,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
""");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
package org.kar.karso.migration;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
|
||||||
import org.kar.archidata.dataAccess.options.AccessDeletedItems;
|
|
||||||
import org.kar.archidata.dataAccess.options.OverrideTableName;
|
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
|
||||||
import org.kar.archidata.tools.UuidUtils;
|
|
||||||
import org.kar.karso.migration.model.UUIDConversion;
|
|
||||||
|
|
||||||
public class Migration20240515 extends MigrationSqlStep {
|
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "migration-2024-05-15: Update the link user application and the cover";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Migration20240515() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateStep() {
|
|
||||||
// update migration update (last one)
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `user_link_application` ADD `uuid` binary(16) AFTER `id`;
|
|
||||||
""");
|
|
||||||
addAction(() -> {
|
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(),
|
|
||||||
new OverrideTableName("user_link_application"));
|
|
||||||
for (final UUIDConversion elem : datas) {
|
|
||||||
elem.uuid = UuidUtils.nextUUID();
|
|
||||||
}
|
|
||||||
for (final UUIDConversion elem : datas) {
|
|
||||||
DataAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("user_link_application"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `user_link_application`
|
|
||||||
CHANGE `id` `id` bigint;
|
|
||||||
""");
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `user_link_application` DROP PRIMARY KEY;
|
|
||||||
""");
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `user_link_application`
|
|
||||||
CHANGE `uuid` `uuid` binary(16) DEFAULT (UUID_TO_BIN(UUID(), TRUE));
|
|
||||||
""");
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `user_link_application`
|
|
||||||
ADD PRIMARY KEY `uuid` (`uuid`);
|
|
||||||
""");
|
|
||||||
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `user_link_application`
|
|
||||||
DROP `id`;
|
|
||||||
""");
|
|
||||||
|
|
||||||
addAction("""
|
|
||||||
DROP TABLE `user_link_cover`;
|
|
||||||
""");
|
|
||||||
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `user`
|
|
||||||
ADD `covers` json DEFAULT NULL COMMENT 'List of Id of the specific covers' AFTER `removed`;
|
|
||||||
""");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package org.kar.karso.migration.model;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import jakarta.persistence.Id;
|
|
||||||
|
|
||||||
public class UUIDConversion {
|
|
||||||
@Id
|
|
||||||
public Long id = null;
|
|
||||||
public UUID uuid = null;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class AddUserData {
|
|
||||||
public Long userId;
|
|
||||||
|
|
||||||
public AddUserData() {}
|
|
||||||
|
|
||||||
public AddUserData(final long userId) {
|
|
||||||
this.userId = userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
CREATE TABLE `application` (
|
|
||||||
`id` bigint NOT NULL COMMENT 'Unique ID of the application' AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
`description` text COMMENT 'description of the application',
|
|
||||||
`token` varchar(128) COLLATE 'latin1_bin' NOT NULL COMMENT 'Token (can be not unique)'
|
|
||||||
) AUTO_INCREMENT=10;
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataComment;
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
import jakarta.ws.rs.DefaultValue;
|
|
||||||
|
|
||||||
@Table(name = "application")
|
|
||||||
@DataIfNotExists
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class Application extends GenericDataSoftDelete {
|
|
||||||
@Column(length = 256)
|
|
||||||
public String name;
|
|
||||||
@Column(length = 2048)
|
|
||||||
public String description;
|
|
||||||
@Column(length = 2048, nullable = false)
|
|
||||||
public String redirect;
|
|
||||||
@Column(length = 2048)
|
|
||||||
@DefaultValue("'http://localhost:4200/sso/'")
|
|
||||||
public String redirectDev;
|
|
||||||
@Column(length = 2048)
|
|
||||||
@DefaultValue("'http://localhost:4200/sso/notification'")
|
|
||||||
public String notification;
|
|
||||||
@Column(nullable = false)
|
|
||||||
@DataComment("Expiration time ")
|
|
||||||
@DefaultValue("666")
|
|
||||||
public Integer ttl;
|
|
||||||
@Column(nullable = false)
|
|
||||||
@DataComment("Right is manage with Karso")
|
|
||||||
@DefaultValue("0")
|
|
||||||
public Boolean manageRight;
|
|
||||||
|
|
||||||
public Application() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Application{" + "id=" + this.id + ", description='" + this.description + '\'' + ", redirect='"
|
|
||||||
+ this.redirect + '\'' + ", redirectDev='" + this.redirectDev + '\'' + ", notification='"
|
|
||||||
+ this.notification + '\'' + ", ttl='" + this.ttl + '\'' + '}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class ApplicationSmall {
|
|
||||||
public Long id;
|
|
||||||
public String name;
|
|
||||||
public String description;
|
|
||||||
public String redirect;
|
|
||||||
|
|
||||||
public ApplicationSmall() {}
|
|
||||||
|
|
||||||
public ApplicationSmall(final Long id, final String name, final String description, final String redirect) {
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
this.description = description;
|
|
||||||
this.redirect = redirect;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
|
||||||
import org.kar.archidata.model.GenericToken;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
|
|
||||||
@Table(name = "applicationToken")
|
|
||||||
@DataIfNotExists
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class ApplicationToken extends GenericToken {
|
|
||||||
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class ChangePassword {
|
|
||||||
@Column(length = 32)
|
|
||||||
public String method;
|
|
||||||
@Column(length = 512)
|
|
||||||
public String login;
|
|
||||||
@Column(length = 64)
|
|
||||||
public String time;
|
|
||||||
@Column(length = 128)
|
|
||||||
public String password;
|
|
||||||
@Column(length = 128)
|
|
||||||
public String newPassword;
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class ClientToken {
|
|
||||||
@Column(length = 1024)
|
|
||||||
public String url;
|
|
||||||
@Column(length = 0)
|
|
||||||
public String jwt;
|
|
||||||
|
|
||||||
public ClientToken() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientToken(final String url, final String jwt) {
|
|
||||||
this.url = url;
|
|
||||||
this.jwt = jwt;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class CreateTokenRequest {
|
|
||||||
public CreateTokenRequest() {}
|
|
||||||
|
|
||||||
public CreateTokenRequest(final String name, final Integer validity) {
|
|
||||||
this.name = name;
|
|
||||||
this.validity = validity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String name;
|
|
||||||
public Integer validity;
|
|
||||||
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public record DataGetToken(
|
|
||||||
String login,
|
|
||||||
String method,
|
|
||||||
String time,
|
|
||||||
String password) {
|
|
||||||
|
|
||||||
/*public DataGetToken(String login, String method,
|
|
||||||
String time,
|
|
||||||
String password) {
|
|
||||||
this(login, method, time, password);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public static String sha512(final String passwordToHash) { //, String salt){
|
|
||||||
String generatedPassword = null;
|
|
||||||
try {
|
|
||||||
final MessageDigest md = MessageDigest.getInstance("SHA-512");
|
|
||||||
//md.update(salt.getBytes(StandardCharsets.UTF_8));
|
|
||||||
final byte[] bytes = md.digest(passwordToHash.getBytes(StandardCharsets.UTF_8));
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
|
||||||
for (final byte element : bytes) {
|
|
||||||
sb.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1));
|
|
||||||
}
|
|
||||||
generatedPassword = sb.toString();
|
|
||||||
} catch (final NoSuchAlgorithmException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return generatedPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DataGetToken generate(
|
|
||||||
final String login,
|
|
||||||
final String method,
|
|
||||||
final String time,
|
|
||||||
final String password) {
|
|
||||||
return generateSha(login, method, time, sha512(password));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DataGetToken generateSha(
|
|
||||||
final String login,
|
|
||||||
final String method,
|
|
||||||
final String time,
|
|
||||||
final String password) {
|
|
||||||
return new DataGetToken(login, method, time,
|
|
||||||
sha512("login='" + login + "';pass='" + password + "';date='" + time + "'"));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class DataGetTokenApplication {
|
|
||||||
public String application;
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.FetchType;
|
|
||||||
import jakarta.persistence.ManyToOne;
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
|
|
||||||
@Table(name = "right")
|
|
||||||
@DataIfNotExists
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class Right extends GenericDataSoftDelete {
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
@Schema(description = "application-ID that have the reference of the right")
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Application.class)
|
|
||||||
public Long applicationId;
|
|
||||||
@Column(nullable = false)
|
|
||||||
@Schema(description = "user-ID ")
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = UserAuth.class)
|
|
||||||
public Long userId;
|
|
||||||
@Column(nullable = false)
|
|
||||||
@Schema(description = "rightDescription-ID of the right description")
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = RightDescription.class)
|
|
||||||
public Long rightDescriptionId;
|
|
||||||
@Column(length = 1024, nullable = false)
|
|
||||||
@Schema(description = "Value of the right")
|
|
||||||
public String value;
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.FetchType;
|
|
||||||
import jakarta.persistence.ManyToOne;
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
import jakarta.ws.rs.DefaultValue;
|
|
||||||
|
|
||||||
@Table(name = "rightDescription")
|
|
||||||
@DataIfNotExists
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class RightDescription extends GenericDataSoftDelete {
|
|
||||||
@Column(nullable = false)
|
|
||||||
@Schema(description = "Application id that have the reference of the right")
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Application.class)
|
|
||||||
public Long applicationId;
|
|
||||||
@Column(length = 64, nullable = false)
|
|
||||||
@Schema(description = "Key of the property")
|
|
||||||
public String key;
|
|
||||||
@Column(length = 1024, nullable = false)
|
|
||||||
@Schema(description = "Title of the right")
|
|
||||||
public String title;
|
|
||||||
@Column(length = 1024, nullable = false)
|
|
||||||
@Schema(description = "Description of the right")
|
|
||||||
public String description;
|
|
||||||
@Column(length = 1024)
|
|
||||||
@Schema(description = "default value if Never set")
|
|
||||||
public String defaultValue;
|
|
||||||
@Column(length = 16, nullable = false)
|
|
||||||
@Schema(description = "Type of the property")
|
|
||||||
@DefaultValue("\"BOOLEAN\"")
|
|
||||||
public String type = "BOOLEAN"; // this is a place-holder (current type supported BOOLEAN)
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
import jakarta.ws.rs.DefaultValue;
|
|
||||||
|
|
||||||
enum PropertyType {
|
|
||||||
STRING, NUMBER, BOOLEAN,
|
|
||||||
}
|
|
||||||
|
|
||||||
@Table(name = "settings")
|
|
||||||
@DataIfNotExists
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class Settings extends GenericDataSoftDelete {
|
|
||||||
@Column(length = 512, nullable = false)
|
|
||||||
public String key;
|
|
||||||
@Schema(description = "Right for the specific element(ADMIN [rw] USER [rw] other [rw])")
|
|
||||||
@Column(length = 6, nullable = false)
|
|
||||||
@DefaultValue("\"rw----\"")
|
|
||||||
public String right;
|
|
||||||
@Schema(description = "Type Of the data")
|
|
||||||
@Column(length = 10, nullable = false)
|
|
||||||
public String type;
|
|
||||||
@Schema(description = "Value of the configuration")
|
|
||||||
@Column(nullable = false)
|
|
||||||
public String value;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Settings [key=" + this.key + ", value=" + this.value + ", id=" + this.id + ", deleted=" + this.deleted
|
|
||||||
+ "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
|
||||||
import org.kar.archidata.model.User;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.ManyToMany;
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
import jakarta.ws.rs.DefaultValue;
|
|
||||||
|
|
||||||
@Table(name = "user")
|
|
||||||
@DataIfNotExists
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class UserAuth extends User {
|
|
||||||
@Column(length = 128, nullable = false)
|
|
||||||
public String password;
|
|
||||||
/*
|
|
||||||
@Column(length = 128)
|
|
||||||
public String passwordChange; //!< When change a password, the new password is set in temporary area and wait the email validation
|
|
||||||
@Column(length = 128)
|
|
||||||
public String passwordValidation; //!< UniqueId to validate the new password
|
|
||||||
*/
|
|
||||||
@Column(length = 512, nullable = false)
|
|
||||||
public String email;
|
|
||||||
public Timestamp emailValidate; // time of validation
|
|
||||||
@Column(length = 512)
|
|
||||||
public String newEmail;
|
|
||||||
@DefaultValue("'0'")
|
|
||||||
@Column(nullable = false)
|
|
||||||
public Boolean avatar = false;
|
|
||||||
@Schema(description = "List of accessible application (if not set the application is not available)")
|
|
||||||
@ManyToMany(targetEntity = Application.class)
|
|
||||||
public List<Long> applications = null;
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
|
||||||
import org.kar.archidata.model.User;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
import jakarta.ws.rs.DefaultValue;
|
|
||||||
|
|
||||||
@Table(name = "user")
|
|
||||||
@DataIfNotExists
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class UserAuthGet extends User {
|
|
||||||
@Column(length = 512, nullable = false)
|
|
||||||
public String email;
|
|
||||||
@DefaultValue("'0'")
|
|
||||||
@Column(nullable = false)
|
|
||||||
public Boolean avatar = false;
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class UserCreate {
|
|
||||||
public String login;
|
|
||||||
public String email;
|
|
||||||
public String password;
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package org.kar.karso.model;
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
CREATE TABLE `application` (
|
|
||||||
`id` bigint NOT NULL COMMENT 'Unique ID of the application' AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
`description` text COMMENT 'description of the application',
|
|
||||||
`token` varchar(128) COLLATE 'latin1_bin' NOT NULL COMMENT 'Token (can be not unique)'
|
|
||||||
) AUTO_INCREMENT=10;
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
|
||||||
import org.kar.archidata.model.UUIDGenericDataSoftDelete;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
|
|
||||||
// TODO: remove this, it must be generated instead of manually create ///
|
|
||||||
@Table(name = "user_link_application")
|
|
||||||
@DataIfNotExists
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class UserLinkApplication extends UUIDGenericDataSoftDelete {
|
|
||||||
@Column(name = "object1id")
|
|
||||||
public Long userId;
|
|
||||||
@Column(name = "object2id")
|
|
||||||
public Long applicationId;
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package org.kar.karso.old;
|
|
||||||
|
|
||||||
public class Group {
|
|
||||||
// Unique ID of the group
|
|
||||||
public long id;
|
|
||||||
// Unique ID of the parent group
|
|
||||||
public long parentGroupId = -1;
|
|
||||||
// Name of the group (Must be unique)
|
|
||||||
public String groupName;
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package org.kar.karso.old;
|
|
||||||
|
|
||||||
public class Package {
|
|
||||||
// Unique ID of the package/module
|
|
||||||
public long id;
|
|
||||||
// name of the package
|
|
||||||
public String name;
|
|
||||||
// version of the package
|
|
||||||
public String version;
|
|
||||||
// current coverage of the package
|
|
||||||
public double coverage;
|
|
||||||
// have module deployed
|
|
||||||
public long refBinary;
|
|
||||||
// have test deployed
|
|
||||||
public long refTest;
|
|
||||||
// have source deployed
|
|
||||||
public long refSource;
|
|
||||||
// have java-doc deployed
|
|
||||||
public long refJavaDoc;
|
|
||||||
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package org.kar.karso.util;
|
|
||||||
|
|
||||||
public class ConfigVariable {
|
|
||||||
public static String BASE_NAME = "ORG_KARAUTH_";
|
|
||||||
public static String frontFolder = System.getenv(BASE_NAME + "FRONT_FOLDER");
|
|
||||||
public static String expirationTime = System.getenv(BASE_NAME + "AUTH_EXPIRATION_TIME");
|
|
||||||
public static String uuid_for_key_generation = System.getenv(BASE_NAME + "UUID_KEY_ROOT");
|
|
||||||
public static String edge = System.getenv(BASE_NAME + "EDGE");
|
|
||||||
|
|
||||||
public static String getFrontFolder() {
|
|
||||||
if (frontFolder == null) {
|
|
||||||
return "/application/front";
|
|
||||||
}
|
|
||||||
return frontFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getUUIDKeyRoot() {
|
|
||||||
return uuid_for_key_generation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getAuthExpirationTime() {
|
|
||||||
String out = expirationTime;
|
|
||||||
if (out == null) {
|
|
||||||
// default expiration is 33 days for the master Oauth token
|
|
||||||
return 60 * 24 * 33;
|
|
||||||
}
|
|
||||||
return Integer.valueOf(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getEdge() {
|
|
||||||
return Boolean.valueOf(edge);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package org.kar.karso.util;
|
|
||||||
|
|
||||||
public class Transform {
|
|
||||||
|
|
||||||
public static Object convertToType(String type, String value) {
|
|
||||||
if ("BOOLEAN".equals(type)) {
|
|
||||||
return Boolean.valueOf(value);
|
|
||||||
} else if ("STRING".equals(type)) {
|
|
||||||
return value;
|
|
||||||
} else if ("LONG".equals(type)) {
|
|
||||||
return Long.valueOf(value);
|
|
||||||
} else if ("NUMBER".equals(type)) {
|
|
||||||
return Double.valueOf(value);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String convertToStringCheck(String type, Object value) {
|
|
||||||
if ("BOOLEAN".equals(type)) {
|
|
||||||
if (value instanceof Boolean tmp) {
|
|
||||||
return String.valueOf(tmp);
|
|
||||||
}
|
|
||||||
} else if ("STRING".equals(type)) {
|
|
||||||
if (value instanceof String tmp) {
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
} else if ("LONG".equals(type)) {
|
|
||||||
if (value instanceof Long tmp) {
|
|
||||||
return String.valueOf(tmp);
|
|
||||||
} else if (value instanceof Integer tmp) {
|
|
||||||
return String.valueOf(tmp);
|
|
||||||
} else if (value instanceof Short tmp) {
|
|
||||||
return String.valueOf(tmp);
|
|
||||||
} else if (value instanceof Float tmp) {
|
|
||||||
return String.valueOf(Math.round(tmp));
|
|
||||||
} else if (value instanceof Double tmp) {
|
|
||||||
return String.valueOf(Math.round(tmp));
|
|
||||||
}
|
|
||||||
} else if ("NUMBER".equals(type)) {
|
|
||||||
if (value instanceof Long tmp) {
|
|
||||||
return String.valueOf(tmp);
|
|
||||||
} else if (value instanceof Integer tmp) {
|
|
||||||
return String.valueOf(tmp);
|
|
||||||
} else if (value instanceof Short tmp) {
|
|
||||||
return String.valueOf(tmp);
|
|
||||||
} else if (value instanceof Float tmp) {
|
|
||||||
return String.valueOf(tmp);
|
|
||||||
} else if (value instanceof Double tmp) {
|
|
||||||
return String.valueOf(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
13
back/src/resources/logback.xml
Normal file
13
back/src/resources/logback.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<configuration>
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern name="ConversionPattern">
|
||||||
|
%green(%d{HH:mm:ss.SSS}) %highlight(%-5level) %-30((%file:%line\)): %msg%n
|
||||||
|
</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="trace">
|
||||||
|
<appender-ref ref="CONSOLE" />
|
||||||
|
</root>
|
||||||
|
</configuration>
|
@ -1,35 +0,0 @@
|
|||||||
# SLF4J's SimpleLogger configuration file
|
|
||||||
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
|
|
||||||
# Default logging detail level for all instances of SimpleLogger.
|
|
||||||
# Must be one of ("trace", "debug", "info", "warn", or "error").
|
|
||||||
# If not specified, defaults to "info".
|
|
||||||
org.slf4j.simpleLogger.defaultLogLevel=trace
|
|
||||||
|
|
||||||
# Logging detail level for a SimpleLogger instance named "xxxxx".
|
|
||||||
# Must be one of ("trace", "debug", "info", "warn", or "error").
|
|
||||||
# If not specified, the default logging detail level is used.
|
|
||||||
#org.slf4j.simpleLogger.log.xxxxx=
|
|
||||||
|
|
||||||
# Set to true if you want the current date and time to be included in output messages.
|
|
||||||
# Default is false, and will output the number of milliseconds elapsed since startup.
|
|
||||||
#org.slf4j.simpleLogger.showDateTime=false
|
|
||||||
|
|
||||||
# The date and time format to be used in the output messages.
|
|
||||||
# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
|
|
||||||
# If the format is not specified or is invalid, the default format is used.
|
|
||||||
# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
|
|
||||||
#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
|
|
||||||
|
|
||||||
# Set to true if you want to output the current thread name.
|
|
||||||
# Defaults to true.
|
|
||||||
org.slf4j.simpleLogger.showThreadName=true
|
|
||||||
|
|
||||||
# Set to true if you want the Logger instance name to be included in output messages.
|
|
||||||
# Defaults to true.
|
|
||||||
#org.slf4j.simpleLogger.showLogName=true
|
|
||||||
|
|
||||||
# Set to true if you want the last component of the name to be included in output messages.
|
|
||||||
# Defaults to false.
|
|
||||||
#org.slf4j.simpleLogger.showShortLogName=false
|
|
||||||
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
|||||||
package test.kar.karso;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
|
||||||
import org.junit.jupiter.api.extension.ExecutionCondition;
|
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
|
||||||
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
|
|
||||||
|
|
||||||
class StepwiseExtension implements ExecutionCondition, TestExecutionExceptionHandler {
|
|
||||||
@Override
|
|
||||||
public ConditionEvaluationResult evaluateExecutionCondition(final ExtensionContext extensionContext) {
|
|
||||||
final ExtensionContext.Namespace namespace = namespaceFor(extensionContext);
|
|
||||||
final ExtensionContext.Store store = storeFor(extensionContext, namespace);
|
|
||||||
final String value = store.get(StepwiseExtension.class, String.class);
|
|
||||||
return value == null ? ConditionEvaluationResult.enabled("No test failures in stepwise tests")
|
|
||||||
: ConditionEvaluationResult
|
|
||||||
.disabled(String.format("Stepwise test disabled due to previous failure in '%s'", value));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleTestExecutionException(final ExtensionContext extensionContext, final Throwable throwable)
|
|
||||||
throws Throwable {
|
|
||||||
final ExtensionContext.Namespace namespace = namespaceFor(extensionContext);
|
|
||||||
final ExtensionContext.Store store = storeFor(extensionContext, namespace);
|
|
||||||
store.put(StepwiseExtension.class, extensionContext.getDisplayName());
|
|
||||||
throw throwable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ExtensionContext.Namespace namespaceFor(final ExtensionContext extensionContext) {
|
|
||||||
return ExtensionContext.Namespace.create(StepwiseExtension.class, extensionContext.getParent());
|
|
||||||
}
|
|
||||||
|
|
||||||
private ExtensionContext.Store storeFor(
|
|
||||||
final ExtensionContext extensionContext,
|
|
||||||
final ExtensionContext.Namespace namespace) {
|
|
||||||
return extensionContext.getParent().get().getStore(namespace);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,125 +0,0 @@
|
|||||||
package test.kar.karso;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestMethodOrder;
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
|
||||||
import org.kar.archidata.db.DBEntry;
|
|
||||||
import org.kar.archidata.model.GetToken;
|
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
|
||||||
import org.kar.archidata.tools.JWTWrapper;
|
|
||||||
import org.kar.archidata.tools.RESTApi;
|
|
||||||
import org.kar.karso.model.DataGetToken;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.nimbusds.jwt.JWTClaimsSet;
|
|
||||||
|
|
||||||
@ExtendWith(StepwiseExtension.class)
|
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
|
||||||
public class TestBase {
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(TestBase.class);
|
|
||||||
|
|
||||||
static WebLauncherTest webInterface = null;
|
|
||||||
static RESTApi api = null;
|
|
||||||
|
|
||||||
public void login(final String login, final String password) {
|
|
||||||
try {
|
|
||||||
final GetToken token = api.post(GetToken.class, "users/get_token",
|
|
||||||
DataGetToken.generate(login, "v1", "202515252", password));
|
|
||||||
api.setToken(token.jwt);
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
Assertions.fail("Can not get Authentication for '" + login + "' ==> " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loginAdmin() {
|
|
||||||
login("karadmin", "adminA@666");
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void configureWebServer() throws Exception {
|
|
||||||
LOGGER.info("configure server ...");
|
|
||||||
webInterface = new WebLauncherTest();
|
|
||||||
LOGGER.info("Create DB");
|
|
||||||
try {
|
|
||||||
webInterface.migrateDB();
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
LOGGER.error("Detect an error: {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
LOGGER.info("Start REST (BEGIN)");
|
|
||||||
webInterface.process();
|
|
||||||
LOGGER.info("Start REST (DONE)");
|
|
||||||
api = new RESTApi(ConfigBaseVariable.apiAdress);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void stopWebServer() throws InterruptedException, IOException {
|
|
||||||
LOGGER.info("Kill the web server");
|
|
||||||
webInterface.stop();
|
|
||||||
webInterface = null;
|
|
||||||
LOGGER.info("Remove the test db");
|
|
||||||
DBEntry.closeAllForceMode();
|
|
||||||
ConfigBaseVariable.clearAllValue();
|
|
||||||
Thread.sleep(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Order(3)
|
|
||||||
@Test
|
|
||||||
public void firstUserConnect() throws Exception {
|
|
||||||
final GetToken result = api.post(GetToken.class, "users/get_token",
|
|
||||||
DataGetToken.generate("karadmin", "v1", "202515252", "adminA@666"));
|
|
||||||
final String[] splitted = result.jwt.split("\\.");
|
|
||||||
Assertions.assertEquals(3, splitted.length);
|
|
||||||
final String authorization = result.jwt;
|
|
||||||
LOGGER.debug(" validate token : " + authorization);
|
|
||||||
// Note with local access we get the internal key of the system.
|
|
||||||
final JWTClaimsSet ret = JWTWrapper.validateToken(authorization, "KarAuth", null);
|
|
||||||
// check the token is valid !!! (signed and coherent issuer...
|
|
||||||
Assertions.assertNotNull(ret);
|
|
||||||
// check userID
|
|
||||||
final String userUID = ret.getSubject();
|
|
||||||
final long id = Long.parseLong(userUID);
|
|
||||||
Assertions.assertEquals(1, id);
|
|
||||||
final String name = (String) ret.getClaim("login");
|
|
||||||
Assertions.assertEquals("karadmin", name);
|
|
||||||
|
|
||||||
final Object rowRight = ret.getClaim("right");
|
|
||||||
Assertions.assertNotNull(rowRight);
|
|
||||||
final Map<String, Map<String, Object>> rights = (Map<String, Map<String, Object>>) ret.getClaim("right");
|
|
||||||
// Check if the element contain the basic keys:
|
|
||||||
Assertions.assertEquals(rights.size(), 1);
|
|
||||||
Assertions.assertTrue(rights.containsKey("karso"));
|
|
||||||
final Map<String, Object> applRight = rights.get("karso");
|
|
||||||
//logger.error("full right: {}", applRight);
|
|
||||||
Assertions.assertEquals(applRight.size(), 2);
|
|
||||||
Assertions.assertTrue(applRight.containsKey("ADMIN"));
|
|
||||||
Assertions.assertEquals(true, applRight.get("ADMIN"));
|
|
||||||
Assertions.assertTrue(applRight.containsKey("USER"));
|
|
||||||
Assertions.assertEquals(true, applRight.get("USER"));
|
|
||||||
|
|
||||||
//logger.debug("request user: '{}' right: '{}' row='{}'", userUID, applRight, rowRight);
|
|
||||||
|
|
||||||
//Assertions.assertEquals("eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9", splitted[0]);
|
|
||||||
//Assertions.assertEquals("eyJzdWIiOiIwIiwiYXBwbGljYXRpb24iOiJrYXJzbyIsImlzcyI6IkthckF1dGgiLCJyaWdodCI6eyJrYXJzbyI6eyJBRE1JTiI6dHJ1ZSwiVVNFUiI6dHJ1ZX19LCJsb2dpbiI6ImthcmFkbWluIiwiZXhwIjoxNjg0MTk5MTkzLCJpYXQiOjE2ODI3NTU0MjV9", splitted[1]);
|
|
||||||
// TODO ... Assertions.assertEquals("????", splitted[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Order(5)
|
|
||||||
@Test
|
|
||||||
public void testMeWithToken() throws Exception {
|
|
||||||
loginAdmin();
|
|
||||||
final String result = api.get(String.class, "users/me");
|
|
||||||
Assertions.assertEquals("{\"id\":1,\"login\":\"karadmin\"}", result);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
package test.kar.karso;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestMethodOrder;
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
|
||||||
import org.kar.archidata.db.DBEntry;
|
|
||||||
import org.kar.archidata.exception.RESTErrorResponseExeption;
|
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
|
||||||
import org.kar.archidata.tools.RESTApi;
|
|
||||||
import org.kar.karso.api.HealthCheck.HealthResult;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
@ExtendWith(StepwiseExtension.class)
|
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
|
||||||
public class TestHealthCheck {
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(TestHealthCheck.class);
|
|
||||||
|
|
||||||
static WebLauncherTest webInterface = null;
|
|
||||||
static RESTApi api = null;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void configureWebServer() throws Exception {
|
|
||||||
LOGGER.info("configure server ...");
|
|
||||||
webInterface = new WebLauncherTest();
|
|
||||||
LOGGER.info("Create DB");
|
|
||||||
try {
|
|
||||||
webInterface.migrateDB();
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
LOGGER.error("Detect an error: {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
LOGGER.info("Start REST (BEGIN)");
|
|
||||||
webInterface.process();
|
|
||||||
LOGGER.info("Start REST (DONE)");
|
|
||||||
api = new RESTApi(ConfigBaseVariable.apiAdress);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void stopWebServer() throws InterruptedException, IOException {
|
|
||||||
LOGGER.info("Kill the web server");
|
|
||||||
webInterface.stop();
|
|
||||||
webInterface = null;
|
|
||||||
LOGGER.info("Remove the test db");
|
|
||||||
DBEntry.closeAllForceMode();
|
|
||||||
ConfigBaseVariable.clearAllValue();
|
|
||||||
Thread.sleep(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Order(1)
|
|
||||||
@Test
|
|
||||||
//@RepeatedTest(10)
|
|
||||||
public void checkHealthCheck() throws Exception {
|
|
||||||
final HealthResult result = api.get(HealthResult.class, "health_check");
|
|
||||||
Assertions.assertEquals(result.value(), "alive and kicking");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Order(2)
|
|
||||||
@Test
|
|
||||||
public void checkHealthCheckWrongAPI() throws Exception {
|
|
||||||
Assertions.assertThrows(RESTErrorResponseExeption.class, () -> api.get(HealthResult.class, "health_checks"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,188 +0,0 @@
|
|||||||
package test.kar.karso;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestMethodOrder;
|
|
||||||
import org.kar.archidata.db.DBEntry;
|
|
||||||
import org.kar.archidata.exception.RESTErrorResponseExeption;
|
|
||||||
import org.kar.archidata.model.GetToken;
|
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
|
||||||
import org.kar.archidata.tools.RESTApi;
|
|
||||||
import org.kar.karso.model.DataGetToken;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
|
||||||
public class TestUnAuthorizedAPI {
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(TestUnAuthorizedAPI.class);
|
|
||||||
|
|
||||||
static WebLauncherTest webInterface = null;
|
|
||||||
static RESTApi api = null;
|
|
||||||
|
|
||||||
public void login(final String login, final String password) {
|
|
||||||
try {
|
|
||||||
final GetToken token = api.post(GetToken.class, "users/get_token",
|
|
||||||
DataGetToken.generate(login, "v1", "202515252", password));
|
|
||||||
api.setToken(token.jwt);
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
Assertions.fail("Can not get Authentication for '" + login + "' ==> " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loginAdmin() {
|
|
||||||
login("karadmin", "adminA@666");
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void configureWebServer() throws Exception {
|
|
||||||
LOGGER.info("configure server ...");
|
|
||||||
webInterface = new WebLauncherTest();
|
|
||||||
LOGGER.info("Create DB");
|
|
||||||
try {
|
|
||||||
webInterface.migrateDB();
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
LOGGER.error("Detect an error: {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
LOGGER.info("Start REST (BEGIN)");
|
|
||||||
webInterface.process();
|
|
||||||
LOGGER.info("Start REST (DONE)");
|
|
||||||
api = new RESTApi(ConfigBaseVariable.apiAdress);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void stopWebServer() throws InterruptedException, IOException {
|
|
||||||
LOGGER.info("Kill the web server");
|
|
||||||
webInterface.stop();
|
|
||||||
webInterface = null;
|
|
||||||
LOGGER.info("Remove the test db");
|
|
||||||
DBEntry.closeAllForceMode();
|
|
||||||
ConfigBaseVariable.clearAllValue();
|
|
||||||
Thread.sleep(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkFail(final String type, final String urlOffset, final int errorStatus) {
|
|
||||||
checkFail(type, urlOffset, errorStatus, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkFail(final String type, final String urlOffset, final int errorStatus, final String data) {
|
|
||||||
LOGGER.info("Test API: url={} urlOffset={}", type, urlOffset);
|
|
||||||
try {
|
|
||||||
if ("GET".equals(type)) {
|
|
||||||
api.get(String.class, urlOffset);
|
|
||||||
} else if ("POST".equals(type)) {
|
|
||||||
api.post(String.class, urlOffset, data);
|
|
||||||
} else if ("PATCH".equals(type)) {
|
|
||||||
api.patch(String.class, urlOffset, data);
|
|
||||||
} else if ("DELETE".equals(type)) {
|
|
||||||
api.delete(String.class, urlOffset);
|
|
||||||
}
|
|
||||||
Assertions.fail("Request on URL does not fail as expected: '" + type + "' url='" + urlOffset + "'");
|
|
||||||
} catch (final RESTErrorResponseExeption ex) {
|
|
||||||
if (errorStatus != ex.status) {
|
|
||||||
LOGGER.error("Fail in test with the wrong return errors: {}", ex.toString());
|
|
||||||
}
|
|
||||||
Assertions.assertEquals(errorStatus, ex.status);
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
LOGGER.error("Unexpected throw error: {}", ex);
|
|
||||||
Assertions.fail("Unexpected throws...");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkWork(final String type, final String urlOffset) {
|
|
||||||
checkWork(type, urlOffset, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkWork(final String type, final String urlOffset, final String data) {
|
|
||||||
LOGGER.info("Test API: url={} urlOffset={}", type, urlOffset);
|
|
||||||
try {
|
|
||||||
if ("GET".equals(type)) {
|
|
||||||
api.get(String.class, urlOffset);
|
|
||||||
} else if ("POST".equals(type)) {
|
|
||||||
api.post(String.class, urlOffset, data);
|
|
||||||
} else if ("PATCH".equals(type)) {
|
|
||||||
api.patch(String.class, urlOffset, data);
|
|
||||||
} else if ("DELETE".equals(type)) {
|
|
||||||
api.delete(String.class, urlOffset);
|
|
||||||
}
|
|
||||||
//Assertions.fail("Request on URL does not fail as expected: '" + type + "' url='" + urlOffset + "'");
|
|
||||||
} catch (final RESTErrorResponseExeption ex) {
|
|
||||||
Assertions.fail("Must not fail ... " + ex.toString());
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
LOGGER.error("Unexpected throw error: {}", ex);
|
|
||||||
Assertions.fail("Unexpected throws...");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Order(1)
|
|
||||||
@Test
|
|
||||||
public void checkUnAuthorizedAPI() throws Exception {
|
|
||||||
// /application/
|
|
||||||
checkFail("GET", "application/", 401);
|
|
||||||
checkFail("POST", "application/", 401, "{}");
|
|
||||||
checkFail("PATCH", "application/", 405, "{}"); // does not exist
|
|
||||||
checkFail("DELETE", "application/", 405); // does not exist
|
|
||||||
// /application/{id}
|
|
||||||
checkFail("GET", "application/0", 401);
|
|
||||||
checkFail("PATCH", "application/0", 401, "{}");
|
|
||||||
checkFail("POST", "application/0", 405, "{}");
|
|
||||||
checkFail("DELETE", "application/0", 401);
|
|
||||||
// /application/{id}/*
|
|
||||||
checkFail("GET", "application/0/users", 401);
|
|
||||||
// /application/*
|
|
||||||
checkFail("GET", "application/small", 401);
|
|
||||||
checkFail("GET", "application/get_token", 401);
|
|
||||||
checkFail("GET", "application/return", 401);
|
|
||||||
|
|
||||||
// /application_token/ section:
|
|
||||||
checkFail("GET", "application_token/0", 401);
|
|
||||||
checkFail("DELETE", "application_token/0/5", 401);
|
|
||||||
checkFail("DELETE", "application_token/0/create", 401);
|
|
||||||
|
|
||||||
// /front/*
|
|
||||||
checkFail("GET", "front", 404); // no index in test section
|
|
||||||
// health check
|
|
||||||
checkWork("GET", "health_check");
|
|
||||||
|
|
||||||
// public_key (only application)
|
|
||||||
checkFail("GET", "public_key", 401);
|
|
||||||
checkFail("GET", "public_key/pem", 401);
|
|
||||||
|
|
||||||
// /right
|
|
||||||
checkFail("GET", "right", 401);
|
|
||||||
checkFail("POST", "right", 401, "{}");
|
|
||||||
checkFail("GET", "right/0", 401);
|
|
||||||
checkFail("PATCH", "right/0", 401, "{}");
|
|
||||||
checkFail("DELETE", "right/0", 401);
|
|
||||||
|
|
||||||
// /system_config
|
|
||||||
checkWork("GET", "system_config/is_sign_up_availlable");
|
|
||||||
checkFail("GET", "system_config/key/skjdfhkjsdhfkjsh", 401);
|
|
||||||
checkFail("PATCH", "system_config/key/skjdfhkjsdhfkjsh", 401, "{}");
|
|
||||||
|
|
||||||
// /users
|
|
||||||
checkFail("GET", "users", 401);
|
|
||||||
checkFail("GET", "users/0", 401);
|
|
||||||
checkFail("POST", "users/0/application/0/link", 401, "{}");
|
|
||||||
checkFail("POST", "users/0/set_admin", 401, "{}");
|
|
||||||
checkFail("POST", "users/0/set_blocked", 401, "{}");
|
|
||||||
checkFail("POST", "users", 401, "{}");
|
|
||||||
checkFail("GET", "users/me", 401, "{}");
|
|
||||||
checkFail("POST", "users/password", 401, "{}");
|
|
||||||
checkWork("GET", "users/is_login_exist?login=karadmin");
|
|
||||||
checkWork("GET", "users/is_login_exist?login=jhkjhkjh");
|
|
||||||
checkWork("GET", "users/is_email_exist?email=admin@admin.ZZZ");
|
|
||||||
checkWork("GET", "users/is_email_exist?email=ksjhdkjfhskjdh");
|
|
||||||
// not testable : get_token
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
package test.kar.karso;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestMethodOrder;
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
|
||||||
import org.kar.archidata.db.DBEntry;
|
|
||||||
import org.kar.archidata.exception.RESTErrorResponseExeption;
|
|
||||||
import org.kar.archidata.model.GetToken;
|
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
|
||||||
import org.kar.archidata.tools.RESTApi;
|
|
||||||
import org.kar.karso.migration.Initialization;
|
|
||||||
import org.kar.karso.model.DataGetToken;
|
|
||||||
import org.kar.karso.model.UserAuthGet;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
@ExtendWith(StepwiseExtension.class)
|
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
|
||||||
public class TestUsers {
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(TestUsers.class);
|
|
||||||
public final static String ENDPOINT_NAME = "users/";
|
|
||||||
|
|
||||||
static WebLauncherTest webInterface = null;
|
|
||||||
static RESTApi api = null;
|
|
||||||
|
|
||||||
private static long idTest;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void configureWebServer() throws InterruptedException, RESTErrorResponseExeption, IOException {
|
|
||||||
LOGGER.info("configure server ...");
|
|
||||||
webInterface = new WebLauncherTest();
|
|
||||||
LOGGER.info("Clean previous table");
|
|
||||||
|
|
||||||
try {
|
|
||||||
Initialization.dropAll();
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
LOGGER.error("plop: {}", ex.getLocalizedMessage());
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGGER.info("Create DB");
|
|
||||||
try {
|
|
||||||
webInterface.migrateDB();
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
LOGGER.error("Detect an error: {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
LOGGER.info("Start REST (BEGIN)");
|
|
||||||
webInterface.process();
|
|
||||||
LOGGER.info("Start REST (DONE)");
|
|
||||||
api = new RESTApi(ConfigBaseVariable.apiAdress);
|
|
||||||
final GetToken result = api.post(GetToken.class, "users/get_token",
|
|
||||||
DataGetToken.generate("karadmin", "v1", "202515252", "adminA@666"));
|
|
||||||
api.setToken(result.jwt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void stopWebServer() throws IOException {
|
|
||||||
LOGGER.info("Kill the web server");
|
|
||||||
webInterface.stop();
|
|
||||||
webInterface = null;
|
|
||||||
LOGGER.info("Remove the test db");
|
|
||||||
DBEntry.closeAllForceMode();
|
|
||||||
ConfigBaseVariable.clearAllValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Order(1)
|
|
||||||
@Test
|
|
||||||
public void getsValue() throws RESTErrorResponseExeption, IOException, InterruptedException {
|
|
||||||
final List<UserAuthGet> listUsers = api.gets(UserAuthGet.class, TestUsers.ENDPOINT_NAME);
|
|
||||||
Assertions.assertNotNull(listUsers);
|
|
||||||
Assertions.assertEquals(1, listUsers.size());
|
|
||||||
Assertions.assertEquals(1, listUsers.get(0).id);
|
|
||||||
Assertions.assertEquals(true, listUsers.get(0).admin);
|
|
||||||
Assertions.assertEquals(false, listUsers.get(0).blocked);
|
|
||||||
Assertions.assertEquals(false, listUsers.get(0).avatar);
|
|
||||||
Assertions.assertEquals("karadmin", listUsers.get(0).login);
|
|
||||||
Assertions.assertEquals("admin@admin.ZZZ", listUsers.get(0).email);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
|
|
||||||
package test.kar.karso;
|
|
||||||
|
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
|
||||||
import org.kar.karso.WebLauncher;
|
|
||||||
import org.kar.karso.util.ConfigVariable;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class WebLauncherTest extends WebLauncher {
|
|
||||||
final private static Logger LOGGER = LoggerFactory.getLogger(WebLauncherTest.class);
|
|
||||||
|
|
||||||
public WebLauncherTest() {
|
|
||||||
LOGGER.debug("Configure REST system");
|
|
||||||
// for local test:
|
|
||||||
ConfigBaseVariable.apiAdress = "http://127.0.0.1:12345/test/api/";
|
|
||||||
|
|
||||||
//ConfigBaseVariable.dbPort = "3306";
|
|
||||||
// create a unique key for test ==> not retrieve the token every load...
|
|
||||||
ConfigVariable.uuid_for_key_generation = "lkjlkjlkjlmkjqmwlsdkjqfsdlkf,nmQLSDK,NFMQLKSdjmlKQJSDMLQK,S;ndmLQKZNERMA,ÉL";
|
|
||||||
|
|
||||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
|
||||||
ConfigBaseVariable.dbType = "sqlite";
|
|
||||||
ConfigBaseVariable.dbHost = "memory";
|
|
||||||
// for test we need to connect all time the DB
|
|
||||||
ConfigBaseVariable.dbKeepConnected = "true";
|
|
||||||
}
|
|
||||||
|
|
||||||
//ConfigBaseVariable.dbHost = "localhost";
|
|
||||||
//ConfigBaseVariable.dbUser = "root";
|
|
||||||
//ConfigBaseVariable.dbPassword = "ZERTYSDGFVHSDFGHJYZSDFGSQxfgsqdfgsqdrf4564654";
|
|
||||||
}
|
|
||||||
}
|
|
56
env_dev/docker-compose.yaml
Normal file
56
env_dev/docker-compose.yaml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
services:
|
||||||
|
kar_db_service:
|
||||||
|
image: mysql:latest
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- MYSQL_ROOT_PASSWORD=base_db_password
|
||||||
|
volumes:
|
||||||
|
- ./data:/var/lib/mysql
|
||||||
|
mem_limit: 300m
|
||||||
|
ports:
|
||||||
|
- 3906:3306
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
|
||||||
|
timeout: 10s
|
||||||
|
retries: 5
|
||||||
|
# perform a 1 minute grace to let the DB to perform the initialization
|
||||||
|
start_period: 1m
|
||||||
|
start_interval: 1m
|
||||||
|
|
||||||
|
kar_mongodb_service:
|
||||||
|
image: mongo:latest
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
MONGO_INITDB_ROOT_USERNAME: root
|
||||||
|
MONGO_INITDB_ROOT_PASSWORD: base_db_password
|
||||||
|
ports:
|
||||||
|
- 27017:27017
|
||||||
|
volumes:
|
||||||
|
- ./dataMongo:/data/db
|
||||||
|
|
||||||
|
kar_adminer_service:
|
||||||
|
image: adminer:latest
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
kar_db_service:
|
||||||
|
condition: service_healthy
|
||||||
|
links:
|
||||||
|
- kar_db_service:db
|
||||||
|
- kar_mongodb_service:dbm
|
||||||
|
ports:
|
||||||
|
- 4079:8080
|
||||||
|
mem_limit: 50m
|
||||||
|
|
||||||
|
mongo_express_service:
|
||||||
|
image: mongo-express
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 4077:8081
|
||||||
|
links:
|
||||||
|
- kar_mongodb_service:db
|
||||||
|
environment:
|
||||||
|
ME_CONFIG_MONGODB_ADMINUSERNAME: root
|
||||||
|
ME_CONFIG_MONGODB_ADMINPASSWORD: base_db_password
|
||||||
|
ME_CONFIG_MONGODB_URL: mongodb://root:base_db_password@db:27017/
|
||||||
|
ME_CONFIG_BASICAUTH: false
|
||||||
|
|
2
front/.env.production
Normal file
2
front/.env.production
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# URL for database connection
|
||||||
|
VITE_API_BASE_URL=karso/api/
|
27
front/.storybook/main.ts
Normal file
27
front/.storybook/main.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import type { StorybookConfig } from '@storybook/react-vite';
|
||||||
|
|
||||||
|
const config: StorybookConfig = {
|
||||||
|
framework: {
|
||||||
|
name: '@storybook/react-vite',
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
|
|
||||||
|
core: {
|
||||||
|
disableTelemetry: true,
|
||||||
|
builder: '@storybook/builder-vite',
|
||||||
|
},
|
||||||
|
|
||||||
|
stories: ['../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
|
||||||
|
|
||||||
|
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
|
||||||
|
|
||||||
|
staticDirs: ['../public'],
|
||||||
|
|
||||||
|
typescript: {
|
||||||
|
reactDocgen: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
docs: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
16
front/.storybook/preview-head.html
Normal file
16
front/.storybook/preview-head.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<style>
|
||||||
|
html {
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.docs-story > :first-child {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.docs-story > * {
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#root #start-ui-storybook-wrapper {
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
</style>
|
34
front/.storybook/preview.tsx
Normal file
34
front/.storybook/preview.tsx
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { Box } from '@chakra-ui/react';
|
||||||
|
import { ChakraProvider } from '@chakra-ui/react';
|
||||||
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { ColorModeProvider } from '../src/components/ui/color-mode';
|
||||||
|
import { Toaster } from '../src/components/ui/toaster';
|
||||||
|
import { systemTheme } from '../src/theme/theme';
|
||||||
|
|
||||||
|
// .
|
||||||
|
const DocumentationWrapper = ({ children }) => {
|
||||||
|
return (
|
||||||
|
<Box id="start-ui-storybook-wrapper" p="4" pb="8" flex="1">
|
||||||
|
{children}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const decorators = [
|
||||||
|
(Story, context) => (
|
||||||
|
<ColorModeProvider>
|
||||||
|
<ChakraProvider value={systemTheme}>
|
||||||
|
{/* Using MemoryRouter to avoid route clashing with Storybook */}
|
||||||
|
<MemoryRouter>
|
||||||
|
<DocumentationWrapper>
|
||||||
|
<Story {...context} />
|
||||||
|
</DocumentationWrapper>
|
||||||
|
</MemoryRouter>
|
||||||
|
<Toaster />
|
||||||
|
</ChakraProvider>
|
||||||
|
</ColorModeProvider>
|
||||||
|
),
|
||||||
|
];
|
2
front/LICENSE
Normal file
2
front/LICENSE
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Proprietary
|
||||||
|
@copyright Edouard Dupin 2024
|
10888
front/config sample.ts
Normal file
10888
front/config sample.ts
Normal file
File diff suppressed because it is too large
Load Diff
13
front/index.html
Normal file
13
front/index.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>karso</title>
|
||||||
|
<link rel="icon" href="/favicon.ico" />
|
||||||
|
</head>
|
||||||
|
<body style="width:100vw;height:100vh;min-width:100%;min-height:100%;">
|
||||||
|
<div id="root" style="width:100%;height:100%;min-width:100%;min-height:100%;"></div>
|
||||||
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
9
front/knip.ts
Normal file
9
front/knip.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import type { KnipConfig } from 'knip';
|
||||||
|
|
||||||
|
const config: KnipConfig = {
|
||||||
|
// Ignoring mostly shell binaries
|
||||||
|
ignoreBinaries: ['export', 'sleep'],
|
||||||
|
ignore: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
@ -1,64 +1,92 @@
|
|||||||
{
|
{
|
||||||
"name": "karso",
|
"name": "karso",
|
||||||
"version": "0.0.0",
|
"private": true,
|
||||||
"license": "MPL-2",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"description": "KAR web SSO application",
|
||||||
"all": "npm run build && npm run test",
|
"author": {
|
||||||
"ng": "ng",
|
"name": "Edouard DUPIN",
|
||||||
"dev": "ng serve karso --configuration=develop --watch --port 4200",
|
"email": "yui.heero@gmail.farm"
|
||||||
"dev-hot-update": "ng serve karso --configuration=develop --watch --hmr --port 4200",
|
},
|
||||||
"dev_edge": "ng serve karso-edge --configuration=develop --watch --port 4199",
|
"license": "PROPRIETARY",
|
||||||
"build": "ng build karso --prod",
|
"engines": {
|
||||||
"test": "ng test karso",
|
"node": ">=20"
|
||||||
"test-coverage": "ng test karso --code-coverage",
|
},
|
||||||
"lint": "ng lint",
|
"scripts": {
|
||||||
"style": "prettier --write .",
|
"update_packages": "ncu --target minor",
|
||||||
"e2e": "ng e2e",
|
"upgrade_packages": "ncu --upgrade ",
|
||||||
"update_packages": "ncu --upgrade",
|
"install_dependency": "pnpm install",
|
||||||
"install_dependency": "pnpm install --force",
|
"test": "vitest run",
|
||||||
"link_kar_cw": "pnpm link ../../kar-cw/dist/kar-cw/",
|
"test:watch": "vitest watch",
|
||||||
"unlink_kar_cw": "pnpm unlink ../../kar-cw/dist/kar-cw/"
|
"build": "tsc && vite build",
|
||||||
},
|
"static:build": "pnpm build",
|
||||||
"private": true,
|
"dev": "vite",
|
||||||
"dependencies": {
|
"pretty": "prettier -w .",
|
||||||
"@angular/animations": "^18.0.1",
|
"lint": "pnpm tsc --noEmit",
|
||||||
"@angular/cdk": "^18.0.1",
|
"storybook": "storybook dev -p 3001",
|
||||||
"@angular/common": "^18.0.1",
|
"storybook:build": "storybook build && mv ./storybook-static ./public/storybook"
|
||||||
"@angular/compiler": "^18.0.1",
|
},
|
||||||
"@angular/core": "^18.0.1",
|
"lint-staged": {
|
||||||
"@angular/forms": "^18.0.1",
|
"*.{ts,tsx,js,jsx,json}": "prettier --write"
|
||||||
"@angular/material": "^18.0.1",
|
},
|
||||||
"@angular/platform-browser": "^18.0.1",
|
"dependencies": {
|
||||||
"@angular/platform-browser-dynamic": "^18.0.1",
|
"@trivago/prettier-plugin-sort-imports": "5.2.2",
|
||||||
"@angular/router": "^18.0.1",
|
"@chakra-ui/cli": "3.16.0",
|
||||||
"rxjs": "^7.8.1",
|
"@chakra-ui/react": "3.16.0",
|
||||||
"zone.js": "^0.14.6",
|
"@emotion/react": "11.14.0",
|
||||||
"zod": "3.23.8",
|
"allotment": "1.20.3",
|
||||||
"@kangaroo-and-rabbit/kar-cw": "^0.4.0"
|
"css-mediaquery": "0.1.2",
|
||||||
},
|
"dayjs": "1.11.13",
|
||||||
"devDependencies": {
|
"history": "5.3.0",
|
||||||
"@angular-devkit/build-angular": "^18.0.2",
|
"next-themes": "^0.4.6",
|
||||||
"@angular-eslint/builder": "18.0.1",
|
"react": "19.1.0",
|
||||||
"@angular-eslint/eslint-plugin": "18.0.1",
|
"react-dom": "19.1.0",
|
||||||
"@angular-eslint/eslint-plugin-template": "18.0.1",
|
"react-error-boundary": "5.0.0",
|
||||||
"@angular-eslint/schematics": "18.0.1",
|
"react-icons": "5.5.0",
|
||||||
"@angular-eslint/template-parser": "18.0.1",
|
"react-router-dom": "7.5.0",
|
||||||
"@angular/cli": "^18.0.2",
|
"react-select": "5.10.1",
|
||||||
"@angular/compiler-cli": "^18.0.1",
|
"react-use": "17.6.0",
|
||||||
"@angular/language-service": "^18.0.1",
|
"zod": "3.24.2",
|
||||||
"@playwright/test": "^1.44.1",
|
"zustand": "5.0.3"
|
||||||
"@types/jest": "^29.5.12",
|
},
|
||||||
"jasmine": "^5.1.0",
|
"devDependencies": {
|
||||||
"jasmine-core": "^5.1.2",
|
"@chakra-ui/styled-system": "^2.12.0",
|
||||||
"karma": "^6.4.3",
|
"@playwright/test": "1.51.1",
|
||||||
"karma-coverage": "^2.2.1",
|
"@storybook/addon-actions": "8.6.12",
|
||||||
"karma-coverage-istanbul-reporter": "^3.0.3",
|
"@storybook/addon-essentials": "8.6.12",
|
||||||
"karma-firefox-launcher": "^2.1.3",
|
"@storybook/addon-links": "8.6.12",
|
||||||
"karma-jasmine": "^5.1.0",
|
"@storybook/addon-mdx-gfm": "8.6.12",
|
||||||
"karma-jasmine-html-reporter": "^2.1.0",
|
"@storybook/react": "8.6.12",
|
||||||
"karma-spec-reporter": "^0.0.36",
|
"@storybook/react-vite": "8.6.12",
|
||||||
"prettier": "^3.3.0",
|
"@storybook/theming": "8.6.12",
|
||||||
"npm-check-updates": "^16.14.20",
|
"@testing-library/jest-dom": "6.6.3",
|
||||||
"tslib": "^2.6.2"
|
"@testing-library/react": "16.3.0",
|
||||||
}
|
"@testing-library/user-event": "14.6.1",
|
||||||
|
"@trivago/prettier-plugin-sort-imports": "5.2.2",
|
||||||
|
"@types/jest": "29.5.14",
|
||||||
|
"@types/node": "22.14.1",
|
||||||
|
"@types/react": "19.1.1",
|
||||||
|
"@types/react-dom": "19.1.2",
|
||||||
|
"@typescript-eslint/eslint-plugin": "8.30.0",
|
||||||
|
"@typescript-eslint/parser": "8.30.0",
|
||||||
|
"@vitejs/plugin-react": "4.3.4",
|
||||||
|
"eslint": "9.24.0",
|
||||||
|
"eslint-plugin-codeceptjs": "1.3.0",
|
||||||
|
"eslint-plugin-import": "2.31.0",
|
||||||
|
"eslint-plugin-react": "7.37.5",
|
||||||
|
"eslint-plugin-react-hooks": "5.2.0",
|
||||||
|
"eslint-plugin-storybook": "0.12.0",
|
||||||
|
"jest": "29.7.0",
|
||||||
|
"jest-environment-jsdom": "29.7.0",
|
||||||
|
"knip": "5.50.3",
|
||||||
|
"lint-staged": "15.5.1",
|
||||||
|
"npm-check-updates": "^17.1.18",
|
||||||
|
"prettier": "3.5.3",
|
||||||
|
"puppeteer": "24.6.1",
|
||||||
|
"react-is": "19.1.0",
|
||||||
|
"storybook": "8.6.12",
|
||||||
|
"ts-node": "10.9.2",
|
||||||
|
"typescript": "5.8.3",
|
||||||
|
"vite": "6.2.6",
|
||||||
|
"vitest": "3.1.1"
|
||||||
|
}
|
||||||
}
|
}
|
0
front/playwright-report/.keep
Normal file
0
front/playwright-report/.keep
Normal file
19067
front/pnpm-lock.yaml
generated
19067
front/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
16
front/prettier.config.js
Normal file
16
front/prettier.config.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Using a JS file, allowing us to add comments
|
||||||
|
module.exports = {
|
||||||
|
// This plugins line is mandatory for the plugin to work with pnpm.
|
||||||
|
// https://github.com/trivago/prettier-plugin-sort-imports/blob/61d069711008c530f5a41ca4e254781abc5de358/README.md?plain=1#L89-L96
|
||||||
|
plugins: ['@trivago/prettier-plugin-sort-imports'],
|
||||||
|
endOfLine: 'lf',
|
||||||
|
semi: true,
|
||||||
|
singleQuote: true,
|
||||||
|
tabWidth: 2,
|
||||||
|
trailingComma: 'es5',
|
||||||
|
arrowParens: 'always',
|
||||||
|
importOrder: ['^react$', '^(?!^react$|^@/|^[./]).*', '^@/(.*)$', '^[./]'],
|
||||||
|
importOrderSeparation: true,
|
||||||
|
importOrderSortSpecifiers: true,
|
||||||
|
importOrderParserPlugins: ['jsx', 'typescript'],
|
||||||
|
};
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
18
front/src/App.tsx
Normal file
18
front/src/App.tsx
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { ErrorBoundary } from '@/errors/ErrorBoundary';
|
||||||
|
import { AppRoutes } from '@/scene/AppRoutes';
|
||||||
|
import { ServiceContextProvider } from '@/service/ServiceContext';
|
||||||
|
|
||||||
|
import { EnvDevelopment } from './components/EnvDevelopment/EnvDevelopment';
|
||||||
|
|
||||||
|
export const App = () => {
|
||||||
|
return (
|
||||||
|
<ServiceContextProvider>
|
||||||
|
<EnvDevelopment />
|
||||||
|
<ErrorBoundary>
|
||||||
|
<AppRoutes />
|
||||||
|
</ErrorBoundary>
|
||||||
|
</ServiceContextProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default App;
|
@ -1,26 +1,70 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
width="256"
|
width="256"
|
||||||
height="256"
|
height="256"
|
||||||
viewBox="0 0 67.733333 67.733333"
|
viewBox="0 0 67.733333 67.733333"
|
||||||
version="1.1"
|
version="1.1"
|
||||||
id="svg8"
|
id="svg18"
|
||||||
inkscape:version="0.92.4 5da689c313, 2019-01-14"
|
sodipodi:docname="ikon_red.svg"
|
||||||
sodipodi:docname="ikon.svg"
|
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
||||||
inkscape:export-filename="/home/heero/dev/perso/appl_pro/NoKomment/plugin/chrome/ikon.png"
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
inkscape:export-xdpi="7.1250005"
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
inkscape:export-ydpi="7.1250005">
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||||
<defs
|
<defs
|
||||||
id="defs2" />
|
id="defs2">
|
||||||
|
<filter
|
||||||
|
style="color-interpolation-filters:sRGB;"
|
||||||
|
id="filter5338"
|
||||||
|
x="-0.12319682"
|
||||||
|
y="-0.081815216"
|
||||||
|
width="1.2463936"
|
||||||
|
height="1.1636304">
|
||||||
|
<feFlood
|
||||||
|
flood-opacity="1"
|
||||||
|
flood-color="rgb(165,29,45)"
|
||||||
|
result="flood"
|
||||||
|
id="feFlood5328" />
|
||||||
|
<feComposite
|
||||||
|
in="flood"
|
||||||
|
in2="SourceGraphic"
|
||||||
|
operator="in"
|
||||||
|
result="composite1"
|
||||||
|
id="feComposite5330" />
|
||||||
|
<feGaussianBlur
|
||||||
|
in="composite1"
|
||||||
|
stdDeviation="2.1"
|
||||||
|
result="blur"
|
||||||
|
id="feGaussianBlur5332" />
|
||||||
|
<feOffset
|
||||||
|
dx="0"
|
||||||
|
dy="0"
|
||||||
|
result="offset"
|
||||||
|
id="feOffset5334" />
|
||||||
|
<feComposite
|
||||||
|
in="SourceGraphic"
|
||||||
|
in2="offset"
|
||||||
|
operator="over"
|
||||||
|
result="composite2"
|
||||||
|
id="feComposite5336" />
|
||||||
|
</filter>
|
||||||
|
<filter
|
||||||
|
inkscape:collect="always"
|
||||||
|
style="color-interpolation-filters:sRGB"
|
||||||
|
id="filter1159"
|
||||||
|
x="-0.11802406"
|
||||||
|
width="1.2360481"
|
||||||
|
y="-0.078379973"
|
||||||
|
height="1.1567599">
|
||||||
|
<feGaussianBlur
|
||||||
|
inkscape:collect="always"
|
||||||
|
stdDeviation="2.0118255"
|
||||||
|
id="feGaussianBlur1161" />
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
<sodipodi:namedview
|
<sodipodi:namedview
|
||||||
id="base"
|
id="base"
|
||||||
pagecolor="#ffffff"
|
pagecolor="#ffffff"
|
||||||
@ -28,22 +72,31 @@
|
|||||||
borderopacity="1.0"
|
borderopacity="1.0"
|
||||||
inkscape:pageopacity="0.0"
|
inkscape:pageopacity="0.0"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:zoom="1.979899"
|
inkscape:zoom="7.9195959"
|
||||||
inkscape:cx="52.480467"
|
inkscape:cx="89.966711"
|
||||||
inkscape:cy="138.73493"
|
inkscape:cy="177.91312"
|
||||||
inkscape:document-units="mm"
|
inkscape:document-units="mm"
|
||||||
inkscape:current-layer="layer1"
|
inkscape:current-layer="layer1"
|
||||||
showgrid="true"
|
showgrid="true"
|
||||||
units="px"
|
units="px"
|
||||||
inkscape:snap-text-baseline="false"
|
inkscape:snap-text-baseline="false"
|
||||||
inkscape:window-width="1918"
|
inkscape:window-width="3838"
|
||||||
inkscape:window-height="1038"
|
inkscape:window-height="2118"
|
||||||
inkscape:window-x="0"
|
inkscape:window-x="0"
|
||||||
inkscape:window-y="20"
|
inkscape:window-y="20"
|
||||||
inkscape:window-maximized="1">
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:deskcolor="#d1d1d1">
|
||||||
<inkscape:grid
|
<inkscape:grid
|
||||||
type="xygrid"
|
type="xygrid"
|
||||||
id="grid4504" />
|
id="grid4504"
|
||||||
|
originx="0"
|
||||||
|
originy="0"
|
||||||
|
spacingy="1"
|
||||||
|
spacingx="1"
|
||||||
|
units="px"
|
||||||
|
visible="true" />
|
||||||
</sodipodi:namedview>
|
</sodipodi:namedview>
|
||||||
<metadata
|
<metadata
|
||||||
id="metadata5">
|
id="metadata5">
|
||||||
@ -61,18 +114,22 @@
|
|||||||
inkscape:label="Layer 1"
|
inkscape:label="Layer 1"
|
||||||
inkscape:groupmode="layer"
|
inkscape:groupmode="layer"
|
||||||
id="layer1"
|
id="layer1"
|
||||||
transform="translate(0,-229.26668)">
|
transform="translate(0,-229.26668)"
|
||||||
|
style="display:inline">
|
||||||
<g
|
<g
|
||||||
aria-label="K"
|
id="text821-7"
|
||||||
transform="scale(1.0347881,0.96638145)"
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:84.55024719px;line-height:1.25;font-family:'DejaVu Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;opacity:1;fill:#2b3137;fill-opacity:1;stroke:none;stroke-width:2.11405313;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:84.55024719px;line-height:1.25;font-family:'DejaVu Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:2.11376619"
|
transform="matrix(0.8407653,0,0,0.83753055,-37.28971,3.4402954)"
|
||||||
id="text821">
|
aria-label="K">
|
||||||
<path
|
<path
|
||||||
d="m 12.784421,241.62303 h 8.949095 v 27.37877 l 25.568842,-27.37877 6.39221,6.84469 -20.455074,21.90302 20.455074,27.37876 -6.39221,5.47576 -19.176632,-27.37877 -6.39221,6.84469 0,20.53408 h -8.949095 z"
|
id="path823-5"
|
||||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:84.55024719px;font-family:'DejaVu Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:2.11376619;fill:#ff0000;fill-opacity:1"
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:84.55024719px;font-family:'DejaVu Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;opacity:0.775;fill:#2b3137;fill-opacity:1;stroke-width:2.11405313;filter:url(#filter5338);stroke-miterlimit:4;stroke-dasharray:none"
|
||||||
id="path823"
|
d="M 65.200545 279.95309 L 65.200545 341.55532 L 74.14964 341.55532 L 74.14964 321.02125 L 80.541851 314.17676 L 99.718483 341.55532 L 106.11069 336.07998 L 85.655619 308.7008 L 106.11069 286.7982 L 99.718483 279.95309 L 74.14964 307.33227 L 74.14964 279.95309 L 65.200545 279.95309 z M 69.586585 307.95792 C 71.270821 307.95521 72.163105 308.76519 72.164982 309.94037 C 72.166858 311.11555 71.276967 311.92813 69.592731 311.93085 C 67.946259 311.9335 67.061695 311.12357 67.059818 309.94839 C 67.057941 308.77322 67.940113 307.96057 69.586585 307.95792 z M 69.588429 309.10309 C 68.568824 309.10473 68.017826 309.4316 68.01865 309.94716 C 68.019473 310.46272 68.571283 310.78793 69.590887 310.78629 C 70.655808 310.78458 71.206973 310.45717 71.20615 309.94161 C 71.205327 309.42604 70.653349 309.10138 69.588429 309.10309 z M 70.651134 317.13779 C 71.466818 317.13648 72.177771 317.82535 72.179733 319.0536 C 72.180798 319.7208 71.940317 320.4034 71.472902 320.93487 L 70.70891 320.29194 C 71.010421 319.91995 71.221049 319.45722 71.220287 318.97956 C 71.219524 318.50191 71.038049 318.28194 70.788812 318.28234 C 70.441392 318.2829 70.351355 318.5789 70.155738 319.04928 L 69.884683 319.68666 C 69.681646 320.24045 69.259204 320.7412 68.541704 320.74236 C 67.726021 320.74367 67.075662 320.0017 67.073955 318.93267 C 67.072998 318.33371 67.298319 317.73449 67.720551 317.28649 L 68.424309 317.85414 C 68.175617 318.19572 68.032626 318.50667 68.033401 318.9919 C 68.033994 319.36341 68.192626 319.61369 68.479626 319.61323 C 68.774179 319.61276 68.886895 319.27856 69.059842 318.80063 L 69.315531 318.20151 C 69.556173 317.54909 69.956292 317.13891 70.651134 317.13779 z M 72.09983 325.98324 L 72.102289 327.23453 L 70.32845 328.18534 L 70.32968 328.76904 L 72.104747 328.76595 L 72.106591 329.88027 L 67.18213 329.88829 L 67.179057 328.13722 C 67.177386 327.09093 67.538843 326.22575 68.7095 326.22387 C 69.434552 326.2227 69.895571 326.57849 70.130538 327.10126 L 72.09983 325.98324 z M 68.711344 327.32338 C 68.227976 327.32416 68.061959 327.6353 68.062903 328.22668 L 68.064133 328.77274 L 69.445833 328.77027 L 69.445219 328.22422 C 69.444274 327.63284 69.194712 327.3226 68.711344 327.32338 z M 72.114581 335.0286 L 72.116425 336.2114 L 70.946159 336.5088 L 70.948618 338.00258 L 72.119499 338.30368 L 72.121342 339.44145 L 67.195038 337.91003 L 67.192579 336.57544 L 72.114581 335.0286 z M 70.078294 336.73771 L 69.625307 336.85248 C 69.134592 336.98216 68.560497 337.13471 68.039547 337.24921 L 68.039547 337.27945 C 68.560872 337.39992 69.13541 337.53513 69.626536 337.66323 L 70.079523 337.77614 L 70.078294 336.73771 z " />
|
||||||
inkscape:connector-curvature="0"
|
|
||||||
sodipodi:nodetypes="ccccccccccccc" />
|
|
||||||
</g>
|
</g>
|
||||||
|
<g
|
||||||
|
id="text821"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:84.55024719px;line-height:1.25;font-family:'DejaVu Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#2b3137;fill-opacity:1;stroke:none;stroke-width:2.11376619;stroke-opacity:1;filter:url(#filter1159)"
|
||||||
|
transform="matrix(1.0347881,0,0,0.96638144,-54.239583,-37.041665)"
|
||||||
|
aria-label="K" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 7.6 KiB |
@ -11,10 +11,11 @@ import {
|
|||||||
|
|
||||||
import { z as zod } from "zod"
|
import { z as zod } from "zod"
|
||||||
import {
|
import {
|
||||||
AddUserDataWrite,
|
AddUserData,
|
||||||
Application,
|
Application,
|
||||||
|
ApplicationCreate,
|
||||||
ApplicationSmall,
|
ApplicationSmall,
|
||||||
ApplicationWrite,
|
ApplicationUpdate,
|
||||||
ClientToken,
|
ClientToken,
|
||||||
Long,
|
Long,
|
||||||
RightDescription,
|
RightDescription,
|
||||||
@ -37,7 +38,7 @@ export namespace ApplicationResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: AddUserDataWrite,
|
data: AddUserData,
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return RESTRequestVoid({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -55,7 +56,7 @@ export namespace ApplicationResource {
|
|||||||
data,
|
data,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: ApplicationWrite,
|
data: ApplicationCreate,
|
||||||
}): Promise<Application> {
|
}): Promise<Application> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -256,12 +257,12 @@ export namespace ApplicationResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: ApplicationWrite,
|
data: ApplicationUpdate,
|
||||||
}): Promise<Application> {
|
}): Promise<Application> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/application/{id}",
|
endPoint: "/application/{id}",
|
||||||
requestType: HTTPRequestModel.PATCH,
|
requestType: HTTPRequestModel.PUT,
|
||||||
contentType: HTTPMimeType.JSON,
|
contentType: HTTPMimeType.JSON,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
|
@ -12,7 +12,7 @@ import {
|
|||||||
import { z as zod } from "zod"
|
import { z as zod } from "zod"
|
||||||
import {
|
import {
|
||||||
ApplicationToken,
|
ApplicationToken,
|
||||||
CreateTokenRequestWrite,
|
CreateTokenRequest,
|
||||||
Integer,
|
Integer,
|
||||||
Long,
|
Long,
|
||||||
ZodApplicationToken,
|
ZodApplicationToken,
|
||||||
@ -30,7 +30,7 @@ export namespace ApplicationTokenResource {
|
|||||||
params: {
|
params: {
|
||||||
applicationId: Long,
|
applicationId: Long,
|
||||||
},
|
},
|
||||||
data: CreateTokenRequestWrite,
|
data: CreateTokenRequest,
|
||||||
}): Promise<ApplicationToken> {
|
}): Promise<ApplicationToken> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
} from "../rest-tools";
|
} from "../rest-tools";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
UUID,
|
ObjectId,
|
||||||
} from "../model";
|
} from "../model";
|
||||||
|
|
||||||
export namespace DataResource {
|
export namespace DataResource {
|
||||||
@ -22,7 +22,7 @@ export namespace DataResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
queries,
|
queries,
|
||||||
params,
|
params,
|
||||||
data,
|
headers,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
queries: {
|
queries: {
|
||||||
@ -30,19 +30,21 @@ export namespace DataResource {
|
|||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
name: string,
|
name: string,
|
||||||
uuid: UUID,
|
oid: ObjectId,
|
||||||
|
},
|
||||||
|
headers?: {
|
||||||
|
Range?: string,
|
||||||
},
|
},
|
||||||
data: string,
|
|
||||||
}): Promise<object> {
|
}): Promise<object> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/{uuid}/{name}",
|
endPoint: "/data/{oid}/{name}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
queries,
|
queries,
|
||||||
data,
|
headers,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@ -52,26 +54,28 @@ export namespace DataResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
queries,
|
queries,
|
||||||
params,
|
params,
|
||||||
data,
|
headers,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
queries: {
|
queries: {
|
||||||
Authorization?: string,
|
Authorization?: string,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
uuid: UUID,
|
oid: ObjectId,
|
||||||
|
},
|
||||||
|
headers?: {
|
||||||
|
Range: string,
|
||||||
},
|
},
|
||||||
data: string,
|
|
||||||
}): Promise<object> {
|
}): Promise<object> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/{uuid}",
|
endPoint: "/data/{oid}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
queries,
|
queries,
|
||||||
data,
|
headers,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@ -81,26 +85,28 @@ export namespace DataResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
queries,
|
queries,
|
||||||
params,
|
params,
|
||||||
data,
|
headers,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
queries: {
|
queries: {
|
||||||
Authorization?: string,
|
Authorization?: string,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
uuid: UUID,
|
oid: ObjectId,
|
||||||
|
},
|
||||||
|
headers?: {
|
||||||
|
Range: string,
|
||||||
},
|
},
|
||||||
data: string,
|
|
||||||
}): Promise<object> {
|
}): Promise<object> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/thumbnail/{uuid}",
|
endPoint: "/data/thumbnail/{oid}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
queries,
|
queries,
|
||||||
data,
|
headers,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +13,8 @@ import { z as zod } from "zod"
|
|||||||
import {
|
import {
|
||||||
Long,
|
Long,
|
||||||
Right,
|
Right,
|
||||||
RightWrite,
|
RightCreate,
|
||||||
|
RightUpdate,
|
||||||
ZodRight,
|
ZodRight,
|
||||||
isRight,
|
isRight,
|
||||||
} from "../model";
|
} from "../model";
|
||||||
@ -76,12 +77,12 @@ export namespace RightResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: RightWrite,
|
data: RightUpdate,
|
||||||
}): Promise<Right> {
|
}): Promise<Right> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/right/{id}",
|
endPoint: "/right/{id}",
|
||||||
requestType: HTTPRequestModel.PATCH,
|
requestType: HTTPRequestModel.PUT,
|
||||||
contentType: HTTPMimeType.JSON,
|
contentType: HTTPMimeType.JSON,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
@ -95,7 +96,7 @@ export namespace RightResource {
|
|||||||
data,
|
data,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: RightWrite,
|
data: RightCreate,
|
||||||
}): Promise<Right> {
|
}): Promise<Right> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
|
@ -78,7 +78,7 @@ export namespace SystemConfigResource {
|
|||||||
return RESTRequestVoid({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/system_config/key/{key}",
|
endPoint: "/system_config/key/{key}",
|
||||||
requestType: HTTPRequestModel.PATCH,
|
requestType: HTTPRequestModel.PUT,
|
||||||
contentType: HTTPMimeType.JSON,
|
contentType: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
|
@ -11,14 +11,16 @@ import {
|
|||||||
|
|
||||||
import { z as zod } from "zod"
|
import { z as zod } from "zod"
|
||||||
import {
|
import {
|
||||||
ChangePasswordWrite,
|
ChangePassword,
|
||||||
DataGetTokenWrite,
|
DataGetToken,
|
||||||
GetToken,
|
GetToken,
|
||||||
Long,
|
Long,
|
||||||
|
PartRight,
|
||||||
UserAuth,
|
UserAuth,
|
||||||
UserAuthGet,
|
UserAuthGet,
|
||||||
UserCreateWrite,
|
UserCreate,
|
||||||
UserOut,
|
UserOut,
|
||||||
|
ZodPartRight,
|
||||||
ZodUserAuthGet,
|
ZodUserAuthGet,
|
||||||
isGetToken,
|
isGetToken,
|
||||||
isUserAuth,
|
isUserAuth,
|
||||||
@ -33,7 +35,7 @@ export namespace UserResource {
|
|||||||
data,
|
data,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: ChangePasswordWrite,
|
data: ChangePassword,
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return RESTRequestVoid({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -50,7 +52,7 @@ export namespace UserResource {
|
|||||||
data,
|
data,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: UserCreateWrite,
|
data: UserCreate,
|
||||||
}): Promise<UserAuthGet> {
|
}): Promise<UserAuthGet> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -63,8 +65,27 @@ export namespace UserResource {
|
|||||||
data,
|
data,
|
||||||
}, isUserAuthGet);
|
}, isUserAuthGet);
|
||||||
};
|
};
|
||||||
|
export function get({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<UserAuthGet> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isUserAuthGet);
|
||||||
|
};
|
||||||
|
|
||||||
export const ZodGetApplicationRightTypeReturn = zod.record(zod.string(), zod.any());
|
export const ZodGetApplicationRightTypeReturn = zod.record(zod.string(), ZodPartRight);
|
||||||
export type GetApplicationRightTypeReturn = zod.infer<typeof ZodGetApplicationRightTypeReturn>;
|
export type GetApplicationRightTypeReturn = zod.infer<typeof ZodGetApplicationRightTypeReturn>;
|
||||||
|
|
||||||
export function isGetApplicationRightTypeReturn(data: any): data is GetApplicationRightTypeReturn {
|
export function isGetApplicationRightTypeReturn(data: any): data is GetApplicationRightTypeReturn {
|
||||||
@ -116,7 +137,7 @@ export namespace UserResource {
|
|||||||
data,
|
data,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: DataGetTokenWrite,
|
data: DataGetToken,
|
||||||
}): Promise<GetToken> {
|
}): Promise<GetToken> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -129,44 +150,25 @@ export namespace UserResource {
|
|||||||
data,
|
data,
|
||||||
}, isGetToken);
|
}, isGetToken);
|
||||||
};
|
};
|
||||||
export function getUser({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<UserAuthGet> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/users/{id}",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isUserAuthGet);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ZodGetUsersTypeReturn = zod.array(ZodUserAuthGet);
|
export const ZodGetsTypeReturn = zod.array(ZodUserAuthGet);
|
||||||
export type GetUsersTypeReturn = zod.infer<typeof ZodGetUsersTypeReturn>;
|
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
||||||
|
|
||||||
export function isGetUsersTypeReturn(data: any): data is GetUsersTypeReturn {
|
export function isGetsTypeReturn(data: any): data is GetsTypeReturn {
|
||||||
try {
|
try {
|
||||||
ZodGetUsersTypeReturn.parse(data);
|
ZodGetsTypeReturn.parse(data);
|
||||||
return true;
|
return true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(`Fail to parse data type='ZodGetUsersTypeReturn' error=${e}`);
|
console.log(`Fail to parse data type='ZodGetsTypeReturn' error=${e}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUsers({
|
export function gets({
|
||||||
restConfig,
|
restConfig,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
}): Promise<GetUsersTypeReturn> {
|
}): Promise<GetsTypeReturn> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/users/",
|
endPoint: "/users/",
|
||||||
@ -174,7 +176,7 @@ export namespace UserResource {
|
|||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
}, isGetUsersTypeReturn);
|
}, isGetsTypeReturn);
|
||||||
};
|
};
|
||||||
export function isEmailExist({
|
export function isEmailExist({
|
||||||
restConfig,
|
restConfig,
|
||||||
@ -238,7 +240,7 @@ export namespace UserResource {
|
|||||||
}, isUserAuth);
|
}, isUserAuth);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ZodPatchApplicationRightTypeReturn = zod.record(zod.string(), zod.any());
|
export const ZodPatchApplicationRightTypeReturn = zod.record(zod.string(), ZodPartRight);
|
||||||
export type PatchApplicationRightTypeReturn = zod.infer<typeof ZodPatchApplicationRightTypeReturn>;
|
export type PatchApplicationRightTypeReturn = zod.infer<typeof ZodPatchApplicationRightTypeReturn>;
|
||||||
|
|
||||||
export function isPatchApplicationRightTypeReturn(data: any): data is PatchApplicationRightTypeReturn {
|
export function isPatchApplicationRightTypeReturn(data: any): data is PatchApplicationRightTypeReturn {
|
||||||
@ -261,7 +263,7 @@ export namespace UserResource {
|
|||||||
applicationId: Long,
|
applicationId: Long,
|
||||||
userId: Long,
|
userId: Long,
|
||||||
},
|
},
|
||||||
data: {[key: string]: object;},
|
data: {[key: Partial<string>]: PartRight;},
|
||||||
}): Promise<PatchApplicationRightTypeReturn> {
|
}): Promise<PatchApplicationRightTypeReturn> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
|
@ -21,17 +21,3 @@ export function isAddUserData(data: any): data is AddUserData {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodAddUserDataWrite = ZodAddUserData.partial();
|
|
||||||
|
|
||||||
export type AddUserDataWrite = zod.infer<typeof ZodAddUserDataWrite>;
|
|
||||||
|
|
||||||
export function isAddUserDataWrite(data: any): data is AddUserDataWrite {
|
|
||||||
try {
|
|
||||||
ZodAddUserDataWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodAddUserDataWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -7,9 +7,9 @@ import {ZodLong} from "./long";
|
|||||||
|
|
||||||
export const ZodApplicationSmall = zod.object({
|
export const ZodApplicationSmall = zod.object({
|
||||||
id: ZodLong.optional(),
|
id: ZodLong.optional(),
|
||||||
name: zod.string().max(255).optional(),
|
name: zod.string().optional(),
|
||||||
description: zod.string().max(255).optional(),
|
description: zod.string().optional(),
|
||||||
redirect: zod.string().max(255).optional(),
|
redirect: zod.string().optional(),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -24,17 +24,3 @@ export function isApplicationSmall(data: any): data is ApplicationSmall {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodApplicationSmallWrite = ZodApplicationSmall.partial();
|
|
||||||
|
|
||||||
export type ApplicationSmallWrite = zod.infer<typeof ZodApplicationSmallWrite>;
|
|
||||||
|
|
||||||
export function isApplicationSmallWrite(data: any): data is ApplicationSmallWrite {
|
|
||||||
try {
|
|
||||||
ZodApplicationSmallWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodApplicationSmallWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -5,9 +5,7 @@ import { z as zod } from "zod";
|
|||||||
|
|
||||||
import {ZodGenericToken} from "./generic-token";
|
import {ZodGenericToken} from "./generic-token";
|
||||||
|
|
||||||
export const ZodApplicationToken = ZodGenericToken.extend({
|
export const ZodApplicationToken = ZodGenericToken;
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export type ApplicationToken = zod.infer<typeof ZodApplicationToken>;
|
export type ApplicationToken = zod.infer<typeof ZodApplicationToken>;
|
||||||
|
|
||||||
@ -20,23 +18,3 @@ export function isApplicationToken(data: any): data is ApplicationToken {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodApplicationTokenWrite = ZodApplicationToken.omit({
|
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type ApplicationTokenWrite = zod.infer<typeof ZodApplicationTokenWrite>;
|
|
||||||
|
|
||||||
export function isApplicationTokenWrite(data: any): data is ApplicationTokenWrite {
|
|
||||||
try {
|
|
||||||
ZodApplicationTokenWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodApplicationTokenWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -3,15 +3,16 @@
|
|||||||
*/
|
*/
|
||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodLong} from "./long";
|
||||||
import {ZodInteger} from "./integer";
|
import {ZodInteger} from "./integer";
|
||||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteUpdate , ZodGenericDataSoftDeleteCreate } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodApplication = ZodGenericDataSoftDelete.extend({
|
export const ZodApplication = ZodGenericDataSoftDelete.extend({
|
||||||
name: zod.string().max(256).optional(),
|
name: zod.string().min(1).max(256).optional(),
|
||||||
description: zod.string().max(2048).optional(),
|
description: zod.string().min(1).max(2048).optional(),
|
||||||
redirect: zod.string().max(2048),
|
redirect: zod.string().min(1).max(2048),
|
||||||
redirectDev: zod.string().max(2048).optional(),
|
redirectDev: zod.string().min(1).max(2048).optional(),
|
||||||
notification: zod.string().max(2048).optional(),
|
notification: zod.string().min(1).max(2048).optional(),
|
||||||
/**
|
/**
|
||||||
* Expiration time
|
* Expiration time
|
||||||
*/
|
*/
|
||||||
@ -20,6 +21,7 @@ export const ZodApplication = ZodGenericDataSoftDelete.extend({
|
|||||||
* Right is manage with Karso
|
* Right is manage with Karso
|
||||||
*/
|
*/
|
||||||
manageRight: zod.boolean(),
|
manageRight: zod.boolean(),
|
||||||
|
users: zod.array(ZodLong),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -34,23 +36,61 @@ export function isApplication(data: any): data is Application {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodApplicationUpdate = ZodGenericDataSoftDeleteUpdate.extend({
|
||||||
|
name: zod.string().min(1).max(256).nullable().optional(),
|
||||||
|
description: zod.string().min(1).max(2048).nullable().optional(),
|
||||||
|
redirect: zod.string().min(1).max(2048),
|
||||||
|
redirectDev: zod.string().min(1).max(2048).nullable().optional(),
|
||||||
|
notification: zod.string().min(1).max(2048).nullable().optional(),
|
||||||
|
/**
|
||||||
|
* Expiration time
|
||||||
|
*/
|
||||||
|
ttl: ZodInteger,
|
||||||
|
/**
|
||||||
|
* Right is manage with Karso
|
||||||
|
*/
|
||||||
|
manageRight: zod.boolean(),
|
||||||
|
users: zod.array(ZodLong),
|
||||||
|
|
||||||
export const ZodApplicationWrite = ZodApplication.omit({
|
});
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
export type ApplicationUpdate = zod.infer<typeof ZodApplicationUpdate>;
|
||||||
|
|
||||||
export type ApplicationWrite = zod.infer<typeof ZodApplicationWrite>;
|
export function isApplicationUpdate(data: any): data is ApplicationUpdate {
|
||||||
|
|
||||||
export function isApplicationWrite(data: any): data is ApplicationWrite {
|
|
||||||
try {
|
try {
|
||||||
ZodApplicationWrite.parse(data);
|
ZodApplicationUpdate.parse(data);
|
||||||
return true;
|
return true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(`Fail to parse data type='ZodApplicationWrite' error=${e}`);
|
console.log(`Fail to parse data type='ZodApplicationUpdate' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodApplicationCreate = ZodGenericDataSoftDeleteCreate.extend({
|
||||||
|
name: zod.string().min(1).max(256).nullable().optional(),
|
||||||
|
description: zod.string().min(1).max(2048).nullable().optional(),
|
||||||
|
redirect: zod.string().min(1).max(2048),
|
||||||
|
redirectDev: zod.string().min(1).max(2048).nullable().optional(),
|
||||||
|
notification: zod.string().min(1).max(2048).nullable().optional(),
|
||||||
|
/**
|
||||||
|
* Expiration time
|
||||||
|
*/
|
||||||
|
ttl: ZodInteger,
|
||||||
|
/**
|
||||||
|
* Right is manage with Karso
|
||||||
|
*/
|
||||||
|
manageRight: zod.boolean(),
|
||||||
|
users: zod.array(ZodLong),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ApplicationCreate = zod.infer<typeof ZodApplicationCreate>;
|
||||||
|
|
||||||
|
export function isApplicationCreate(data: any): data is ApplicationCreate {
|
||||||
|
try {
|
||||||
|
ZodApplicationCreate.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodApplicationCreate' error=${e}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ import { z as zod } from "zod";
|
|||||||
|
|
||||||
|
|
||||||
export const ZodChangePassword = zod.object({
|
export const ZodChangePassword = zod.object({
|
||||||
method: zod.string().max(32).optional(),
|
method: zod.string().min(2).max(2),
|
||||||
login: zod.string().max(512).optional(),
|
login: zod.string().min(3).max(128),
|
||||||
time: zod.string().max(64).optional(),
|
time: zod.string().min(20).max(64),
|
||||||
password: zod.string().max(128).optional(),
|
password: zod.string().min(128).max(128),
|
||||||
newPassword: zod.string().max(128).optional(),
|
newPassword: zod.string().min(128).max(128),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -24,17 +24,3 @@ export function isChangePassword(data: any): data is ChangePassword {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodChangePasswordWrite = ZodChangePassword.partial();
|
|
||||||
|
|
||||||
export type ChangePasswordWrite = zod.infer<typeof ZodChangePasswordWrite>;
|
|
||||||
|
|
||||||
export function isChangePasswordWrite(data: any): data is ChangePasswordWrite {
|
|
||||||
try {
|
|
||||||
ZodChangePasswordWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodChangePasswordWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -6,7 +6,7 @@ import { z as zod } from "zod";
|
|||||||
|
|
||||||
export const ZodClientToken = zod.object({
|
export const ZodClientToken = zod.object({
|
||||||
url: zod.string().max(1024).optional(),
|
url: zod.string().max(1024).optional(),
|
||||||
jwt: zod.string().optional(),
|
jwt: zod.string().max(1024).optional(),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -21,17 +21,3 @@ export function isClientToken(data: any): data is ClientToken {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodClientTokenWrite = ZodClientToken.partial();
|
|
||||||
|
|
||||||
export type ClientTokenWrite = zod.infer<typeof ZodClientTokenWrite>;
|
|
||||||
|
|
||||||
export function isClientTokenWrite(data: any): data is ClientTokenWrite {
|
|
||||||
try {
|
|
||||||
ZodClientTokenWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodClientTokenWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -6,7 +6,7 @@ import { z as zod } from "zod";
|
|||||||
import {ZodInteger} from "./integer";
|
import {ZodInteger} from "./integer";
|
||||||
|
|
||||||
export const ZodCreateTokenRequest = zod.object({
|
export const ZodCreateTokenRequest = zod.object({
|
||||||
name: zod.string().max(255).optional(),
|
name: zod.string().optional(),
|
||||||
validity: ZodInteger.optional(),
|
validity: ZodInteger.optional(),
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -22,17 +22,3 @@ export function isCreateTokenRequest(data: any): data is CreateTokenRequest {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodCreateTokenRequestWrite = ZodCreateTokenRequest.partial();
|
|
||||||
|
|
||||||
export type CreateTokenRequestWrite = zod.infer<typeof ZodCreateTokenRequestWrite>;
|
|
||||||
|
|
||||||
export function isCreateTokenRequestWrite(data: any): data is CreateTokenRequestWrite {
|
|
||||||
try {
|
|
||||||
ZodCreateTokenRequestWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodCreateTokenRequestWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -5,6 +5,10 @@ import { z as zod } from "zod";
|
|||||||
|
|
||||||
|
|
||||||
export const ZodDataGetToken = zod.object({
|
export const ZodDataGetToken = zod.object({
|
||||||
|
login: zod.string().min(3).max(128),
|
||||||
|
method: zod.string().min(2).max(2),
|
||||||
|
time: zod.string().min(20).max(64),
|
||||||
|
password: zod.string().min(128).max(128),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -19,17 +23,3 @@ export function isDataGetToken(data: any): data is DataGetToken {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodDataGetTokenWrite = ZodDataGetToken.partial();
|
|
||||||
|
|
||||||
export type DataGetTokenWrite = zod.infer<typeof ZodDataGetTokenWrite>;
|
|
||||||
|
|
||||||
export function isDataGetTokenWrite(data: any): data is DataGetTokenWrite {
|
|
||||||
try {
|
|
||||||
ZodDataGetTokenWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodDataGetTokenWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodGenericData} from "./generic-data";
|
import {ZodGenericData, ZodGenericDataUpdate , ZodGenericDataCreate } from "./generic-data";
|
||||||
|
|
||||||
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
||||||
/**
|
/**
|
||||||
@ -24,23 +24,29 @@ export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelet
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodGenericDataSoftDeleteUpdate = ZodGenericDataUpdate;
|
||||||
|
|
||||||
export const ZodGenericDataSoftDeleteWrite = ZodGenericDataSoftDelete.omit({
|
export type GenericDataSoftDeleteUpdate = zod.infer<typeof ZodGenericDataSoftDeleteUpdate>;
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
export function isGenericDataSoftDeleteUpdate(data: any): data is GenericDataSoftDeleteUpdate {
|
||||||
|
|
||||||
export type GenericDataSoftDeleteWrite = zod.infer<typeof ZodGenericDataSoftDeleteWrite>;
|
|
||||||
|
|
||||||
export function isGenericDataSoftDeleteWrite(data: any): data is GenericDataSoftDeleteWrite {
|
|
||||||
try {
|
try {
|
||||||
ZodGenericDataSoftDeleteWrite.parse(data);
|
ZodGenericDataSoftDeleteUpdate.parse(data);
|
||||||
return true;
|
return true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(`Fail to parse data type='ZodGenericDataSoftDeleteWrite' error=${e}`);
|
console.log(`Fail to parse data type='ZodGenericDataSoftDeleteUpdate' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodGenericDataSoftDeleteCreate = ZodGenericDataCreate;
|
||||||
|
|
||||||
|
export type GenericDataSoftDeleteCreate = zod.infer<typeof ZodGenericDataSoftDeleteCreate>;
|
||||||
|
|
||||||
|
export function isGenericDataSoftDeleteCreate(data: any): data is GenericDataSoftDeleteCreate {
|
||||||
|
try {
|
||||||
|
ZodGenericDataSoftDeleteCreate.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodGenericDataSoftDeleteCreate' error=${e}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodGenericTiming} from "./generic-timing";
|
import {ZodGenericTiming, ZodGenericTimingUpdate , ZodGenericTimingCreate } from "./generic-timing";
|
||||||
|
|
||||||
export const ZodGenericData = ZodGenericTiming.extend({
|
export const ZodGenericData = ZodGenericTiming.extend({
|
||||||
/**
|
/**
|
||||||
@ -25,22 +25,29 @@ export function isGenericData(data: any): data is GenericData {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodGenericDataUpdate = ZodGenericTimingUpdate;
|
||||||
|
|
||||||
export const ZodGenericDataWrite = ZodGenericData.omit({
|
export type GenericDataUpdate = zod.infer<typeof ZodGenericDataUpdate>;
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
export function isGenericDataUpdate(data: any): data is GenericDataUpdate {
|
||||||
|
|
||||||
export type GenericDataWrite = zod.infer<typeof ZodGenericDataWrite>;
|
|
||||||
|
|
||||||
export function isGenericDataWrite(data: any): data is GenericDataWrite {
|
|
||||||
try {
|
try {
|
||||||
ZodGenericDataWrite.parse(data);
|
ZodGenericDataUpdate.parse(data);
|
||||||
return true;
|
return true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(`Fail to parse data type='ZodGenericDataWrite' error=${e}`);
|
console.log(`Fail to parse data type='ZodGenericDataUpdate' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodGenericDataCreate = ZodGenericTimingCreate;
|
||||||
|
|
||||||
|
export type GenericDataCreate = zod.infer<typeof ZodGenericDataCreate>;
|
||||||
|
|
||||||
|
export function isGenericDataCreate(data: any): data is GenericDataCreate {
|
||||||
|
try {
|
||||||
|
ZodGenericDataCreate.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodGenericDataCreate' error=${e}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,21 +28,33 @@ export function isGenericTiming(data: any): data is GenericTiming {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodGenericTimingUpdate = zod.object({
|
||||||
|
|
||||||
export const ZodGenericTimingWrite = ZodGenericTiming.omit({
|
});
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
export type GenericTimingUpdate = zod.infer<typeof ZodGenericTimingUpdate>;
|
||||||
|
|
||||||
export type GenericTimingWrite = zod.infer<typeof ZodGenericTimingWrite>;
|
export function isGenericTimingUpdate(data: any): data is GenericTimingUpdate {
|
||||||
|
|
||||||
export function isGenericTimingWrite(data: any): data is GenericTimingWrite {
|
|
||||||
try {
|
try {
|
||||||
ZodGenericTimingWrite.parse(data);
|
ZodGenericTimingUpdate.parse(data);
|
||||||
return true;
|
return true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(`Fail to parse data type='ZodGenericTimingWrite' error=${e}`);
|
console.log(`Fail to parse data type='ZodGenericTimingUpdate' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodGenericTimingCreate = zod.object({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type GenericTimingCreate = zod.infer<typeof ZodGenericTimingCreate>;
|
||||||
|
|
||||||
|
export function isGenericTimingCreate(data: any): data is GenericTimingCreate {
|
||||||
|
try {
|
||||||
|
ZodGenericTimingCreate.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodGenericTimingCreate' error=${e}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteUpdate , ZodGenericDataSoftDeleteCreate } from "./generic-data-soft-delete";
|
||||||
import {ZodTimestamp} from "./timestamp";
|
import {ZodTimestamp} from "./timestamp";
|
||||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
|
||||||
|
|
||||||
export const ZodGenericToken = ZodGenericDataSoftDelete.extend({
|
export const ZodGenericToken = ZodGenericDataSoftDelete.extend({
|
||||||
parentId: ZodLong,
|
parentId: ZodLong,
|
||||||
@ -26,23 +26,3 @@ export function isGenericToken(data: any): data is GenericToken {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodGenericTokenWrite = ZodGenericToken.omit({
|
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type GenericTokenWrite = zod.infer<typeof ZodGenericTokenWrite>;
|
|
||||||
|
|
||||||
export function isGenericTokenWrite(data: any): data is GenericTokenWrite {
|
|
||||||
try {
|
|
||||||
ZodGenericTokenWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodGenericTokenWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -20,17 +20,3 @@ export function isGetSignUpAvailable(data: any): data is GetSignUpAvailable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodGetSignUpAvailableWrite = ZodGetSignUpAvailable.partial();
|
|
||||||
|
|
||||||
export type GetSignUpAvailableWrite = zod.infer<typeof ZodGetSignUpAvailableWrite>;
|
|
||||||
|
|
||||||
export function isGetSignUpAvailableWrite(data: any): data is GetSignUpAvailableWrite {
|
|
||||||
try {
|
|
||||||
ZodGetSignUpAvailableWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodGetSignUpAvailableWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -20,17 +20,3 @@ export function isGetToken(data: any): data is GetToken {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodGetTokenWrite = ZodGetToken.partial();
|
|
||||||
|
|
||||||
export type GetTokenWrite = zod.infer<typeof ZodGetTokenWrite>;
|
|
||||||
|
|
||||||
export function isGetTokenWrite(data: any): data is GetTokenWrite {
|
|
||||||
try {
|
|
||||||
ZodGetTokenWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodGetTokenWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -15,12 +15,17 @@ export * from "./generic-timing"
|
|||||||
export * from "./generic-token"
|
export * from "./generic-token"
|
||||||
export * from "./get-sign-up-available"
|
export * from "./get-sign-up-available"
|
||||||
export * from "./get-token"
|
export * from "./get-token"
|
||||||
export * from "./int"
|
|
||||||
export * from "./integer"
|
export * from "./integer"
|
||||||
export * from "./iso-date"
|
export * from "./iso-date"
|
||||||
|
export * from "./jwt-header"
|
||||||
|
export * from "./jwt-payload"
|
||||||
|
export * from "./jwt-token"
|
||||||
export * from "./long"
|
export * from "./long"
|
||||||
|
export * from "./object-id"
|
||||||
|
export * from "./part-right"
|
||||||
export * from "./public-key"
|
export * from "./public-key"
|
||||||
export * from "./rest-error-response"
|
export * from "./rest-error-response"
|
||||||
|
export * from "./rest-input-error"
|
||||||
export * from "./right"
|
export * from "./right"
|
||||||
export * from "./right-description"
|
export * from "./right-description"
|
||||||
export * from "./timestamp"
|
export * from "./timestamp"
|
||||||
|
23
front/src/back-api/model/jwt-header.ts
Normal file
23
front/src/back-api/model/jwt-header.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodJwtHeader = zod.object({
|
||||||
|
typ: zod.string().max(128),
|
||||||
|
alg: zod.string().max(128),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type JwtHeader = zod.infer<typeof ZodJwtHeader>;
|
||||||
|
|
||||||
|
export function isJwtHeader(data: any): data is JwtHeader {
|
||||||
|
try {
|
||||||
|
ZodJwtHeader.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodJwtHeader' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
29
front/src/back-api/model/jwt-payload.ts
Normal file
29
front/src/back-api/model/jwt-payload.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodLong} from "./long";
|
||||||
|
|
||||||
|
export const ZodJwtPayload = zod.object({
|
||||||
|
sub: zod.string(),
|
||||||
|
application: zod.string(),
|
||||||
|
iss: zod.string(),
|
||||||
|
right: zod.record(zod.string(), zod.record(zod.string(), ZodLong)),
|
||||||
|
login: zod.string(),
|
||||||
|
exp: ZodLong,
|
||||||
|
iat: ZodLong,
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type JwtPayload = zod.infer<typeof ZodJwtPayload>;
|
||||||
|
|
||||||
|
export function isJwtPayload(data: any): data is JwtPayload {
|
||||||
|
try {
|
||||||
|
ZodJwtPayload.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodJwtPayload' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
26
front/src/back-api/model/jwt-token.ts
Normal file
26
front/src/back-api/model/jwt-token.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodJwtHeader} from "./jwt-header";
|
||||||
|
import {ZodJwtPayload} from "./jwt-payload";
|
||||||
|
|
||||||
|
export const ZodJwtToken = zod.object({
|
||||||
|
header: ZodJwtHeader,
|
||||||
|
payload: ZodJwtPayload,
|
||||||
|
signature: zod.string(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type JwtToken = zod.infer<typeof ZodJwtToken>;
|
||||||
|
|
||||||
|
export function isJwtToken(data: any): data is JwtToken {
|
||||||
|
try {
|
||||||
|
ZodJwtToken.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodJwtToken' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
8
front/src/back-api/model/object-id.ts
Normal file
8
front/src/back-api/model/object-id.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodObjectId = zod.string().length(24, "Invalid ObjectId length").regex(/^[a-fA-F0-9]{24}$/, "Invalid ObjectId format");
|
||||||
|
export type ObjectId = zod.infer<typeof ZodObjectId>;
|
24
front/src/back-api/model/part-right.ts
Normal file
24
front/src/back-api/model/part-right.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export enum PartRight {
|
||||||
|
READ = 1,
|
||||||
|
NONE = 0,
|
||||||
|
WRITE = 2,
|
||||||
|
READ_WRITE = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ZodPartRight = zod.nativeEnum(PartRight);
|
||||||
|
|
||||||
|
export function isPartRight(data: any): data is PartRight {
|
||||||
|
try {
|
||||||
|
ZodPartRight.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodPartRight' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ import { z as zod } from "zod";
|
|||||||
|
|
||||||
|
|
||||||
export const ZodPublicKey = zod.object({
|
export const ZodPublicKey = zod.object({
|
||||||
key: zod.string().max(255).optional(),
|
key: zod.string().optional(),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -20,17 +20,3 @@ export function isPublicKey(data: any): data is PublicKey {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodPublicKeyWrite = ZodPublicKey.partial();
|
|
||||||
|
|
||||||
export type PublicKeyWrite = zod.infer<typeof ZodPublicKeyWrite>;
|
|
||||||
|
|
||||||
export function isPublicKeyWrite(data: any): data is PublicKeyWrite {
|
|
||||||
try {
|
|
||||||
ZodPublicKeyWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodPublicKeyWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -3,16 +3,18 @@
|
|||||||
*/
|
*/
|
||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodUUID} from "./uuid";
|
import {ZodRestInputError} from "./rest-input-error";
|
||||||
import {Zodint} from "./int";
|
import {ZodObjectId} from "./object-id";
|
||||||
|
import {ZodInteger} from "./integer";
|
||||||
|
|
||||||
export const ZodRestErrorResponse = zod.object({
|
export const ZodRestErrorResponse = zod.object({
|
||||||
uuid: ZodUUID.optional(),
|
oid: ZodObjectId.optional(),
|
||||||
name: zod.string(),
|
name: zod.string(),
|
||||||
message: zod.string(),
|
message: zod.string(),
|
||||||
time: zod.string(),
|
time: zod.string(),
|
||||||
status: Zodint,
|
status: ZodInteger,
|
||||||
statusMessage: zod.string(),
|
statusMessage: zod.string(),
|
||||||
|
inputError: zod.array(ZodRestInputError).optional(),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -27,17 +29,3 @@ export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodRestErrorResponseWrite = ZodRestErrorResponse.partial();
|
|
||||||
|
|
||||||
export type RestErrorResponseWrite = zod.infer<typeof ZodRestErrorResponseWrite>;
|
|
||||||
|
|
||||||
export function isRestErrorResponseWrite(data: any): data is RestErrorResponseWrite {
|
|
||||||
try {
|
|
||||||
ZodRestErrorResponseWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodRestErrorResponseWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteUpdate , ZodGenericDataSoftDeleteCreate } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodRightDescription = ZodGenericDataSoftDelete.extend({
|
export const ZodRightDescription = ZodGenericDataSoftDelete.extend({
|
||||||
/**
|
/**
|
||||||
@ -14,23 +14,15 @@ export const ZodRightDescription = ZodGenericDataSoftDelete.extend({
|
|||||||
/**
|
/**
|
||||||
* Key of the property
|
* Key of the property
|
||||||
*/
|
*/
|
||||||
key: zod.string().max(64),
|
key: zod.string().min(1).max(64),
|
||||||
/**
|
/**
|
||||||
* Title of the right
|
* Title of the right
|
||||||
*/
|
*/
|
||||||
title: zod.string().max(1024),
|
title: zod.string().min(1).max(1024),
|
||||||
/**
|
/**
|
||||||
* Description of the right
|
* Description of the right
|
||||||
*/
|
*/
|
||||||
description: zod.string().max(1024),
|
description: zod.string().max(1024),
|
||||||
/**
|
|
||||||
* default value if Never set
|
|
||||||
*/
|
|
||||||
defaultValue: zod.string().max(1024).optional(),
|
|
||||||
/**
|
|
||||||
* Type of the property
|
|
||||||
*/
|
|
||||||
type: zod.string().max(16),
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -45,23 +37,3 @@ export function isRightDescription(data: any): data is RightDescription {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodRightDescriptionWrite = ZodRightDescription.omit({
|
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type RightDescriptionWrite = zod.infer<typeof ZodRightDescriptionWrite>;
|
|
||||||
|
|
||||||
export function isRightDescriptionWrite(data: any): data is RightDescriptionWrite {
|
|
||||||
try {
|
|
||||||
ZodRightDescriptionWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodRightDescriptionWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteUpdate , ZodGenericDataSoftDeleteCreate } from "./generic-data-soft-delete";
|
||||||
|
import {ZodPartRight} from "./part-right";
|
||||||
|
|
||||||
export const ZodRight = ZodGenericDataSoftDelete.extend({
|
export const ZodRight = ZodGenericDataSoftDelete.extend({
|
||||||
/**
|
/**
|
||||||
@ -22,7 +23,7 @@ export const ZodRight = ZodGenericDataSoftDelete.extend({
|
|||||||
/**
|
/**
|
||||||
* Value of the right
|
* Value of the right
|
||||||
*/
|
*/
|
||||||
value: zod.string().max(1024),
|
value: ZodPartRight.optional(),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -37,23 +38,65 @@ export function isRight(data: any): data is Right {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodRightUpdate = ZodGenericDataSoftDeleteUpdate.extend({
|
||||||
|
/**
|
||||||
|
* application-ID that have the reference of the right
|
||||||
|
*/
|
||||||
|
applicationId: ZodLong,
|
||||||
|
/**
|
||||||
|
* user-ID
|
||||||
|
*/
|
||||||
|
userId: ZodLong,
|
||||||
|
/**
|
||||||
|
* rightDescription-ID of the right description
|
||||||
|
*/
|
||||||
|
rightDescriptionId: ZodLong,
|
||||||
|
/**
|
||||||
|
* Value of the right
|
||||||
|
*/
|
||||||
|
value: ZodPartRight.nullable().optional(),
|
||||||
|
|
||||||
export const ZodRightWrite = ZodRight.omit({
|
});
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
export type RightUpdate = zod.infer<typeof ZodRightUpdate>;
|
||||||
|
|
||||||
export type RightWrite = zod.infer<typeof ZodRightWrite>;
|
export function isRightUpdate(data: any): data is RightUpdate {
|
||||||
|
|
||||||
export function isRightWrite(data: any): data is RightWrite {
|
|
||||||
try {
|
try {
|
||||||
ZodRightWrite.parse(data);
|
ZodRightUpdate.parse(data);
|
||||||
return true;
|
return true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(`Fail to parse data type='ZodRightWrite' error=${e}`);
|
console.log(`Fail to parse data type='ZodRightUpdate' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodRightCreate = ZodGenericDataSoftDeleteCreate.extend({
|
||||||
|
/**
|
||||||
|
* application-ID that have the reference of the right
|
||||||
|
*/
|
||||||
|
applicationId: ZodLong,
|
||||||
|
/**
|
||||||
|
* user-ID
|
||||||
|
*/
|
||||||
|
userId: ZodLong,
|
||||||
|
/**
|
||||||
|
* rightDescription-ID of the right description
|
||||||
|
*/
|
||||||
|
rightDescriptionId: ZodLong,
|
||||||
|
/**
|
||||||
|
* Value of the right
|
||||||
|
*/
|
||||||
|
value: ZodPartRight.nullable().optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type RightCreate = zod.infer<typeof ZodRightCreate>;
|
||||||
|
|
||||||
|
export function isRightCreate(data: any): data is RightCreate {
|
||||||
|
try {
|
||||||
|
ZodRightCreate.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodRightCreate' error=${e}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user