Compare commits

..

No commits in common. "b9b2c12b04cad229130dd1053608e64eb6560597" and "a96d4ccc7dfba052c0e7bb02c657d2ca79cc1b61" have entirely different histories.

6 changed files with 21 additions and 98 deletions

View File

@ -6,6 +6,12 @@ jobs:
name: SonarQube Trigger name: SonarQube Trigger
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Debug Gitea variables
run: |
echo "GITEA_REF: ${GITEA_REF}"
echo "GITEA_SHA: ${GITEA_SHA}"
echo "All env variables:"
env
- name: Checking out - name: Checking out
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
@ -13,10 +19,6 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: SonarQube Scan - name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v7.0.0 uses: SonarSource/sonarqube-scan-action@v7.0.0
args: >
-Dsonar.projectKey=pki-manager
-Dsonar.sources=. \
-Dsonar.host.url=${{secrets.SONAR_HOST}}
env: env:
SONAR_TOKEN: ${{secrets.SONAR_TOKEN}} SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
SONAR_HOST_URL: ${{secrets.SONAR_HOST}} SONAR_HOST_URL: http://infra.bv.stef.lan:9000

View File

@ -9,15 +9,13 @@ COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ./cmd/server RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ./cmd/server
FROM alpine:latest FROM alpine:latest
RUN apk --no-cache add ca-certificates \ RUN apk --no-cache add ca-certificates
&& addgroup -S nonroot \
&& adduser -S nonroot -G nonroot
WORKDIR /app WORKDIR /app
COPY --from=builder /app/main . COPY --from=builder /app/main .
COPY --from=builder /app/internal/web ./internal/web COPY --from=builder /app/internal/web ./internal/web
COPY --from=builder /app/certs ./certs COPY --from=builder /app/certs ./certs
USER nonroot
EXPOSE 8080 EXPOSE 8080
CMD ["./main"] CMD ["./main"]

View File

@ -1,75 +0,0 @@
# PKI-MANAGER
Permet de creer des CA subCA et de certificat client & server
**Pour le moment le code est en court de develloppement et ne DOIT PAS servir en production !!**
Langage du moteur GO
Fonctionalites non encore implementées:
- Authentification
- Chiffrement en base
- Ajout swagger
- Autre fonctions d'api
- Amélioration GUI
## API
- POST /api/v1/cas/ --> Creation d'une CA
- GET /api/v1/cas/ --> Liste mes CAs
- GET /api/v1/cas/:id --> Récuperation d'une CA
- PUT /api/v1/cas/:id --> Modification d'une CA
- DELETE /api/v1/cas/:id --> Effacement d'une CA
- GET /api/v1/cas/:id/download/cert --> Recuperation du fichier de certificat d'une CA (Format PEM)
- GET /api/v1/cas/:id/download/key --> Recuperation du fichier de clé d'une CA (Format PEM)
Idem pour les SubCA en modifiant l'appel part /api/v1/subcas/
Idem pour les Ceritificats en modifiant l'appel par /api/v1/certificates/
Ajout pour les certificats:
- GET /api/v1/certificates/:id/download/p12 Récuperation du certificat et de sont issuer au format pkcs12
## Configuration
Créer un fichier .env à la racine du projet contenant:
```
MONGO_INITDB_ROOT_USERNAME=<Nom du compte admin mongo>
MONGO_INITDB_ROOT_PASSWORD=<Mot de passe du compte admin mongo>
JWT_SECRET=mon-super-token-my-jwt-secret
EXTERNAL_PORT=<port expose port l'acces a l'application exemple:8080"
```
## Si besoin d'accéder à la base Mongodb:
Ajouter un export de port dans le service mongodb
```yaml
services:
mongodb:
...
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
- ./scripts/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
...
```
## Dev Web
Pour l'instant les repetoire contenant le code lié au web est monté via volume.
Vous pouvez donc modifier dynamiquement ce contenu sans avoir a rebuild.
docker-compose.yml
```yaml
pki-api:
...
volumes:
- ./internal/web/static:/app/internal/web/static
- ./internal/web/templates:/app/internal/web/templates
```
Pour locker le webcode, retirez ces montages
## Lancement:
```
docker compose up --build -d
```

View File

@ -19,14 +19,14 @@ services:
depends_on: depends_on:
- mongodb - mongodb
ports: ports:
- "${EXTERNAL_PORT}:8080" - "8080:8080"
environment: environment:
MONGODB_URI: mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongodb:27017/pki_db?authSource=admin MONGODB_URI: mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongodb:27017/pki_db?authSource=admin
JWT_SECRET: ${JWT_SECRET} JWT_SECRET: ${JWT_SECRET}
volumes: volumes:
- ./certs:/app/certs - ./certs:/app/certs
# - ./internal/web/static:/app/internal/web/static - ./internal/web/static:/app/internal/web/static
# - ./internal/web/templates:/app/internal/web/templates - ./internal/web/templates:/app/internal/web/templates
volumes: volumes:
mongodb_data: mongodb_data:

View File

@ -600,8 +600,8 @@ async fetchSubCAs() {
street_address: data.street_address || '', street_address: data.street_address || '',
postal_code: data.postal_code || '', postal_code: data.postal_code || '',
email: data.email || '', email: data.email || '',
key_size: Number.parseInt(data.key_size) || 4096, key_size: parseInt(data.key_size) || 4096,
valid_years: Number.parseInt(data.valid_years) || 10, valid_years: parseInt(data.valid_years) || 10,
is_root: data.is_root === 'true' is_root: data.is_root === 'true'
}) })
}); });
@ -641,8 +641,8 @@ async fetchSubCAs() {
province: data.province || '', province: data.province || '',
locality: data.locality || '', locality: data.locality || '',
parent_ca_id: data.parent_ca_id, parent_ca_id: data.parent_ca_id,
key_size: Number.parseInt(data.key_size) || 4096, key_size: parseInt(data.key_size) || 4096,
valid_years: Number.parseInt(data.valid_years) || 5 valid_years: parseInt(data.valid_years) || 5
}) })
}); });
@ -680,8 +680,8 @@ async fetchSubCAs() {
dns_names: dnsNames, dns_names: dnsNames,
ip_addresses: ipAddresses, ip_addresses: ipAddresses,
issuer_ca_id: data.issuer_ca_id, issuer_ca_id: data.issuer_ca_id,
key_size: Number.parseInt(data.key_size) || 2048, key_size: parseInt(data.key_size) || 2048,
valid_days: Number.parseInt(data.valid_days) || 365 valid_days: parseInt(data.valid_days) || 365
}) })
}); });

View File

@ -1,2 +0,0 @@
sonar.projectKey=pki-manager