/packages/core/src/layout/Sidebar/DefaultProviderSettings.tsx

https://github.com/spotify/backstage · TypeScript · 89 lines · 72 code · 2 blank · 15 comment · 8 complexity · a329c853b613492920e39dc544f2ccc6 MD5 · raw file

  1. /*
  2. * Copyright 2020 Spotify AB
  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. import {
  17. configApiRef,
  18. githubAuthApiRef,
  19. gitlabAuthApiRef,
  20. googleAuthApiRef,
  21. oauth2ApiRef,
  22. oktaAuthApiRef,
  23. microsoftAuthApiRef,
  24. samlAuthApiRef,
  25. useApi,
  26. } from '@backstage/core-api';
  27. import Star from '@material-ui/icons/Star';
  28. import React from 'react';
  29. import { ProviderSettingsItem } from './Settings';
  30. export const DefaultProviderSettings = () => {
  31. const configApi = useApi(configApiRef);
  32. const providersConfig = configApi.getOptionalConfig('auth.providers');
  33. const providers = providersConfig?.keys() ?? [];
  34. return (
  35. <>
  36. {providers.includes('google') && (
  37. <ProviderSettingsItem
  38. title="Google"
  39. apiRef={googleAuthApiRef}
  40. icon={Star}
  41. />
  42. )}
  43. {providers.includes('microsoft') && (
  44. <ProviderSettingsItem
  45. title="Microsoft"
  46. apiRef={microsoftAuthApiRef}
  47. icon={Star}
  48. />
  49. )}
  50. {providers.includes('github') && (
  51. <ProviderSettingsItem
  52. title="Github"
  53. apiRef={githubAuthApiRef}
  54. icon={Star}
  55. />
  56. )}
  57. {providers.includes('gitlab') && (
  58. <ProviderSettingsItem
  59. title="Gitlab"
  60. apiRef={gitlabAuthApiRef}
  61. icon={Star}
  62. />
  63. )}
  64. {providers.includes('okta') && (
  65. <ProviderSettingsItem
  66. title="Okta"
  67. apiRef={oktaAuthApiRef}
  68. icon={Star}
  69. />
  70. )}
  71. {providers.includes('saml') && (
  72. <ProviderSettingsItem
  73. title="SAML"
  74. apiRef={samlAuthApiRef}
  75. icon={Star}
  76. />
  77. )}
  78. {providers.includes('oauth2') && (
  79. <ProviderSettingsItem
  80. title="YourOrg"
  81. apiRef={oauth2ApiRef}
  82. icon={Star}
  83. />
  84. )}
  85. </>
  86. );
  87. };