auth.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // Copyright 2016 Nippon Telegraph and Telephone Corporation.
  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. package v3rpc
  15. import (
  16. "github.com/coreos/etcd/etcdserver"
  17. pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
  18. "golang.org/x/net/context"
  19. )
  20. type AuthServer struct {
  21. authenticator etcdserver.Authenticator
  22. }
  23. func NewAuthServer(s *etcdserver.EtcdServer) *AuthServer {
  24. return &AuthServer{authenticator: s}
  25. }
  26. func (as *AuthServer) AuthEnable(ctx context.Context, r *pb.AuthEnableRequest) (*pb.AuthEnableResponse, error) {
  27. resp, err := as.authenticator.AuthEnable(ctx, r)
  28. if err != nil {
  29. return nil, togRPCError(err)
  30. }
  31. return resp, nil
  32. }
  33. func (as *AuthServer) AuthDisable(ctx context.Context, r *pb.AuthDisableRequest) (*pb.AuthDisableResponse, error) {
  34. plog.Info("not implemented yet")
  35. return nil, nil
  36. }
  37. func (as *AuthServer) Authenticate(ctx context.Context, r *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) {
  38. plog.Info("not implemented yet")
  39. return nil, nil
  40. }
  41. func (as *AuthServer) RoleAdd(ctx context.Context, r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error) {
  42. resp, err := as.authenticator.RoleAdd(ctx, r)
  43. if err != nil {
  44. return nil, togRPCError(err)
  45. }
  46. return resp, nil
  47. }
  48. func (as *AuthServer) RoleDelete(ctx context.Context, r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error) {
  49. plog.Info("not implemented yet")
  50. return nil, nil
  51. }
  52. func (as *AuthServer) RoleGet(ctx context.Context, r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error) {
  53. plog.Info("not implemented yet")
  54. return nil, nil
  55. }
  56. func (as *AuthServer) RoleRevoke(ctx context.Context, r *pb.AuthRoleRevokeRequest) (*pb.AuthRoleRevokeResponse, error) {
  57. plog.Info("not implemented yet")
  58. return nil, nil
  59. }
  60. func (as *AuthServer) RoleGrant(ctx context.Context, r *pb.AuthRoleGrantRequest) (*pb.AuthRoleGrantResponse, error) {
  61. plog.Info("not implemented yet")
  62. return nil, nil
  63. }
  64. func (as *AuthServer) UserAdd(ctx context.Context, r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error) {
  65. resp, err := as.authenticator.UserAdd(ctx, r)
  66. if err != nil {
  67. return nil, togRPCError(err)
  68. }
  69. return resp, nil
  70. }
  71. func (as *AuthServer) UserDelete(ctx context.Context, r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error) {
  72. resp, err := as.authenticator.UserDelete(ctx, r)
  73. if err != nil {
  74. return nil, togRPCError(err)
  75. }
  76. return resp, nil
  77. }
  78. func (as *AuthServer) UserGet(ctx context.Context, r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error) {
  79. plog.Info("not implemented yet")
  80. return nil, nil
  81. }
  82. func (as *AuthServer) UserGrant(ctx context.Context, r *pb.AuthUserGrantRequest) (*pb.AuthUserGrantResponse, error) {
  83. plog.Info("not implemented yet")
  84. return nil, nil
  85. }
  86. func (as *AuthServer) UserRevoke(ctx context.Context, r *pb.AuthUserRevokeRequest) (*pb.AuthUserRevokeResponse, error) {
  87. plog.Info("not implemented yet")
  88. return nil, nil
  89. }
  90. func (as *AuthServer) UserChangePassword(ctx context.Context, r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error) {
  91. resp, err := as.authenticator.UserChangePassword(ctx, r)
  92. if err != nil {
  93. return nil, togRPCError(err)
  94. }
  95. return resp, nil
  96. }