
    ic                    6    d Z ddlmZ ddlZddZdd	ZddZdS )zSecurity helper utilities for Star Office backend.

Production detection and validation for Flask secret and asset drawer password.
    )annotationsNreturnboolc                     t          j        d          pt          j        d          pd                                                                } | dv S )z?Return True if STAR_OFFICE_ENV or FLASK_ENV is prod/production.STAR_OFFICE_ENV	FLASK_ENV >   prod
production)osgetenvstriplower)envs    ./root/Star-Office-UI/backend/security_utils.pyis_production_moder      sJ    9&''G29[+A+AGR
N
N
P
P
V
V
X
XC(((    secretstrc                    | sdS |                                  } t          |           dk     rdS h d}|                                 t          fd|D                        S )zcReturn True if secret is at least 24 chars and does not contain weak markers (e.g. change-me, dev).F   >   	change-medevtestdefaultexamplec              3      K   | ]}|v V  	d S )N ).0mlows     r   	<genexpr>z#is_strong_secret.<locals>.<genexpr>   s'      2218222222r   )r   lenr   any)r   weak_markersr!   s     @r   is_strong_secretr&      sq     u\\^^F
6{{RuEEEL
,,..C2222\2222222r   pwdc                h    | sdS |                                  } | dk    rdS t          |           dk    S )zJReturn True if password is not default 1234 and has at least 8 characters.F1234   )r   r#   )r'   s    r   is_strong_drawer_passr+      s:     u
))++C
f}}us88q=r   )r   r   )r   r   r   r   )r'   r   r   r   )__doc__
__future__r   r   r   r&   r+   r   r   r   <module>r.      sr    
 # " " " " " 				) ) ) )	3 	3 	3 	3     r   