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

[wip][do not review] auth support for dbnode #4235

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

gandhikrishna
Copy link
Contributor

What this PR does / why we need it:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing and/or backwards incompatible change?:


Does this PR require updating code package or user-facing documentation?:


Copy link

@SokolAndrey SokolAndrey left a comment

Choose a reason for hiding this comment

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

This is very big PR, please consider splitting it into smaller parts

@@ -52,6 +53,8 @@ type ClusterConfig struct {
AutoSyncInterval time.Duration `yaml:"autoSyncInterval"`
DialTimeout time.Duration `yaml:"dialTimeout"`

Auth *AuthConfig `yaml:"auth"`

Choose a reason for hiding this comment

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

pls don't use pointers in config structures


// Validate validates the AuthConfig.
func (a *AuthConfig) Validate() error {
if a.Enabled {

Choose a reason for hiding this comment

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

nit:

if !a.Enabled { return nil } ...

func (a *AuthConfig) Validate() error {
if a.Enabled {
if a.UserName == "" || a.Password == "" {
return fmt.Errorf("credentials must be set for client's outbound")

Choose a reason for hiding this comment

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

super nit: avoid using single quote in the log messages

// AuthConfig is the top level config that includes secrets of inbound and
// outbound of a dbnode.
type AuthConfig struct {
Outbound *Outbounds `yaml:"outbounds"`

Choose a reason for hiding this comment

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

same as above, avoid using pointers in config structs. Once you replace it with values I don't think you need all these validation methods

services:
- service:
zone: m3_abc
username: m3_bcd

Choose a reason for hiding this comment

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

I thought this should be a path to a file, no?

return nil
}

if i.authMode == AuthModeShadow {

Choose a reason for hiding this comment

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

this should be after cred validation

}

if i.authMode == AuthModeShadow {
go func() {

Choose a reason for hiding this comment

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

Why is it executed in a separated routine?

}()
return nil
}
if creds.Type == Unknown {

Choose a reason for hiding this comment

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

I think this should be part of Validate

// ValidateCredentialsFromThriftContext validates inbound credential from thrift context.
func (i *Inbound) ValidateCredentialsFromThriftContext(tctx thrift.Context, credtype CredentialType) error {
ctxHeaders := tctx.Headers()
userName, ok := ctxHeaders[AuthUsername]

Choose a reason for hiding this comment

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

I think we discussed it offline, but why don't we encrypt the username/password before sending it as a header? We provide user name/password to the node at start up, we might as well pass a private part of asymetric key. User encrypt the username/password using public part before sending the request and we decrypt it here.
I don't think it will add a lot of overhead but without it sending username/password in plain text as a header doesn't provide a lot of security


var (
credentialCache = map[string]string{}
hashFunc = md5.New() // #nosec

Choose a reason for hiding this comment

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

maybe I'm missing something but are we not using nonce? Using digest authentication is vulnerable to simple replay attack

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.

2 participants