
    Bi_                     L    d dl Z d dlmZ d dlmZ d dlmZ  G d d          ZdS )    N)CORS)Flask)envc                   J    e Zd ZdZedefd            Zedefd            ZdS )SecurityConfigu   보안 설정 클래스appc           
         t          j        dddg          }t          j        d          dk    r|                    g d           t	          | |t          j        dg d	          t          j        d
g d          dd           dS )u   CORS 설정ALLOWED_ORIGINSzhttps://mlink.sellmall.co.krzhttps://www.sellmall.co.kr)defaultENVIRONMENTdevelopment)zhttp://localhost:3000zhttp://localhost:3001zhttp://127.0.0.1:3000zhttp://127.0.0.1:3001ALLOWED_METHODS)GETPOSTPUTDELETEOPTIONSALLOWED_HEADERS)zContent-TypeAuthorizationzX-Requested-WithzX-CSRF-TokenTi  )originsmethodsallow_headerssupports_credentialsmax_ageN)r   get_listgetextendr   )r   allowed_originss     L/var/www/html/web/mlink/mlink_AI_Server/mlink-backend/src/config/security.pyconfigure_corszSecurityConfig.configure_cors
   s     ,'8*(C
    7=!!]22"" $ $ $    	#L!2 = = =    ,'8 C C C    "&	
 	
 	
 	
 	
 	
    c                 &    | j         d             }dS )u   보안 헤더 설정c                     d| j         d<   d| j         d<   d| j         d<   d| j         d<   d	}|| j         d
<   d| j         d<   d| j         d<   | S )NnosniffzX-Content-Type-OptionsDENYzX-Frame-Optionsz1; mode=blockzX-XSS-Protectionz#max-age=31536000; includeSubDomainszStrict-Transport-Securityzdefault-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self' https://api.openai.com https://media.tenor.com; frame-ancestors 'none';zContent-Security-Policyzstrict-origin-when-cross-originzReferrer-Policyzmgeolocation=(), microphone=(), camera=(), payment=(), usb=(), magnetometer=(), gyroscope=(), accelerometer=()zPermissions-Policy)headers)responsecsps     r   add_security_headerszGSecurityConfig.configure_security_headers.<locals>.add_security_headers/   s     :CH5628H./3BH/0 =bH89*  ;>H67 3TH./# 12 Or!   N)after_request)r   r)   s     r   configure_security_headersz)SecurityConfig.configure_security_headers,   s+     
	#	 #	 
	#	 #	 #	r!   N)__name__
__module____qualname____doc__staticmethodr   r    r+    r!   r   r   r      sg        !!
E 
 
 
 \
B & & & & \& & &r!   r   )os
flask_corsr   flaskr   src.config.env_loaderr   r   r1   r!   r   <module>r6      s    				             % % % % % %L L L L L L L L L Lr!   