Coverage for rfpy/auth/webapp.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-24 10:52 +0000

1import logging 

2 

3from webob import Response 

4 

5from rfpy.auth.policy import PassthroughPolicy 

6from rfpy.suxint import Sux 

7from rfpy.web.base import WSGIApp 

8 

9 

10log = logging.getLogger(__name__) 

11 

12 

13auth_sux = Sux( 

14 "rfpy.auth.endpoints", 

15 "rfpy.auth.adaptors", 

16 models_module="rfpy.auth.adaptors", 

17 api_name="PostRFP Auth API", 

18) 

19 

20 

21class TokenAuthenticationApp(WSGIApp): 

22 """ 

23 Provides /login and /logout URLs for authenticating users by username/password 

24 """ 

25 

26 routes = {} 

27 

28 def __init__(self, **kwargs): 

29 if not kwargs.get("auth_policy", None): 

30 kwargs["auth_policy"] = PassthroughPolicy() 

31 super().__init__(**kwargs) 

32 

33 def validate_user(self, request): 

34 pass 

35 

36 def build_sux(self): 

37 self.sux_instance = auth_sux 

38 

39 

40@TokenAuthenticationApp.route("/status") 

41def status(request): 

42 """ 

43 Check that the app is running. 

44 

45 In auth/webapp so there is no authentication so this endpoint can be called 

46 from uptime monitoring tools 

47 """ 

48 return Response(body="ok", content_type="text/plain")