Skip to content

--disable-password-auth is useless when using Coder in a headless fashion #7657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ammario opened this issue May 23, 2023 · 7 comments · Fixed by #8009
Closed

--disable-password-auth is useless when using Coder in a headless fashion #7657

ammario opened this issue May 23, 2023 · 7 comments · Fixed by #8009
Assignees
Milestone

Comments

@ammario
Copy link
Member

ammario commented May 23, 2023

From szab100 in #7638 (comment)

One suggestion though is that we found --disable-password-auth to be useless, since it blocks user management via the API when enabled. The workaround is that we create users with long, generated passwords that we never share with them. Our suggestion is that instead of making it org-scoped, make it even more flexible by making it user-scoped, eg allow creating users with disabled passwords and/or disable password for already existing users (through API / CLI / UI).

@Emyrk
Copy link
Member

Emyrk commented Jun 9, 2023

Here is the code in question that blocks user administration.

coder/coderd/users.go

Lines 288 to 295 in 0999db0

// If password auth is disabled, don't allow new users to be
// created with a password!
if api.DeploymentValues.DisablePasswordAuth {
httpapi.Write(ctx, rw, http.StatusForbidden, codersdk.Response{
Message: "You cannot manually provision new users with password authentication disabled!",
})
return
}

@Emyrk
Copy link
Member

Emyrk commented Jun 9, 2023

Would a solution be to add a new LoginType to this list?

const (
LoginTypePassword LoginType = "password"
LoginTypeGithub LoginType = "github"
LoginTypeOIDC LoginType = "oidc"
LoginTypeToken LoginType = "token"
)

Make it something like

	// LoginTypeNone is used if no login method is available for this user.
	// If this is set, the user has no method of logging in.
	// API keys can still be created by an owner and used by the user.
	// These keys would use the `LoginTypeToken` type.
	LoginTypeNone LoginType = "none"

When creating a user, you can specify this login type. It would prevent the /login route from ever authenticating a user, and the user would need to find an alternative method (like having an owner generate them a key).

We should probably clarify that existing API keys are still valid. So if you switch a user's login type to this, it does not log them. But I don't think we support that functionality yet so it's ok?

@ammario thoughts?

@ammario ammario added the feature label Jun 9, 2023
@ammario
Copy link
Member Author

ammario commented Jun 9, 2023

I wonder if there's a way we could satisfy the use case without adding another knob. Maybe we could just allow users to be created without passwords when disable-password-auth is set?

@Emyrk
Copy link
Member

Emyrk commented Jun 9, 2023

The thing about no password is that then the condition for all password auth related things is:

if user.LoginType == database.LoginTypePassword && user.HashedSecret == "" {
   // No password set
}

Mainly I am thinking that if a user is created without a password, actions like "reset password" should fail.

All password interactions should fail.

LoginTypeNone is another knob, but it is also another authentication mode for a user. So I think it is valid.

@Emyrk Emyrk self-assigned this Jun 9, 2023
@ammario
Copy link
Member Author

ammario commented Jun 9, 2023

Ok. Sounds good to me.

@sreya sreya added this to the ❓Sprint 1 milestone Jun 12, 2023
@Emyrk
Copy link
Member

Emyrk commented Jun 13, 2023

@ammario something I wonder about is should this user be able to make more api keys from one?

If we disable login, an admin can make them a token. They can use that token to make more tokens.


Oh duh, we can add a scope to the key. Nvm!!

@Emyrk
Copy link
Member

Emyrk commented Jun 13, 2023

@ammario thoughts on #8011?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants