You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

user.go 3.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package corrpc
  2. import (
  3. context "context"
  4. "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc"
  5. cortypes "gitlink.org.cn/cloudream/jcs-pub/coordinator/types"
  6. )
  7. type UserService interface {
  8. UserLogin(ctx context.Context, msg *UserLogin) (*UserLoginResp, *rpc.CodeError)
  9. UserLogout(ctx context.Context, msg *UserLogout) (*UserLogoutResp, *rpc.CodeError)
  10. UserRefreshToken(ctx context.Context, msg *UserRefreshToken) (*UserRefreshTokenResp, *rpc.CodeError)
  11. HubLoadAccessToken(ctx context.Context, msg *HubLoadAccessToken) (*HubLoadAccessTokenResp, *rpc.CodeError)
  12. }
  13. // 客户端登录
  14. type UserLogin struct {
  15. Account string
  16. Password string
  17. }
  18. type UserLoginResp struct {
  19. Token cortypes.UserAccessToken
  20. PrivateKey string
  21. }
  22. var _ = NoAuth(Coordinator_UserLogin_FullMethodName)
  23. func (c *Client) UserLogin(ctx context.Context, msg *UserLogin) (*UserLoginResp, *rpc.CodeError) {
  24. if c.fusedErr != nil {
  25. return nil, c.fusedErr
  26. }
  27. return rpc.UnaryClient[*UserLoginResp](c.cli.UserLogin, ctx, msg)
  28. }
  29. func (s *Server) UserLogin(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
  30. return rpc.UnaryServer(s.svrImpl.UserLogin, ctx, req)
  31. }
  32. // 客户端刷新Token,原始Token会继续有效。
  33. type UserRefreshToken struct{}
  34. type UserRefreshTokenResp struct {
  35. Token cortypes.UserAccessToken
  36. PrivateKey string
  37. }
  38. var _ = TokenAuth(Coordinator_UserLogin_FullMethodName)
  39. func (c *Client) UserRefreshToken(ctx context.Context, msg *UserRefreshToken) (*UserRefreshTokenResp, *rpc.CodeError) {
  40. if c.fusedErr != nil {
  41. return nil, c.fusedErr
  42. }
  43. return rpc.UnaryClient[*UserRefreshTokenResp](c.cli.UserRefreshToken, ctx, msg)
  44. }
  45. func (s *Server) UserRefreshToken(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
  46. return rpc.UnaryServer(s.svrImpl.UserRefreshToken, ctx, req)
  47. }
  48. // 客户端登出。会使用GRPC元数据中的TokenID和UserID来查找Token并删除。
  49. type UserLogout struct{}
  50. type UserLogoutResp struct{}
  51. var _ = TokenAuth(Coordinator_UserLogout_FullMethodName)
  52. func (c *Client) UserLogout(ctx context.Context, msg *UserLogout) (*UserLogoutResp, *rpc.CodeError) {
  53. if c.fusedErr != nil {
  54. return nil, c.fusedErr
  55. }
  56. return rpc.UnaryClient[*UserLogoutResp](c.cli.UserLogout, ctx, msg)
  57. }
  58. func (s *Server) UserLogout(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
  59. return rpc.UnaryServer(s.svrImpl.UserLogout, ctx, req)
  60. }
  61. // Hub服务加载AccessToken
  62. type HubLoadAccessToken struct {
  63. HubID cortypes.HubID
  64. UserID cortypes.UserID
  65. TokenID cortypes.AccessTokenID
  66. }
  67. type HubLoadAccessTokenResp struct {
  68. Token cortypes.UserAccessToken
  69. }
  70. func (c *Client) HubLoadAccessToken(ctx context.Context, msg *HubLoadAccessToken) (*HubLoadAccessTokenResp, *rpc.CodeError) {
  71. if c.fusedErr != nil {
  72. return nil, c.fusedErr
  73. }
  74. return rpc.UnaryClient[*HubLoadAccessTokenResp](c.cli.HubLoadAccessToken, ctx, msg)
  75. }
  76. func (s *Server) HubLoadAccessToken(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
  77. return rpc.UnaryServer(s.svrImpl.HubLoadAccessToken, ctx, req)
  78. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。