blob: 0ed8d246d2bda5a9895f43530af6bc6d0553fd61 [file] [log] [blame]
khenaidooffe076b2019-01-15 16:08:08 -05001// Copyright 2016 The etcd Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package grpcproxy
16
17import (
18 "context"
19
20 "github.com/coreos/etcd/clientv3"
21 pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
22)
23
24type AuthProxy struct {
25 client *clientv3.Client
26}
27
28func NewAuthProxy(c *clientv3.Client) pb.AuthServer {
29 return &AuthProxy{client: c}
30}
31
32func (ap *AuthProxy) AuthEnable(ctx context.Context, r *pb.AuthEnableRequest) (*pb.AuthEnableResponse, error) {
33 conn := ap.client.ActiveConnection()
34 return pb.NewAuthClient(conn).AuthEnable(ctx, r)
35}
36
37func (ap *AuthProxy) AuthDisable(ctx context.Context, r *pb.AuthDisableRequest) (*pb.AuthDisableResponse, error) {
38 conn := ap.client.ActiveConnection()
39 return pb.NewAuthClient(conn).AuthDisable(ctx, r)
40}
41
42func (ap *AuthProxy) Authenticate(ctx context.Context, r *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) {
43 conn := ap.client.ActiveConnection()
44 return pb.NewAuthClient(conn).Authenticate(ctx, r)
45}
46
47func (ap *AuthProxy) RoleAdd(ctx context.Context, r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error) {
48 conn := ap.client.ActiveConnection()
49 return pb.NewAuthClient(conn).RoleAdd(ctx, r)
50}
51
52func (ap *AuthProxy) RoleDelete(ctx context.Context, r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error) {
53 conn := ap.client.ActiveConnection()
54 return pb.NewAuthClient(conn).RoleDelete(ctx, r)
55}
56
57func (ap *AuthProxy) RoleGet(ctx context.Context, r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error) {
58 conn := ap.client.ActiveConnection()
59 return pb.NewAuthClient(conn).RoleGet(ctx, r)
60}
61
62func (ap *AuthProxy) RoleList(ctx context.Context, r *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error) {
63 conn := ap.client.ActiveConnection()
64 return pb.NewAuthClient(conn).RoleList(ctx, r)
65}
66
67func (ap *AuthProxy) RoleRevokePermission(ctx context.Context, r *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error) {
68 conn := ap.client.ActiveConnection()
69 return pb.NewAuthClient(conn).RoleRevokePermission(ctx, r)
70}
71
72func (ap *AuthProxy) RoleGrantPermission(ctx context.Context, r *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error) {
73 conn := ap.client.ActiveConnection()
74 return pb.NewAuthClient(conn).RoleGrantPermission(ctx, r)
75}
76
77func (ap *AuthProxy) UserAdd(ctx context.Context, r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error) {
78 conn := ap.client.ActiveConnection()
79 return pb.NewAuthClient(conn).UserAdd(ctx, r)
80}
81
82func (ap *AuthProxy) UserDelete(ctx context.Context, r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error) {
83 conn := ap.client.ActiveConnection()
84 return pb.NewAuthClient(conn).UserDelete(ctx, r)
85}
86
87func (ap *AuthProxy) UserGet(ctx context.Context, r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error) {
88 conn := ap.client.ActiveConnection()
89 return pb.NewAuthClient(conn).UserGet(ctx, r)
90}
91
92func (ap *AuthProxy) UserList(ctx context.Context, r *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error) {
93 conn := ap.client.ActiveConnection()
94 return pb.NewAuthClient(conn).UserList(ctx, r)
95}
96
97func (ap *AuthProxy) UserGrantRole(ctx context.Context, r *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error) {
98 conn := ap.client.ActiveConnection()
99 return pb.NewAuthClient(conn).UserGrantRole(ctx, r)
100}
101
102func (ap *AuthProxy) UserRevokeRole(ctx context.Context, r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error) {
103 conn := ap.client.ActiveConnection()
104 return pb.NewAuthClient(conn).UserRevokeRole(ctx, r)
105}
106
107func (ap *AuthProxy) UserChangePassword(ctx context.Context, r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error) {
108 conn := ap.client.ActiveConnection()
109 return pb.NewAuthClient(conn).UserChangePassword(ctx, r)
110}