Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

__init__.py 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #
  2. # Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
  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. #
  16. from .oauth import OAuthClient
  17. from .oidc import OIDCClient
  18. CLIENT_TYPES = {
  19. "oauth2": OAuthClient,
  20. "oidc": OIDCClient
  21. }
  22. def get_auth_client(config)->OAuthClient:
  23. channel_type = str(config.get("type", "")).lower()
  24. if channel_type == "":
  25. if config.get("issuer"):
  26. channel_type = "oidc"
  27. else:
  28. channel_type = "oauth2"
  29. client_class = CLIENT_TYPES.get(channel_type)
  30. if not client_class:
  31. raise ValueError(f"Unsupported type: {channel_type}")
  32. return client_class(config)