Compare commits

..

3 Commits

Author SHA1 Message Date
lebaudantoine
1c36ac281b update tag 2024-10-17 11:31:59 +02:00
lebaudantoine
0c6bebe74e wip expose a summary 2024-10-17 11:30:35 +02:00
Jacques ROUSSEL
b9a4653de6 🚀(docs-ia) deploy new environment
Because we use staging for German people, we need a new environment for
our demo
2024-10-17 10:17:47 +02:00
24 changed files with 2232 additions and 2270 deletions

View File

@@ -9,9 +9,6 @@ and this project adheres to
## [Unreleased]
## [1.6.0] - 2024-10-17
## Added
- ✨AI to doc editor #250
@@ -26,12 +23,8 @@ and this project adheres to
## Fixed
- 🛂(backend) do not duplicate user when disabled
- 🐛(frontend) invalidate queries after removing user #336
- 🐛(backend) Fix dysfunctional permissions on document create #329
- 🐛(backend) fix nginx docker container #340
- 🐛(frontend) fix copy paste firefox #353
## [1.5.1] - 2024-10-10
@@ -211,8 +204,7 @@ and this project adheres to
- 🚀 Impress, project to manage your documents easily and collaboratively.
[unreleased]: https://github.com/numerique-gouv/impress/compare/v1.6.0...main
[v1.6.0]: https://github.com/numerique-gouv/impress/releases/v1.6.0
[unreleased]: https://github.com/numerique-gouv/impress/compare/v1.5.1...main
[1.5.1]: https://github.com/numerique-gouv/impress/releases/v1.5.1
[1.5.0]: https://github.com/numerique-gouv/impress/releases/v1.5.0
[1.4.0]: https://github.com/numerique-gouv/impress/releases/v1.4.0

View File

@@ -122,7 +122,6 @@ logs: ## display app-dev logs (follow mode)
run: ## start the wsgi (production) and development server
@$(COMPOSE) up --force-recreate -d celery-dev
@$(COMPOSE) up --force-recreate -d nginx
@$(COMPOSE) up --force-recreate -d y-provider
@echo "Wait for postgresql to be up..."
@$(WAIT_DB)

View File

@@ -63,6 +63,7 @@ services:
- mailcatcher
- redis
- createbuckets
- nginx
celery-dev:
user: ${DOCKER_USER:-1000}
@@ -117,7 +118,6 @@ services:
- ./docker/files/etc/nginx/conf.d:/etc/nginx/conf.d:ro
depends_on:
- keycloak
- app-dev
frontend-dev:
user: "${DOCKER_USER:-1000}"

Submodule secrets updated: 38594182e8...59590c285c

View File

