diff --git a/configs/tokenskey.json b/configs/tokenskey.json new file mode 100644 index 0000000000000000000000000000000000000000..005f9dc4c2eb6aa22dc3c213bd2591e846f1bc98 --- /dev/null +++ b/configs/tokenskey.json @@ -0,0 +1,3 @@ +{ + "Key": "IZOEJFgX0z/Bfx403KdRjfA6FTMcJiOtUb9a4vMWhlU=" +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 6fbcdebbc0e6de24687b4f45440c2270cb06fb92..acf1773f51ce1bd176a32f888f0cad06b07ae04b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,11 +4,12 @@ services: image: test restart: unless-stopped ports: - - 8080:8080 + - 443:443 networks: backoffice: volumes: - ./nginx/site.conf:/etc/nginx/conf.d/default.conf + - ./nginx/nginx.conf:/etc/nginx/nginx.conf - ./cert.pem:/etc/nginx/cert.pem - ./key.pem:/etc/nginx/key.pem @@ -28,7 +29,7 @@ services: retries: 60 backend: - image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server:test + image: back networks: backoffice: depends_on: diff --git a/nginx/nginx.conf b/nginx/nginx.conf index bbb55f1abbc00ea4cfb5b8f3726e026f6bdade3e..af0a4a69be83e562124788fe33855439154811aa 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -1,4 +1,4 @@ -worker_processes 1; +worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; @@ -20,6 +20,7 @@ http { #tcp_nopush on; keepalive_timeout 65; + keepalive_requests 65; # Gzip conf gzip on; diff --git a/nginx/site.conf b/nginx/site.conf index cced783eaa86ba96da39cb797e1012305c7f5a76..07923aab2c279c5449fc34b7c3bf5a11ad085124 100644 --- a/nginx/site.conf +++ b/nginx/site.conf @@ -1,29 +1,27 @@ server { - listen 8080; - server_name localhost; + listen 443 ssl; + server_name localhost; + ssl_certificate /etc/nginx/cert.pem; + ssl_certificate_key /etc/nginx/key.pem; + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_ciphers HIGH:!aNULL:!MD5; location / { root /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ /index.html =404; - add_header Access-Control-Allow-Origin *; - proxy_ssl_certificate /etc/nginx/cert.pem; - proxy_ssl_certificate_key /etc/nginx/key.pem; } - location /api { - proxy_pass http://backend:1443/api; - add_header Access-Control-Allow-Origin *; + location /api { + proxy_pass https://backend:1443/api; + } location /OAuth2Login { - proxy_pass http://backend:1443/OAuth2Login; - add_header Access-Control-Allow-Origin *; + proxy_pass https://backend:1443/OAuth2Login; } location /OAuth2Callback { - proxy_pass http://backend:1443/OAuth2Callback; - add_header Access-Control-Allow-Origin *; + proxy_pass https://backend:1443/OAuth2Callback; } - location /Logout { - proxy_pass http://backend:1443/Logout; - add_header Access-Control-Allow-Origin *; + location /Logout { + proxy_pass https://backend:1443/Logout; } } diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts index aa4e1c1b1264799e29a4de3ad8bdff3a5dd99556..f1607e4b81a1fc77aa02ba28856e9d93de2acf5c 100644 --- a/src/hooks/useAuth.ts +++ b/src/hooks/useAuth.ts @@ -3,7 +3,7 @@ import axios from 'axios' import { UserContext } from './userContext' import { useHistory } from 'react-router-dom' -const _apiUrl: string = 'https://localhost:1443/' +const _apiUrl: string = 'https://localhost:443/' export interface Auth { loginUser: () => Promise<void> @@ -18,7 +18,7 @@ export const useAuth = (): Auth => { //login user const loginUser = async (): Promise<void> => { try { - await axios.get(`${_apiUrl}OAuth2Login`) + await axios.get(`${_apiUrl}OAuth2Login`, { withCredentials: true }) await setUserContext() } catch (e) { setError(e) @@ -37,7 +37,9 @@ export const useAuth = (): Auth => { //set user in context and push them home const setUserContext = async (): Promise<void> => { try { - const { data } = await axios.get(`${_apiUrl}api/common/WhoAmI`) + const { data } = await axios.get(`${_apiUrl}api/common/WhoAmI`, { + withCredentials: true, + }) if (data && setUser) { setUser(data) console.log('usertoContext', data) diff --git a/src/hooks/useFindUser.ts b/src/hooks/useFindUser.ts index 5a3c38eedb100f8bec0519f5895799fa229440fa..2d3ae84939351b8b64a9d19a34de65e241064609 100644 --- a/src/hooks/useFindUser.ts +++ b/src/hooks/useFindUser.ts @@ -5,7 +5,7 @@ import { User } from '../models/user.model' const useFindUser = () => { const [user, setUser] = useState<User | null>(null) const [isLoading, setLoading] = useState<boolean>(true) - const _apiUrl: string = 'https://localhost:1443/' + const _apiUrl: string = 'https://localhost:443/' useEffect(() => { async function findUser() { diff --git a/src/services/monthlyNews.service.ts b/src/services/monthlyNews.service.ts index 920018e7fd85a95c928eaa63520effaa817725a8..2185f2a010e2184d7f5de11d1396a09eeebc7917 100644 --- a/src/services/monthlyNews.service.ts +++ b/src/services/monthlyNews.service.ts @@ -5,7 +5,7 @@ import { toast } from 'react-toastify' export class MonthlyNewsService { private readonly _apiUrl: string constructor() { - this._apiUrl = 'https://localhost:1443/' + this._apiUrl = 'https://localhost:443/' } /** * Creates a quotation and header for selected month