File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 1111from types import FrameType
1212from typing import List , Optional
1313
14+ import pyotp
1415import yaml
1516
1617from pyfilebrowser .modals import models , settings
@@ -212,10 +213,13 @@ def create_config(self) -> None:
212213 )
213214 self .logger .debug ("Extra settings - %s: %s" , key , value )
214215 final_settings [key ].update (value )
215- # Move the authenticator token to the expected location
216- final_settings ["auther" ][
217- "authenticator_token"
218- ] = self .env .config_settings .auther .token
216+ # Move the authenticator token to the expected location, if token is valid
217+ if self .env .config_settings .auther .token :
218+ totp = pyotp .TOTP (self .env .config_settings .auther .token )
219+ assert totp .verify (totp .now (), for_time = time .time ()), "Invalid auth_token!"
220+ final_settings ["auther" ][
221+ "authenticator_token"
222+ ] = self .env .config_settings .auther .token
219223 final_settings ["auther" ].pop ("token" )
220224 # Remove symlinks from the final settings
221225 final_settings ["server" ].pop ("symlinks" )
You can’t perform that action at this time.
0 commit comments