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

20 statements  

« prev     ^ index     » next       coverage.py v7.0.1, created at 2022-12-31 16:00 +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', 'rfpy.auth.adaptors', 

15 models_module='rfpy.auth.adaptors', 

16 api_name='PostRFP Auth API' 

17) 

18 

19 

20class TokenAuthenticationApp(WSGIApp): 

21 

22 ''' 

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

24 ''' 

25 routes = {} 

26 

27 def __init__(self, **kwargs): 

28 if not kwargs.get('auth_policy', None): 

29 kwargs['auth_policy'] = PassthroughPolicy() 

30 super().__init__(**kwargs) 

31 

32 def validate_user(self, request): 

33 pass 

34 

35 def build_sux(self): 

36 self.sux_instance = auth_sux 

37 

38 

39@TokenAuthenticationApp.route('/status') 

40def status(request): 

41 ''' 

42 Check that the app is running. 

43 

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

45 from uptime monitoring tools 

46 ''' 

47 return Response(body='ok', content_type='text/plain')