Skip to content
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

Add ability to disable local auth. #2575

Merged
merged 1 commit into from
May 7, 2019
Merged

Conversation

russjones
Copy link
Contributor

Description

Added "local_auth" to file configuration and "LocalAuth" to services.ClusterConfig to control cluster-wide local authentication. Check local auth settings when generating signup tokens, creating local users, and login.

Related Issues

Fixes https://github.com/gravitational/teleport.e/issues/105

@russjones russjones requested a review from klizhentas February 21, 2019 23:24
@russjones russjones force-pushed the rjones/disable-local-auth branch 2 times, most recently from 3edd64d to add4140 Compare February 22, 2019 23:28
@klizhentas
Copy link
Contributor

I've migrated this model to protobuf in my branch, let's hold on on this change before I merge to avoid changing the model twice.

@russjones russjones force-pushed the rjones/disable-local-auth branch 2 times, most recently from 5aab69a to dea9522 Compare May 3, 2019 23:15
Copy link
Contributor

@alex-kovoy alex-kovoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It reminded me that we need to migrate the code for handling creation of local users and signups from Gravity to Teleport.

if err != nil {
return "", trace.Wrap(err)
}
if clusterConfig.GetLocalAuth() == false {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this condition can be omitted here, the logic of creating a signup token does not need to be aware of this detail.

@@ -263,6 +279,14 @@ func (s *AuthServer) CreateUserWithOTP(token string, password string, otpToken s

// CreateUserWithoutOTP creates an account with the provided password and deletes the token afterwards.
func (s *AuthServer) CreateUserWithoutOTP(token string, password string) (services.WebSession, error) {
clusterConfig, err := s.GetClusterConfig()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the first glance it looks like it should be handled using AuthPreferences rather than a stand alone configuration property.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are moving auth preferences in the cluster config in the longer term, so kind of makes sense

@@ -291,6 +315,14 @@ func (s *AuthServer) CreateUserWithoutOTP(token string, password string) (servic
}

func (s *AuthServer) CreateUserWithU2FToken(token string, password string, response u2f.RegisterResponse) (services.WebSession, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of checking for this condition in all these methods:

CreateSignupToken
CreateUserWithU2FToken
CreateUserWithOTP
CreateUserWithoutOTP

We can do it in 1 method, say CreateUser.

This is how we do it in gravity https://github.com/gravitational/gravity/blob/master/lib/users/usersservice/usersservice.go#L1340
where all requests for creating a new local user go through 1 method which has all the checks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of agree that having one place is nice, not sure if worth refactoring it all right now makes sense

return nil, trace.Wrap(err)
}
if clusterConfig.GetLocalAuth() == false {
return nil, trace.AccessDenied("local auth disabled")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emit audit event here?

return "", trace.Wrap(err)
}
if clusterConfig.GetLocalAuth() == false {
return "", trace.AccessDenied("local auth disabled")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emit audit event here?

@@ -263,6 +279,14 @@ func (s *AuthServer) CreateUserWithOTP(token string, password string, otpToken s

// CreateUserWithoutOTP creates an account with the provided password and deletes the token afterwards.
func (s *AuthServer) CreateUserWithoutOTP(token string, password string) (services.WebSession, error) {
clusterConfig, err := s.GetClusterConfig()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are moving auth preferences in the cluster config in the longer term, so kind of makes sense

@@ -291,6 +315,14 @@ func (s *AuthServer) CreateUserWithoutOTP(token string, password string) (servic
}

func (s *AuthServer) CreateUserWithU2FToken(token string, password string, response u2f.RegisterResponse) (services.WebSession, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of agree that having one place is nice, not sure if worth refactoring it all right now makes sense

Added "local_auth" to file configuration and "LocalAuth" to
services.ClusterConfig to control cluster-wide local authentication.
Check local auth settings when generating signup tokens, creating local
users, and login.
@russjones russjones force-pushed the rjones/disable-local-auth branch from dea9522 to 5bd8e21 Compare May 7, 2019 00:09
@russjones russjones merged commit f403fe8 into master May 7, 2019
@russjones russjones deleted the rjones/disable-local-auth branch May 7, 2019 18:06
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 this pull request may close these issues.

3 participants