@@ -8,6 +8,8 @@ from rest_framework import views as drf_views
from rest_framework.decorators import api_view
from rest_framework.response import Response
from ..models import Document, User, RoleChoices, DocumentAccess
def exception_handler(exc, context):
"""Handle Django ValidationError as an accepted exception.
@@ -38,3 +40,32 @@ def get_frontend_configuration(request):
}
frontend_configuration.update(settings.FRONTEND_CONFIGURATION)
return Response(frontend_configuration)
@api_view(["POST"])
def create_summary(request):
"""Wip."""
data = request.data
document = Document(
title="Votre résumé",
link_reach="authenticated",
link_role="reader",
)
document.save()
owner_user = User.objects.get(email=data["owner"])
document_access = DocumentAccess(
user=owner_user,
document=document,
role=RoleChoices.OWNER
)
document_access.save()
document.content = data["content"]
document.save()
return Response({"id": document.id})

View File

@@ -84,8 +84,6 @@ class OIDCAuthenticationBackend(MozillaOIDCAuthenticationBackend):
user = self.get_existing_user(sub, email)
if user:
if not user.is_active:
raise SuspiciousOperation(_("User account is disabled"))
self.update_user_if_needed(user, claims)
elif self.get_settings("OIDC_CREATE_USER", True):
user = User.objects.create(sub=sub, password="!", **claims) # noqa: S106
@@ -103,11 +101,11 @@ class OIDCAuthenticationBackend(MozillaOIDCAuthenticationBackend):
def get_existing_user(self, sub, email):
"""Fetch existing user by sub or email."""
try:
return User.objects.get(sub=sub)
return User.objects.get(sub=sub, is_active=True)
except User.DoesNotExist:
if email and settings.OIDC_FALLBACK_TO_EMAIL_FOR_IDENTIFICATION:
try:
return User.objects.get(email=email)
return User.objects.get(email=email, is_active=True)
except User.DoesNotExist:
pass
return None

View File

@@ -305,63 +305,3 @@ def test_authentication_get_userinfo_invalid_response():
match="Invalid response format or token verification failed",
):
oidc_backend.get_userinfo("fake_access_token", None, None)
def test_authentication_getter_existing_disabled_user_via_sub(
django_assert_num_queries, monkeypatch
):
"""
If an existing user matches the sub but is disabled,
an error should be raised and a user should not be created.
"""
klass = OIDCAuthenticationBackend()
db_user = UserFactory(is_active=False)
def get_userinfo_mocked(*args):
return {
"sub": db_user.sub,
"email": db_user.email,
"first_name": "John",
"last_name": "Doe",
}
monkeypatch.setattr(OIDCAuthenticationBackend, "get_userinfo", get_userinfo_mocked)
with (
django_assert_num_queries(1),
pytest.raises(SuspiciousOperation, match="User account is disabled"),
):
klass.get_or_create_user(access_token="test-token", id_token=None, payload=None)
assert models.User.objects.count() == 1
def test_authentication_getter_existing_disabled_user_via_email(
django_assert_num_queries, monkeypatch
):
"""
If an existing user does not matches the sub but matches the email and is disabled,
an error should be raised and a user should not be created.
"""
klass = OIDCAuthenticationBackend()
db_user = UserFactory(is_active=False)
def get_userinfo_mocked(*args):
return {
"sub": "random",
"email": db_user.email,
"first_name": "John",
"last_name": "Doe",
}
monkeypatch.setattr(OIDCAuthenticationBackend, "get_userinfo", get_userinfo_mocked)
with (
django_assert_num_queries(2),
pytest.raises(SuspiciousOperation, match="User account is disabled"),
):
klass.get_or_create_user(access_token="test-token", id_token=None, payload=None)
assert models.User.objects.count() == 1

View File

@@ -5,7 +5,7 @@ from django.urls import include, path, re_path
from rest_framework.routers import DefaultRouter
from core.api import viewsets
from core.api import viewsets, create_summary
from core.authentication.urls import urlpatterns as oidc_urls
# - Main endpoints
@@ -44,6 +44,7 @@ urlpatterns = [
[
*router.urls,
*oidc_urls,
path("summary/", create_summary, name="create_summary"),
re_path(
r"^documents/(?P<resource_id>[0-9a-z-]*)/",
include(document_related_router.urls),

View File

@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "impress"
version = "1.6.0"
version = "1.5.1"
authors = [{ "name" = "DINUM", "email" = "dev@mail.numerique.gouv.fr" }]
classifiers = [
"Development Status :: 5 - Production/Stable",

View File

@@ -1,6 +1,6 @@
{
"name": "app-e2e",
"version": "1.6.0",
"version": "1.5.1",
"private": true,
"scripts": {
"lint": "eslint . --ext .ts",
@@ -12,7 +12,7 @@
"test:ui::chromium": "yarn test:ui --project=chromium"
},
"devDependencies": {
"@playwright/test": "1.48.1",
"@playwright/test": "1.47.2",
"@types/node": "*",
"@types/pdf-parse": "1.1.4",
"eslint-config-impress": "*",

View File

@@ -1,6 +1,6 @@
{
"name": "app-impress",
"version": "1.6.0",
"version": "1.5.1",
"private": true,
"scripts": {
"dev": "next dev",
@@ -19,36 +19,36 @@
"@blocknote/mantine": "*",
"@blocknote/react": "*",
"@gouvfr-lasuite/integration": "1.0.2",
"@hocuspocus/provider": "2.13.7",
"@hocuspocus/provider": "2.13.6",
"@openfun/cunningham-react": "2.9.4",
"@tanstack/react-query": "5.59.15",
"i18next": "23.16.0",
"@tanstack/react-query": "5.56.2",
"i18next": "23.15.1",
"idb": "8.0.0",
"lodash": "4.17.21",
"luxon": "3.5.0",
"next": "14.2.15",
"next": "14.2.13",
"react": "*",
"react-aria-components": "1.4.1",
"react-aria-components": "1.3.3",
"react-dom": "*",
"react-i18next": "15.0.3",
"react-i18next": "15.0.2",
"react-select": "5.8.1",
"styled-components": "6.1.13",
"y-protocols": "1.0.6",
"yjs": "*",
"zustand": "5.0.0"
"zustand": "4.5.5"
},
"devDependencies": {
"@svgr/webpack": "8.1.0",
"@tanstack/react-query-devtools": "5.59.15",
"@tanstack/react-query-devtools": "5.58.0",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.6.1",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "16.0.1",
"@testing-library/user-event": "14.5.2",
"@types/jest": "29.5.13",
"@types/lodash": "4.17.10",
"@types/lodash": "4.17.9",
"@types/luxon": "3.4.2",
"@types/node": "*",
"@types/react": "18.3.11",
"@types/react": "18.3.10",
"@types/react-dom": "*",
"cross-env": "*",
"dotenv": "16.4.5",
@@ -58,7 +58,7 @@
"jest-environment-jsdom": "29.7.0",
"node-fetch": "2.7.0",
"prettier": "3.3.3",
"stylelint": "16.10.0",
"stylelint": "16.9.0",
"stylelint-config-standard": "36.0.1",
"stylelint-prettier": "5.0.2",
"typescript": "*",

View File

@@ -374,7 +374,6 @@ const useHandleAIError = () => {
});
}
toast(t('AI seems busy! Please try again.'), VariantType.ERROR);
console.error(error);
},
[toast, t],

View File

@@ -5,7 +5,6 @@
"\"{{email}}\" is already invited to the document.": "\"{{email}}\" est déjà invité à accéder au document.",
"\"{{email}}\" is already member of the document.": "\"{{email}}\" est déjà membre du document.",
"AI Actions": "Actions IA",
"AI seems busy! Please try again.": "L'IA semble occupée ! Veuillez réessayer.",
"Accessibility": "Accessibilité",
"Accessibility statement": "Déclaration d'accessibilité",
"Address:": "Adresse :",

View File

@@ -1,6 +1,6 @@
{
"name": "impress",
"version": "1.6.0",
"version": "1.5.1",
"private": true,
"workspaces": {
"packages": [
@@ -25,18 +25,18 @@
"i18n:test": "yarn I18N run test"
},
"resolutions": {
"@blocknote/core": "0.17.0",
"@blocknote/mantine": "0.17.0",
"@blocknote/react": "0.17.0",
"@types/node": "20.16.12",
"@types/react-dom": "18.3.1",
"@typescript-eslint/eslint-plugin": "8.9.0",
"@typescript-eslint/parser": "8.9.0",
"@blocknote/core": "0.16.0",
"@blocknote/mantine": "0.16.0",
"@blocknote/react": "0.16.0",
"@types/node": "20.16.10",
"@types/react-dom": "18.3.0",
"@typescript-eslint/eslint-plugin": "8.7.0",
"@typescript-eslint/parser": "8.7.0",
"cross-env": "7.0.3",
"eslint": "8.57.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"typescript": "5.6.3",
"yjs": "13.6.20"
"typescript": "5.6.2",
"yjs": "13.6.19"
}
}

View File

@@ -1,24 +1,24 @@
{
"name": "eslint-config-impress",
"version": "1.6.0",
"version": "1.5.1",
"license": "MIT",
"scripts": {
"lint": "eslint --ext .js ."
},
"dependencies": {
"@next/eslint-plugin-next": "14.2.15",
"@tanstack/eslint-plugin-query": "5.59.7",
"@next/eslint-plugin-next": "14.2.13",
"@tanstack/eslint-plugin-query": "5.58.1",
"@typescript-eslint/eslint-plugin": "*",
"@typescript-eslint/parser": "*",
"eslint": "*",
"eslint-config-next": "14.2.15",
"eslint-config-next": "14.2.13",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-import": "2.30.0",
"eslint-plugin-jest": "28.8.3",
"eslint-plugin-jsx-a11y": "6.10.0",
"eslint-plugin-playwright": "1.7.0",
"eslint-plugin-playwright": "1.6.2",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-react": "7.37.1",
"eslint-plugin-react": "7.37.0",
"eslint-plugin-testing-library": "6.3.0",
"prettier": "3.3.3"
}

View File

@@ -1,6 +1,6 @@
{
"name": "packages-i18n",
"version": "1.6.0",
"version": "1.5.1",
"private": true,
"scripts": {
"extract-translation": "yarn extract-translation:impress",
@@ -15,7 +15,7 @@
"@types/jest": "29.5.13",
"@types/node": "*",
"eslint-config-impress": "*",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-import": "2.30.0",
"i18next-parser": "9.0.2",
"jest": "29.7.0",
"ts-jest": "29.2.5",

View File

@@ -1,6 +1,6 @@
{
"name": "server-y-provider",
"version": "1.6.0",
"version": "1.5.1",
"description": "Y.js provider for docs",
"repository": "https://github.com/numerique-gouv/impress",
"license": "MIT",
@@ -15,7 +15,7 @@
"node": ">=18"
},
"dependencies": {
"@hocuspocus/server": "2.13.7",
"@hocuspocus/server": "2.13.6",
"y-protocols": "1.0.6"
},
"devDependencies": {

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
../../../../secrets/numerique-gouv/impress/env/docs-ia/secrets.enc.yaml

View File

@@ -0,0 +1,184 @@
image:
repository: lasuite/impress-backend
pullPolicy: Always
tag: "v-demo"
backend:
migrateJobAnnotations:
argocd.argoproj.io/hook: PreSync
argocd.argoproj.io/hook-delete-policy: HookSucceeded
envVars:
AI_API_KEY:
secretKeyRef:
name: backend
key: AI_API_KEY
AI_BASE_URL:
secretKeyRef:
name: backend
key: AI_BASE_URL
AI_MODEL: meta-llama/Meta-Llama-3.1-70B-Instruct
DJANGO_CSRF_TRUSTED_ORIGINS: http://docs-ia.beta.numerique.gouv.fr,https://docs-ia.beta.numerique.gouv.fr
DJANGO_CONFIGURATION: Production
DJANGO_ALLOWED_HOSTS: "*"
DJANGO_SECRET_KEY:
secretKeyRef:
name: backend
key: DJANGO_SECRET_KEY
DJANGO_SETTINGS_MODULE: impress.settings
DJANGO_SUPERUSER_EMAIL:
secretKeyRef:
name: backend
key: DJANGO_SUPERUSER_EMAIL
DJANGO_SUPERUSER_PASSWORD:
secretKeyRef:
name: backend
key: DJANGO_SUPERUSER_PASSWORD
DJANGO_EMAIL_HOST: "smtp.tem.scw.cloud"
DJANGO_EMAIL_PORT: 587
DJANGO_EMAIL_USE_TLS: True
DJANGO_EMAIL_FROM: "noreply@docs.beta.numerique.gouv.fr"
DJANGO_EMAIL_HOST_USER:
secretKeyRef:
name: backend
key: DJANGO_EMAIL_HOST_USER
DJANGO_EMAIL_HOST_PASSWORD:
secretKeyRef:
name: backend
key: DJANGO_EMAIL_HOST_PASSWORD
DJANGO_SILENCED_SYSTEM_CHECKS: security.W008,security.W004
OIDC_OP_JWKS_ENDPOINT: https://fca.integ01.dev-agentconnect.fr/api/v2/jwks
OIDC_OP_AUTHORIZATION_ENDPOINT: https://fca.integ01.dev-agentconnect.fr/api/v2/authorize
OIDC_OP_TOKEN_ENDPOINT: https://fca.integ01.dev-agentconnect.fr/api/v2/token
OIDC_OP_USER_ENDPOINT: https://fca.integ01.dev-agentconnect.fr/api/v2/userinfo
OIDC_OP_LOGOUT_ENDPOINT: https://fca.integ01.dev-agentconnect.fr/api/v2/session/end
OIDC_RP_CLIENT_ID:
secretKeyRef:
name: backend
key: OIDC_RP_CLIENT_ID
OIDC_RP_CLIENT_SECRET:
secretKeyRef:
name: backend
key: OIDC_RP_CLIENT_SECRET
OIDC_RP_SIGN_ALGO: RS256
OIDC_RP_SCOPES: "openid email"
OIDC_REDIRECT_ALLOWED_HOSTS: https://docs-ia.beta.numerique.gouv.fr
OIDC_AUTH_REQUEST_EXTRA_PARAMS: "{'acr_values': 'eidas1'}"
LOGIN_REDIRECT_URL: https://docs-ia.beta.numerique.gouv.fr
LOGIN_REDIRECT_URL_FAILURE: https://docs-ia.beta.numerique.gouv.fr
LOGOUT_REDIRECT_URL: https://docs-ia.beta.numerique.gouv.fr
DB_HOST:
secretKeyRef:
name: postgresql.postgres.libre.sh
key: host
DB_NAME:
secretKeyRef:
name: postgresql.postgres.libre.sh
key: database
DB_USER:
secretKeyRef:
name: postgresql.postgres.libre.sh
key: username
DB_PASSWORD:
secretKeyRef:
name: postgresql.postgres.libre.sh
key: password
DB_PORT:
secretKeyRef:
name: postgresql.postgres.libre.sh
key: port
POSTGRES_USER:
secretKeyRef:
name: postgresql.postgres.libre.sh
key: username
POSTGRES_DB:
secretKeyRef:
name: postgresql.postgres.libre.sh
key: database
POSTGRES_PASSWORD:
secretKeyRef:
name: postgresql.postgres.libre.sh
key: password
REDIS_URL:
secretKeyRef:
name: redis.redis.libre.sh
key: url
AWS_S3_ENDPOINT_URL:
secretKeyRef:
name: impress-media-storage.bucket.libre.sh
key: url
AWS_S3_ACCESS_KEY_ID:
secretKeyRef:
name: impress-media-storage.bucket.libre.sh
key: accessKey
AWS_S3_SECRET_ACCESS_KEY:
secretKeyRef:
name: impress-media-storage.bucket.libre.sh
key: secretKey
AWS_STORAGE_BUCKET_NAME:
secretKeyRef:
name: impress-media-storage.bucket.libre.sh
key: bucket
AWS_S3_REGION_NAME: local
STORAGES_STATICFILES_BACKEND: django.contrib.staticfiles.storage.StaticFilesStorage
createsuperuser:
command:
- "/bin/sh"
- "-c"
- |
python manage.py createsuperuser --email $DJANGO_SUPERUSER_EMAIL --password $DJANGO_SUPERUSER_PASSWORD
restartPolicy: Never
frontend:
image:
repository: lasuite/impress-frontend
pullPolicy: Always
tag: "v-demo"
yProvider:
image:
repository: lasuite/impress-y-provider
pullPolicy: Always
tag: "v-demo"
ingress:
enabled: true
host: docs-ia.beta.numerique.gouv.fr
className: nginx
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
ingressWS:
enabled: true
host: docs-ia.beta.numerique.gouv.fr
className: nginx
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
ingressAdmin:
enabled: true
host: docs-ia.beta.numerique.gouv.fr
className: nginx
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
nginx.ingress.kubernetes.io/auth-signin: https://oauth2-proxy-preprod.beta.numerique.gouv.fr/oauth2/start
nginx.ingress.kubernetes.io/auth-url: https://oauth2-proxy-preprod.beta.numerique.gouv.fr/oauth2/auth
ingressMedia:
enabled: true
host: docs-ia.beta.numerique.gouv.fr
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
nginx.ingress.kubernetes.io/auth-response-headers: "Authorization, X-Amz-Date, X-Amz-Content-SHA256"
nginx.ingress.kubernetes.io/auth-url: https://docs-ia.beta.numerique.gouv.fr/api/v1.0/documents/retrieve-auth/
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/rewrite-target: /docs-ia-impress-media-storage/$1
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/upstream-vhost: s3.margaret-hamilton.indiehosters.net
serviceMedia:
host: s3.margaret-hamilton.indiehosters.net
port: 443

View File

@@ -1,7 +1,7 @@
image:
repository: lasuite/impress-backend
pullPolicy: Always
tag: "v1.6.0-preprod"
tag: "v1.5.1-preprod"
backend:
migrateJobAnnotations:
@@ -133,13 +133,13 @@ frontend:
image:
repository: lasuite/impress-frontend
pullPolicy: Always
tag: "v1.6.0-preprod"
tag: "v1.5.1-preprod"
yProvider:
image:
repository: lasuite/impress-y-provider
pullPolicy: Always
tag: "v1.6.0-preprod"
tag: "v1.5.1-preprod"
ingress:
enabled: true

View File

@@ -1,7 +1,7 @@
image:
repository: lasuite/impress-backend
pullPolicy: Always
tag: "v1.6.0"
tag: "v1.5.1"
backend:
migrateJobAnnotations:
@@ -133,13 +133,13 @@ frontend:
image:
repository: lasuite/impress-frontend
pullPolicy: Always
tag: "v1.6.0"
tag: "v1.5.1"
yProvider:
image:
repository: lasuite/impress-y-provider
pullPolicy: Always
tag: "v1.6.0"
tag: "v1.5.1"
ingress:
enabled: true

View File

@@ -70,6 +70,11 @@ environments:
- version: 0.0.1
secrets:
- env.d/{{ .Environment.Name }}/secrets.enc.yaml
docs-ia:
values:
- version: 0.0.1
secrets:
- env.d/{{ .Environment.Name }}/secrets.enc.yaml
preprod:
values:
- version: 0.0.1

View File

@@ -1,6 +1,6 @@
{
"name": "mail_mjml",
"version": "1.6.0",
"version": "1.5.1",
"description": "An util to generate html and text django's templates from mjml templates",
"type": "module",
"dependencies": {