Coverage for gws-app/gws/base/auth/method.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""Base authentication method.""" 

2 

3from typing import Optional 

4import gws 

5 

6 

7class Config(gws.Config): 

8 """Common options for authentication methods.""" 

9 

10 secure: bool = True 

11 """Accept credentials only over HTTPS.""" 

12 allowInsecureFrom: Optional[list[str]] 

13 """IP addresses allowed to use this method without HTTPS.""" 

14 

15 

16class Object(gws.AuthMethod): 

17 """Base authentication method. 

18 

19 Reads the ``secure`` and ``allowInsecureFrom`` options, which the manager 

20 checks before it uses the method. Subclasses implement opening and closing 

21 sessions for web requests. 

22 """ 

23 

24 def configure(self): 

25 self.secure = self.cfg('secure') 

26 self.allowInsecureFrom = self.cfg('allowInsecureFrom', default=[])