Skip to content

Commit 0858ad0

Browse files
committed
Add query param to un-hide password auth
1 parent 97d9d46 commit 0858ad0

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

docs/admin/auth.md

+10
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ By default, Coder is accessible via password authentication.
55
The following steps explain how to set up GitHub OAuth or OpenID Connect.
66

77
If after configuring another authentication method you'd like to hide password authentication, you can configure that like so:
8+
89
```console
910
CODER_PASSWORD_AUTH_HIDDEN=true
1011
```
12+
13+
If your external authentication method(s) were to go down, you can un-hide password authentication with the following URL query parameter:
14+
15+
```console
16+
https://coder.domain.com/login?auth=password
17+
```
18+
1119
## GitHub
1220

1321
### Step 1: Configure the OAuth application in GitHub
@@ -80,12 +88,14 @@ Once complete, run `sudo service coder restart` to reboot Coder.
8088
> When a new user is created, the `preferred_username` claim becomes the username. If this claim is empty, the email address will be stripped of the domain, and become the username (e.g. `example@coder.com` becomes `example`).
8189
8290
If your OpenID Connect provider requires client TLS certificates for authentication, you can configure them like so:
91+
8392
```console
8493
CODER_TLS_CLIENT_CERT_FILE=/path/to/cert.pem
8594
CODER_TLS_CLIENT_KEY_FILE=/path/to/key.pem
8695
```
8796

8897
If you'd like to change the OpenID Connect button text and/or icon, you can configure them like so:
98+
8999
```console
90100
CODER_OIDC_SIGN_IN_TEXT="Sign in with Gitea"
91101
CODER_OIDC_ICON_URL=https://gitea.io/images/gitea.png

site/src/components/SignInForm/SignInForm.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { getFormHelpers, onChangeTrimmed } from "../../util/formUtils"
1414
import { Welcome } from "../Welcome/Welcome"
1515
import { LoadingButton } from "./../LoadingButton/LoadingButton"
1616
import { AlertBanner } from "components/AlertBanner/AlertBanner"
17+
import { ContactlessOutlined } from "@material-ui/icons"
18+
import { useSearchParams } from "react-router-dom"
1719

1820
/**
1921
* BuiltInAuthFormValues describes a form using built-in (email/password)
@@ -107,6 +109,7 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
107109
initialTouched,
108110
}) => {
109111
const styles = useStyles()
112+
const [searchParams] = useSearchParams()
110113

111114
const form: FormikContextType<BuiltInAuthFormValues> =
112115
useFormik<BuiltInAuthFormValues>({
@@ -128,10 +131,14 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
128131
loginErrors.authError,
129132
)
130133

134+
const passwordHidden = authMethods?.password.hidden
135+
const urlParamOverride = searchParams.get("auth") === "password"
136+
const showPasswordLogin = !passwordHidden || urlParamOverride
137+
131138
return (
132139
<>
133140
<Welcome />
134-
{!authMethods?.password.hidden && (
141+
{showPasswordLogin && (
135142
<form onSubmit={form.handleSubmit}>
136143
<Stack>
137144
{Object.keys(loginErrors).map(
@@ -177,7 +184,7 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
177184
</Stack>
178185
</form>
179186
)}
180-
{!authMethods?.password.hidden &&
187+
{showPasswordLogin &&
181188
(authMethods?.github.enabled || authMethods?.oidc.enabled) && (
182189
<div className={styles.divider}>
183190
<div className={styles.dividerLine} />

0 commit comments

Comments
 (0)