Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit50d0dcb

Browse files
committed
fix: allow disabling all password auth even if owner
Removes any and all ability to auth with a password.
1 parenta54de60 commit50d0dcb

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

‎coderd/userauth.go‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/coder/coder/coderd/database"
2424
"github.com/coder/coder/coderd/httpapi"
2525
"github.com/coder/coder/coderd/httpmw"
26-
"github.com/coder/coder/coderd/rbac"
2726
"github.com/coder/coder/coderd/userpassword"
2827
"github.com/coder/coder/codersdk"
2928
)
@@ -89,19 +88,10 @@ func (api *API) postLogin(rw http.ResponseWriter, r *http.Request) {
8988
// If password authentication is disabled and the user does not have the
9089
// owner role, block the request.
9190
ifapi.DeploymentConfig.DisablePasswordAuth.Value {
92-
permitted:=false
93-
for_,role:=rangeuser.RBACRoles {
94-
ifrole==rbac.RoleOwner() {
95-
permitted=true
96-
break
97-
}
98-
}
99-
if!permitted {
100-
httpapi.Write(ctx,rw,http.StatusForbidden, codersdk.Response{
101-
Message:"Password authentication is disabled. Only administrators can sign in with password authentication.",
102-
})
103-
return
104-
}
91+
httpapi.Write(ctx,rw,http.StatusForbidden, codersdk.Response{
92+
Message:"Password authentication is disabled.",
93+
})
94+
return
10595
}
10696

10797
ifuser.LoginType!=database.LoginTypePassword {

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,26 @@ WithOIDC.args = {
116116
},
117117
}
118118

119+
exportconstWithOIDCWithoutPassword=Template.bind({})
120+
WithOIDCWithoutPassword.args={
121+
...SignedOut.args,
122+
authMethods:{
123+
password:{enabled:false},
124+
github:{enabled:false},
125+
oidc:{enabled:true,signInText:"",iconUrl:""},
126+
},
127+
}
128+
129+
exportconstWithoutAny=Template.bind({})
130+
WithoutAny.args={
131+
...SignedOut.args,
132+
authMethods:{
133+
password:{enabled:false},
134+
github:{enabled:false},
135+
oidc:{enabled:false,signInText:"",iconUrl:""},
136+
},
137+
}
138+
119139
exportconstWithGithubAndOIDC=Template.bind({})
120140
WithGithubAndOIDC.args={
121141
...SignedOut.args,

‎site/src/components/SignInForm/SignInForm.tsx‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { OAuthSignInForm } from "./OAuthSignInForm"
99
import{BuiltInAuthFormValues}from"./SignInForm.types"
1010
importButtonfrom"@material-ui/core/Button"
1111
importEmailIconfrom"@material-ui/icons/EmailOutlined"
12+
import{AlertBanner}from"components/AlertBanner/AlertBanner"
1213

1314
exportenumLoginErrors{
1415
AUTH_ERROR="authError",
@@ -94,6 +95,7 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
9495
constoAuthEnabled=Boolean(
9596
authMethods?.github.enabled||authMethods?.oidc.enabled,
9697
)
98+
constpasswordEnabled=authMethods?.password.enabled??true
9799

98100
// Hide password auth by default if any OAuth method is enabled
99101
const[showPasswordAuth,setShowPasswordAuth]=useState(!oAuthEnabled)
@@ -108,15 +110,15 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
108110
{loginPageTranslation.t("signInTo")}{" "}
109111
<strong>{commonTranslation.t("coder")}</strong>
110112
</h1>
111-
<Maybecondition={showPasswordAuth}>
113+
<Maybecondition={passwordEnabled&&showPasswordAuth}>
112114
<PasswordSignInForm
113115
loginErrors={loginErrors}
114116
onSubmit={onSubmit}
115117
initialTouched={initialTouched}
116118
isLoading={isLoading}
117119
/>
118120
</Maybe>
119-
<Maybecondition={showPasswordAuth&&oAuthEnabled}>
121+
<Maybecondition={passwordEnabled&&showPasswordAuth&&oAuthEnabled}>
120122
<divclassName={styles.divider}>
121123
<divclassName={styles.dividerLine}/>
122124
<divclassName={styles.dividerLabel}>Or</div>
@@ -131,7 +133,14 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
131133
/>
132134
</Maybe>
133135

134-
<Maybecondition={!showPasswordAuth}>
136+
<Maybecondition={!passwordEnabled&&!oAuthEnabled}>
137+
<AlertBanner
138+
severity="error"
139+
text="No authentication methods configured!"
140+
/>
141+
</Maybe>
142+
143+
<Maybecondition={passwordEnabled&&!showPasswordAuth}>
135144
<divclassName={styles.divider}>
136145
<divclassName={styles.dividerLine}/>
137146
<divclassName={styles.dividerLabel}>Or</div>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp