-
Notifications
You must be signed in to change notification settings - Fork 25
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
support grpc auth for grpc server. #168
Conversation
3a4f400
to
420b812
Compare
/assign @qiujian16 @clyang82 @skeeey |
7d3b22e
to
37489b4
Compare
/ok-to-test |
4ade853
to
93df2b2
Compare
Signed-off-by: morvencao <lcao@redhat.com>
93df2b2
to
e262f36
Compare
rebased the code, added document for how to configure grpc server authN and authZ. |
e.Clients.GRPCAuthorizer = grpcauthorizer.NewMockGRPCAuthorizer() | ||
} else { | ||
kubeConfig, err := clientcmd.BuildConfigFromFlags("", e.Config.GRPCServer.GRPCAuthrizerConfig) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/GRPCAuthrizerConfig/GRPCAuthorizerConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cmd/maestro/server/api_server.go
Outdated
@@ -126,7 +126,7 @@ func NewAPIServer(eventBroadcaster *event.EventBroadcaster) Server { | |||
|
|||
// TODO: support authn and authz for gRPC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this comment since we support it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this.
cmd/maestro/server/grpc_server.go
Outdated
|
||
// newAuthUnaryInterceptor creates a new unary interceptor that looks up the client certificate from the incoming RPC context, | ||
// retrieves the user and groups from it and creates a new context with the user and groups before invoking the provided handler. | ||
// otherwise, it falls back retrieving the user and groups from the access token. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comment is to look up the client cert and then token. but the implement is to look up token and then client cert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use --grpc-authn-type
to decide that where to get the user and group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the original idea is even if we specify the --grpc-authn-type=token
, we may still can retrieve user/group from client certificate if the token is not provided.
Anyway, I will use --grpc-authn-type
to decide that how to get the user and group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated this use --grpc-authn-type
to decide that how to get the user and group.
fs.StringVar(&s.TLSCertFile, "grpc-tls-cert-file", "", "The path to the tls.crt file") | ||
fs.StringVar(&s.TLSKeyFile, "grpc-tls-key-file", "", "The path to the tls.key file") | ||
fs.BoolVar(&s.EnableTLS, "enable-grpc-tls", false, "Enable TLS for gRPC server") | ||
fs.StringVar(&s.GRPCAuthNType, "grpc-authn-type", "mock", "Specify the gRPC authentication type (e.g., mock, mtls or token)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe disable grpc authn instead of using mock. using mock seems it is not ready for use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to simplify the code and make it easy for users to learn, so I'd prefer not to add another parameter for this.
nonResourceUrl = fmt.Sprintf("/sources/%s", resource) | ||
case "cluster": | ||
nonResourceUrl = fmt.Sprintf("/clusters/%s", resource) | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source
and cluster
are not the same level concept. what do you mean cluster
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if configure both, what is the behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we don't need cluster
for now, because currently authZ is for source side, not for agent side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed cluster
for now.
Signed-off-by: morvencao <lcao@redhat.com>
d0735fa
to
c3f4f6f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add authentication and authorization for gRPC server, using kube authorizer:
how to configure authentication and authorization doc: https://github.com/morvencao/openshift-online-maestro/blob/br_grpc_auth/docs/grpc.md#authentication-and-authorization
ref: