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

RFC: RBAC Support for PD #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PhotonQuantum
Copy link

No description provided.

Signed-off-by: PhotonQuantum <[email protected]>

- PD stores `User`s in a KV database (etcd).
- Username: string
- Hash: string (sha256)
Copy link

Choose a reason for hiding this comment

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

I assume this is the hash of the password? In which case sha256 is inappropriate. You should either salt the password and use multiple iterations of sha512, or use a hash algorithm specifically designed for passwords, e.g., Argon2d.

Copy link
Author

Choose a reason for hiding this comment

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

I'm worried about the potential performance penalty if we use key derivation algorithms.

Copy link

Choose a reason for hiding this comment

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

That is a feature, not a bug - being able to hash the password quickly is a security risk. I think a token based scheme would be more performant?

- Roles: a set of strings (role names)
- A client (TiDB/TiKV/pd-ctl/…) must provide a pair of username and password to
gain access to PD APIs (including HTTP and gRPC endpoints).
- Clients using HTTP APIs should send requests with a basic authentication header.
Copy link

Choose a reason for hiding this comment

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

Can users always use https to contact PD? Using http for this would be insecure.

Copy link
Author

Choose a reason for hiding this comment

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

That's a good idea! We may enforce TLS when authentication is enabled.

- A client (TiDB/TiKV/pd-ctl/…) must provide a pair of username and password to
gain access to PD APIs (including HTTP and gRPC endpoints).
- Clients using HTTP APIs should send requests with a basic authentication header.
- Clients using gRPC should set its username and password in the meta field.
Copy link

Choose a reason for hiding this comment

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

Likewise, do we always use TLS for gRPC?


### Authentication

- PD stores `User`s in a KV database (etcd).
Copy link

Choose a reason for hiding this comment

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

Will this require an etcd access on every request? That seems like it could be a big performance hit (though I am just guessing).

Copy link
Author

Choose a reason for hiding this comment

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

I believe an in-memory cache can mitigate the performance regression.

Copy link
Member

Choose a reason for hiding this comment

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

could you write this optimization and the cache maintenance mechanism to the RFC?


## Future Additions

- Token-based authentication.
Copy link

Choose a reason for hiding this comment

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

token-based authorization is considerably more secure than using username/password and IMO should be the only mechanism supported. There are fairly standard approaches which can be used, e.g., OAuth

Copy link
Author

Choose a reason for hiding this comment

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

Maybe different users will have different security models? I'm thinking about providing several auth methods, including password-based, token-based, and certificate-based ones.

Copy link

Choose a reason for hiding this comment

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

From a security perspective, the more auth methods there are, the less secure your system is. Could we support a single, token-based auth method and provide token generation from username/password in the client?

@andylokandy andylokandy mentioned this pull request Aug 16, 2021

## Motivation

PD server exposes its APIs to the network via HTTP or gRPC endpoints.
Copy link
Member

Choose a reason for hiding this comment

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

are there any guidelines about when to use HTTP and gRPC?

@gregwebs
Copy link
Contributor

gregwebs commented Sep 6, 2021

etcd already supports RBAC. What are the issues with just using that?

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.

4 participants