Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/pages/sso/index.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Card, Col, Layout, Row, Typography } from "antd";6import Link from "next/link";78import { to_human_list } from "@cocalc/util/misc";9import { StrategyAvatar } from "components/auth/sso";10import Footer from "components/landing/footer";11import Head from "components/landing/head";12import Header from "components/landing/header";13import Main from "components/landing/main";14import { ssoNav } from "components/sso";15import { Customize, CustomizeType } from "lib/customize";16import { getSSO } from "lib/sso/sso";17import { SSO } from "lib/sso/types";18import withCustomize from "lib/with-customize";1920const { Paragraph, Text } = Typography;2122interface Props {23customize: CustomizeType;24ssos: SSO[];25}2627export const SSO_SUBTITLE = "Single Sign On";2829export default function SignupIndex(props: Props) {30const { customize, ssos } = props;3132function renderDomains(domains) {33if (domains == null || domains.length === 0) return;34return <Text type="secondary">{to_human_list(domains ?? [])}</Text>;35}3637function extra(sso) {38return <Link href={`/sso/${sso.id}`}>more</Link>;39}4041function renderSSOs() {42return ssos.map((sso: SSO) => {43const strategy = {44name: sso.id,45size: 64,46backgroundColor: "",47icon: sso.icon,48display: sso.display,49} as const;50return (51<Col xs={12} md={6} key={sso.id}>52<Card53size="small"54title={<Text strong>{sso.display}</Text>}55extra={extra(sso)}56>57<Paragraph style={{ textAlign: "center" }}>58<StrategyAvatar strategy={strategy} size={64} />59</Paragraph>60<Paragraph style={{ textAlign: "center", marginBottom: 0 }}>61{renderDomains(sso.domains)}62</Paragraph>63</Card>64</Col>65);66});67}6869function renderSSOList(): JSX.Element {70if (ssos.length === 0) {71return (72<Text italic type="danger">73There are no 3rd party SSO providers available.74</Text>75);76} else {77return (78<Row gutter={[24, 24]} align={"top"} wrap={true}>79{renderSSOs()}80</Row>81);82}83}8485function main() {86return (87<>88<h1>{SSO_SUBTITLE}</h1>89<Paragraph>90Sign up at {customize.siteName} via one of these 3<sup>rd</sup> party91single sign-on mechanisms. You need to have an account at the92respective organization in order to complete the sign-up process.93Usually, this will be the only way you can sign up using your94organization specific email address.95</Paragraph>96<Paragraph>{renderSSOList()}</Paragraph>97</>98);99}100101return (102<Customize value={customize}>103<Head title={SSO_SUBTITLE} />104<Layout style={{ background: "white" }}>105<Header />106<Main nav={ssoNav()}>{main()}</Main>107<Footer />108</Layout>109</Customize>110);111}112113export async function getServerSideProps(context) {114const ssos = await getSSO();115return await withCustomize({ context, props: { ssos } });116}117118119