Skip to content

Commit 6eae627

Browse files
committed
Add OIDC to the frontend
1 parent a49b491 commit 6eae627

File tree

3 files changed

+62
-18
lines changed

3 files changed

+62
-18
lines changed

site/src/components/SignInForm/SignInForm.stories.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,26 @@ WithGithub.args = {
9999
authMethods: {
100100
password: true,
101101
github: true,
102+
oidc: false,
103+
},
104+
}
105+
106+
export const WithOIDC = Template.bind({})
107+
WithOIDC.args = {
108+
...SignedOut.args,
109+
authMethods: {
110+
password: true,
111+
github: false,
112+
oidc: true,
113+
},
114+
}
115+
116+
export const WithGithubAndOIDC = Template.bind({})
117+
WithGithubAndOIDC.args = {
118+
...SignedOut.args,
119+
authMethods: {
120+
password: true,
121+
github: true,
122+
oidc: true,
102123
},
103124
}

site/src/components/SignInForm/SignInForm.tsx

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import Box from "@material-ui/core/Box"
12
import Button from "@material-ui/core/Button"
23
import Link from "@material-ui/core/Link"
34
import { makeStyles } from "@material-ui/core/styles"
45
import TextField from "@material-ui/core/TextField"
56
import GitHubIcon from "@material-ui/icons/GitHub"
7+
import KeyIcon from "@material-ui/icons/VpnKey"
68
import { ErrorSummary } from "components/ErrorSummary/ErrorSummary"
79
import { Stack } from "components/Stack/Stack"
810
import { FormikContextType, FormikTouched, useFormik } from "formik"
@@ -43,6 +45,7 @@ export const Language = {
4345
},
4446
passwordSignIn: "Sign In",
4547
githubSignIn: "GitHub",
48+
oidcSignIn: "OpenID Connect",
4649
}
4750

4851
const validationSchema = Yup.object({
@@ -155,32 +158,51 @@ export const SignInForm: FC<SignInFormProps> = ({
155158
</div>
156159
</Stack>
157160
</form>
158-
{authMethods?.github && (
161+
{(authMethods?.github || authMethods?.oidc) && (
159162
<>
160163
<div className={styles.divider}>
161164
<div className={styles.dividerLine} />
162165
<div className={styles.dividerLabel}>Or</div>
163166
<div className={styles.dividerLine} />
164167
</div>
165168

166-
<div>
167-
<Link
168-
underline="none"
169-
href={`/api/v2/users/oauth2/github/callback?redirect=${encodeURIComponent(
170-
redirectTo,
171-
)}`}
172-
>
173-
<Button
174-
startIcon={<GitHubIcon className={styles.buttonIcon} />}
175-
disabled={isLoading}
176-
fullWidth
177-
type="submit"
178-
variant="contained"
169+
<Box display="grid" gridGap="16px">
170+
{authMethods.github && (
171+
<Link
172+
underline="none"
173+
href={`/api/v2/users/oauth2/github/callback?redirect=${encodeURIComponent(
174+
redirectTo,
175+
)}`}
179176
>
180-
{Language.githubSignIn}
181-
</Button>
182-
</Link>
183-
</div>
177+
<Button
178+
startIcon={<GitHubIcon className={styles.buttonIcon} />}
179+
disabled={isLoading}
180+
fullWidth
181+
type="submit"
182+
variant="contained"
183+
>
184+
{Language.githubSignIn}
185+
</Button>
186+
</Link>
187+
)}
188+
189+
{authMethods.oidc && (
190+
<Link
191+
underline="none"
192+
href={`/api/v2/users/oidc/callback?redirect=${encodeURIComponent(redirectTo)}`}
193+
>
194+
<Button
195+
startIcon={<KeyIcon className={styles.buttonIcon} />}
196+
disabled={isLoading}
197+
fullWidth
198+
type="submit"
199+
variant="contained"
200+
>
201+
{Language.oidcSignIn}
202+
</Button>
203+
</Link>
204+
)}
205+
</Box>
184206
</>
185207
)}
186208
</>

site/src/testHelpers/entities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ export const MockUserAgent: Types.UserAgent = {
304304
export const MockAuthMethods: TypesGen.AuthMethods = {
305305
password: true,
306306
github: false,
307+
oidc: false,
307308
}
308309

309310
export const MockGitSSHKey: TypesGen.GitSSHKey = {

0 commit comments

Comments
 (0)