cas.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2015, 2016 OpenMarket Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. from ._base import Config
  16. class CasConfig(Config):
  17. """Cas Configuration
  18. cas_server_url: URL of CAS server
  19. """
  20. def read_config(self, config):
  21. cas_config = config.get("cas_config", None)
  22. if cas_config:
  23. self.cas_enabled = cas_config.get("enabled", True)
  24. self.cas_server_url = cas_config["server_url"]
  25. self.cas_service_url = cas_config["service_url"]
  26. self.cas_required_attributes = cas_config.get("required_attributes", {})
  27. else:
  28. self.cas_enabled = False
  29. self.cas_server_url = None
  30. self.cas_service_url = None
  31. self.cas_required_attributes = {}
  32. def default_config(self, config_dir_path, server_name, **kwargs):
  33. return """
  34. # Enable CAS for registration and login.
  35. #cas_config:
  36. # enabled: true
  37. # server_url: "https://cas-server.com"
  38. # service_url: "https://homesever.domain.com:8448"
  39. # #required_attributes:
  40. # # name: value
  41. """