Compare commits

..

No commits in common. "0de20d5ddfd44713fe8c00e6a5d1bf4c529f6eee" and "ad43d206e1b9626c712b6567f7c1e342d1b4508b" have entirely different histories.

10 changed files with 51 additions and 542 deletions

View File

@ -2722,7 +2722,6 @@ type LoginResponse struct {
Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
Token string `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"`
Expires int64 `protobuf:"varint,4,opt,name=expires,proto3" json:"expires,omitempty"`
RefreshToken string `protobuf:"bytes,5,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@ -2785,133 +2784,6 @@ func (x *LoginResponse) GetExpires() int64 {
return 0
}
func (x *LoginResponse) GetRefreshToken() string {
if x != nil {
return x.RefreshToken
}
return ""
}
type RefreshTokenRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RefreshTokenRequest) Reset() {
*x = RefreshTokenRequest{}
mi := &file_organize_proto_msgTypes[47]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RefreshTokenRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RefreshTokenRequest) ProtoMessage() {}
func (x *RefreshTokenRequest) ProtoReflect() protoreflect.Message {
mi := &file_organize_proto_msgTypes[47]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RefreshTokenRequest.ProtoReflect.Descriptor instead.
func (*RefreshTokenRequest) Descriptor() ([]byte, []int) {
return file_organize_proto_rawDescGZIP(), []int{47}
}
func (x *RefreshTokenRequest) GetRefreshToken() string {
if x != nil {
return x.RefreshToken
}
return ""
}
type RefreshTokenResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"`
Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
Token string `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"`
Expires int64 `protobuf:"varint,4,opt,name=expires,proto3" json:"expires,omitempty"`
RefreshToken string `protobuf:"bytes,5,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RefreshTokenResponse) Reset() {
*x = RefreshTokenResponse{}
mi := &file_organize_proto_msgTypes[48]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RefreshTokenResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RefreshTokenResponse) ProtoMessage() {}
func (x *RefreshTokenResponse) ProtoReflect() protoreflect.Message {
mi := &file_organize_proto_msgTypes[48]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RefreshTokenResponse.ProtoReflect.Descriptor instead.
func (*RefreshTokenResponse) Descriptor() ([]byte, []int) {
return file_organize_proto_rawDescGZIP(), []int{48}
}
func (x *RefreshTokenResponse) GetUid() string {
if x != nil {
return x.Uid
}
return ""
}
func (x *RefreshTokenResponse) GetUsername() string {
if x != nil {
return x.Username
}
return ""
}
func (x *RefreshTokenResponse) GetToken() string {
if x != nil {
return x.Token
}
return ""
}
func (x *RefreshTokenResponse) GetExpires() int64 {
if x != nil {
return x.Expires
}
return 0
}
func (x *RefreshTokenResponse) GetRefreshToken() string {
if x != nil {
return x.RefreshToken
}
return ""
}
type LogoutRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
@ -2921,7 +2793,7 @@ type LogoutRequest struct {
func (x *LogoutRequest) Reset() {
*x = LogoutRequest{}
mi := &file_organize_proto_msgTypes[49]
mi := &file_organize_proto_msgTypes[47]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -2933,7 +2805,7 @@ func (x *LogoutRequest) String() string {
func (*LogoutRequest) ProtoMessage() {}
func (x *LogoutRequest) ProtoReflect() protoreflect.Message {
mi := &file_organize_proto_msgTypes[49]
mi := &file_organize_proto_msgTypes[47]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -2946,7 +2818,7 @@ func (x *LogoutRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead.
func (*LogoutRequest) Descriptor() ([]byte, []int) {
return file_organize_proto_rawDescGZIP(), []int{49}
return file_organize_proto_rawDescGZIP(), []int{47}
}
func (x *LogoutRequest) GetToken() string {
@ -2965,7 +2837,7 @@ type LogoutResponse struct {
func (x *LogoutResponse) Reset() {
*x = LogoutResponse{}
mi := &file_organize_proto_msgTypes[50]
mi := &file_organize_proto_msgTypes[48]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -2977,7 +2849,7 @@ func (x *LogoutResponse) String() string {
func (*LogoutResponse) ProtoMessage() {}
func (x *LogoutResponse) ProtoReflect() protoreflect.Message {
mi := &file_organize_proto_msgTypes[50]
mi := &file_organize_proto_msgTypes[48]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -2990,7 +2862,7 @@ func (x *LogoutResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use LogoutResponse.ProtoReflect.Descriptor instead.
func (*LogoutResponse) Descriptor() ([]byte, []int) {
return file_organize_proto_rawDescGZIP(), []int{50}
return file_organize_proto_rawDescGZIP(), []int{48}
}
func (x *LogoutResponse) GetUid() string {
@ -3265,21 +3137,12 @@ const file_organize_proto_rawDesc = "" +
"\fLoginRequest\x12\x1a\n" +
"\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" +
"\bpassword\x18\x02 \x01(\tR\bpassword\x12\x14\n" +
"\x05token\x18\x03 \x01(\tR\x05token\"\x92\x01\n" +
"\x05token\x18\x03 \x01(\tR\x05token\"m\n" +
"\rLoginResponse\x12\x10\n" +
"\x03uid\x18\x01 \x01(\tR\x03uid\x12\x1a\n" +
"\busername\x18\x02 \x01(\tR\busername\x12\x14\n" +
"\x05token\x18\x03 \x01(\tR\x05token\x12\x18\n" +
"\aexpires\x18\x04 \x01(\x03R\aexpires\x12#\n" +
"\rrefresh_token\x18\x05 \x01(\tR\frefreshToken\":\n" +
"\x13RefreshTokenRequest\x12#\n" +
"\rrefresh_token\x18\x01 \x01(\tR\frefreshToken\"\x99\x01\n" +
"\x14RefreshTokenResponse\x12\x10\n" +
"\x03uid\x18\x01 \x01(\tR\x03uid\x12\x1a\n" +
"\busername\x18\x02 \x01(\tR\busername\x12\x14\n" +
"\x05token\x18\x03 \x01(\tR\x05token\x12\x18\n" +
"\aexpires\x18\x04 \x01(\x03R\aexpires\x12#\n" +
"\rrefresh_token\x18\x05 \x01(\tR\frefreshToken\"%\n" +
"\aexpires\x18\x04 \x01(\x03R\aexpires\"%\n" +
"\rLogoutRequest\x12\x14\n" +
"\x05token\x18\x01 \x01(\tR\x05token\"\"\n" +
"\x0eLogoutResponse\x12\x10\n" +
@ -3305,11 +3168,10 @@ const file_organize_proto_rawDesc = "" +
"\vMenuService\x12S\n" +
"\bGetMenus\x12\x18.organize.GetMenuRequest\x1a\x19.organize.GetMenuResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" +
"/menu/list\x12{\n" +
"\x12GetMenuLevelLabels\x12#.organize.GetMenuLevelLabelsRequest\x1a$.organize.GetMenuLevelLabelsResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/menu/level-labels2\xb0\x02\n" +
"\x12GetMenuLevelLabels\x12#.organize.GetMenuLevelLabelsRequest\x1a$.organize.GetMenuLevelLabelsResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/menu/level-labels2\xbd\x01\n" +
"\vAuthService\x12T\n" +
"\x05Login\x12\x16.organize.LoginRequest\x1a\x17.organize.LoginResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x01*\"\x0f/passport/login\x12X\n" +
"\x06Logout\x12\x17.organize.LogoutRequest\x1a\x18.organize.LogoutResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/passport/logout\x12q\n" +
"\fRefreshToken\x12\x1d.organize.RefreshTokenRequest\x1a\x1e.organize.RefreshTokenResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x01*\"\x17/passport/refresh-tokenB&Z$git.nobla.cn/golang/aeis-admin/pb;pbb\x06proto3"
"\x06Logout\x12\x17.organize.LogoutRequest\x1a\x18.organize.LogoutResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/passport/logoutB&Z$git.nobla.cn/golang/aeis-admin/pb;pbb\x06proto3"
var (
file_organize_proto_rawDescOnce sync.Once
@ -3323,7 +3185,7 @@ func file_organize_proto_rawDescGZIP() []byte {
return file_organize_proto_rawDescData
}
var file_organize_proto_msgTypes = make([]protoimpl.MessageInfo, 51)
var file_organize_proto_msgTypes = make([]protoimpl.MessageInfo, 49)
var file_organize_proto_goTypes = []any{
(*Menu)(nil), // 0: organize.Menu
(*Role)(nil), // 1: organize.Role
@ -3372,10 +3234,8 @@ var file_organize_proto_goTypes = []any{
(*GetMenuResponse)(nil), // 44: organize.GetMenuResponse
(*LoginRequest)(nil), // 45: organize.LoginRequest
(*LoginResponse)(nil), // 46: organize.LoginResponse
(*RefreshTokenRequest)(nil), // 47: organize.RefreshTokenRequest
(*RefreshTokenResponse)(nil), // 48: organize.RefreshTokenResponse
(*LogoutRequest)(nil), // 49: organize.LogoutRequest
(*LogoutResponse)(nil), // 50: organize.LogoutResponse
(*LogoutRequest)(nil), // 47: organize.LogoutRequest
(*LogoutResponse)(nil), // 48: organize.LogoutResponse
}
var file_organize_proto_depIdxs = []int32{
8, // 0: organize.MenuItem.permissions:type_name -> organize.PermissionItem
@ -3409,28 +3269,26 @@ var file_organize_proto_depIdxs = []int32{
43, // 28: organize.MenuService.GetMenus:input_type -> organize.GetMenuRequest
40, // 29: organize.MenuService.GetMenuLevelLabels:input_type -> organize.GetMenuLevelLabelsRequest
45, // 30: organize.AuthService.Login:input_type -> organize.LoginRequest
49, // 31: organize.AuthService.Logout:input_type -> organize.LogoutRequest
47, // 32: organize.AuthService.RefreshToken:input_type -> organize.RefreshTokenRequest
11, // 33: organize.UserService.GetMenus:output_type -> organize.GetUserMenuResponse
13, // 34: organize.UserService.GetProfile:output_type -> organize.GetProfileResponse
17, // 35: organize.UserService.UpdateProfile:output_type -> organize.UpdateProfileResponse
15, // 36: organize.UserService.ResetPassword:output_type -> organize.ResetPasswordResponse
19, // 37: organize.UserService.GetPermissions:output_type -> organize.GetPermissionResponse
21, // 38: organize.UserService.GetUserLabels:output_type -> organize.GetUserLabelResponse
23, // 39: organize.UserService.GetUserTags:output_type -> organize.GetUserTagResponse
27, // 40: organize.DepartmentService.GetDepartmentLabels:output_type -> organize.GetDepartmentLabelResponse
29, // 41: organize.DepartmentService.GetDepartmentUsers:output_type -> organize.GetDepartmentUserResponse
32, // 42: organize.DepartmentService.GetDepartmentLevelLabels:output_type -> organize.GetDepartmentLevelLabelsResponse
34, // 43: organize.RoleService.GetRoleLabels:output_type -> organize.GetRoleLabelResponse
36, // 44: organize.RoleService.GetRolePermissions:output_type -> organize.GetRolePermissionResponse
38, // 45: organize.RoleService.SaveRolePermission:output_type -> organize.SaveRolePermissionResponse
44, // 46: organize.MenuService.GetMenus:output_type -> organize.GetMenuResponse
41, // 47: organize.MenuService.GetMenuLevelLabels:output_type -> organize.GetMenuLevelLabelsResponse
46, // 48: organize.AuthService.Login:output_type -> organize.LoginResponse
50, // 49: organize.AuthService.Logout:output_type -> organize.LogoutResponse
48, // 50: organize.AuthService.RefreshToken:output_type -> organize.RefreshTokenResponse
33, // [33:51] is the sub-list for method output_type
15, // [15:33] is the sub-list for method input_type
47, // 31: organize.AuthService.Logout:input_type -> organize.LogoutRequest
11, // 32: organize.UserService.GetMenus:output_type -> organize.GetUserMenuResponse
13, // 33: organize.UserService.GetProfile:output_type -> organize.GetProfileResponse
17, // 34: organize.UserService.UpdateProfile:output_type -> organize.UpdateProfileResponse
15, // 35: organize.UserService.ResetPassword:output_type -> organize.ResetPasswordResponse
19, // 36: organize.UserService.GetPermissions:output_type -> organize.GetPermissionResponse
21, // 37: organize.UserService.GetUserLabels:output_type -> organize.GetUserLabelResponse
23, // 38: organize.UserService.GetUserTags:output_type -> organize.GetUserTagResponse
27, // 39: organize.DepartmentService.GetDepartmentLabels:output_type -> organize.GetDepartmentLabelResponse
29, // 40: organize.DepartmentService.GetDepartmentUsers:output_type -> organize.GetDepartmentUserResponse
32, // 41: organize.DepartmentService.GetDepartmentLevelLabels:output_type -> organize.GetDepartmentLevelLabelsResponse
34, // 42: organize.RoleService.GetRoleLabels:output_type -> organize.GetRoleLabelResponse
36, // 43: organize.RoleService.GetRolePermissions:output_type -> organize.GetRolePermissionResponse
38, // 44: organize.RoleService.SaveRolePermission:output_type -> organize.SaveRolePermissionResponse
44, // 45: organize.MenuService.GetMenus:output_type -> organize.GetMenuResponse
41, // 46: organize.MenuService.GetMenuLevelLabels:output_type -> organize.GetMenuLevelLabelsResponse
46, // 47: organize.AuthService.Login:output_type -> organize.LoginResponse
48, // 48: organize.AuthService.Logout:output_type -> organize.LogoutResponse
32, // [32:49] is the sub-list for method output_type
15, // [15:32] is the sub-list for method input_type
15, // [15:15] is the sub-list for extension type_name
15, // [15:15] is the sub-list for extension extendee
0, // [0:15] is the sub-list for field type_name
@ -3447,7 +3305,7 @@ func file_organize_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_organize_proto_rawDesc), len(file_organize_proto_rawDesc)),
NumEnums: 0,
NumMessages: 51,
NumMessages: 49,
NumExtensions: 0,
NumServices: 5,
},

View File

@ -5663,8 +5663,6 @@ func (m *LoginResponse) validate(all bool) error {
// no validation rules for Expires
// no validation rules for RefreshToken
if len(errors) > 0 {
return LoginResponseMultiError(errors)
}
@ -5743,222 +5741,6 @@ var _ interface {
ErrorName() string
} = LoginResponseValidationError{}
// Validate checks the field values on RefreshTokenRequest with the rules
// defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *RefreshTokenRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on RefreshTokenRequest with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// RefreshTokenRequestMultiError, or nil if none found.
func (m *RefreshTokenRequest) ValidateAll() error {
return m.validate(true)
}
func (m *RefreshTokenRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for RefreshToken
if len(errors) > 0 {
return RefreshTokenRequestMultiError(errors)
}
return nil
}
// RefreshTokenRequestMultiError is an error wrapping multiple validation
// errors returned by RefreshTokenRequest.ValidateAll() if the designated
// constraints aren't met.
type RefreshTokenRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m RefreshTokenRequestMultiError) Error() string {
msgs := make([]string, 0, len(m))
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m RefreshTokenRequestMultiError) AllErrors() []error { return m }
// RefreshTokenRequestValidationError is the validation error returned by
// RefreshTokenRequest.Validate if the designated constraints aren't met.
type RefreshTokenRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e RefreshTokenRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e RefreshTokenRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e RefreshTokenRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e RefreshTokenRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e RefreshTokenRequestValidationError) ErrorName() string {
return "RefreshTokenRequestValidationError"
}
// Error satisfies the builtin error interface
func (e RefreshTokenRequestValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sRefreshTokenRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = RefreshTokenRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = RefreshTokenRequestValidationError{}
// Validate checks the field values on RefreshTokenResponse with the rules
// defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *RefreshTokenResponse) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on RefreshTokenResponse with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// RefreshTokenResponseMultiError, or nil if none found.
func (m *RefreshTokenResponse) ValidateAll() error {
return m.validate(true)
}
func (m *RefreshTokenResponse) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Uid
// no validation rules for Username
// no validation rules for Token
// no validation rules for Expires
// no validation rules for RefreshToken
if len(errors) > 0 {
return RefreshTokenResponseMultiError(errors)
}
return nil
}
// RefreshTokenResponseMultiError is an error wrapping multiple validation
// errors returned by RefreshTokenResponse.ValidateAll() if the designated
// constraints aren't met.
type RefreshTokenResponseMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m RefreshTokenResponseMultiError) Error() string {
msgs := make([]string, 0, len(m))
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m RefreshTokenResponseMultiError) AllErrors() []error { return m }
// RefreshTokenResponseValidationError is the validation error returned by
// RefreshTokenResponse.Validate if the designated constraints aren't met.
type RefreshTokenResponseValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e RefreshTokenResponseValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e RefreshTokenResponseValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e RefreshTokenResponseValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e RefreshTokenResponseValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e RefreshTokenResponseValidationError) ErrorName() string {
return "RefreshTokenResponseValidationError"
}
// Error satisfies the builtin error interface
func (e RefreshTokenResponseValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sRefreshTokenResponse.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = RefreshTokenResponseValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = RefreshTokenResponseValidationError{}
// Validate checks the field values on LogoutRequest with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.

View File

@ -418,19 +418,6 @@ message LoginResponse {
string username = 2;
string token = 3;
int64 expires = 4;
string refresh_token = 5;
}
message RefreshTokenRequest {
string refresh_token = 1;
}
message RefreshTokenResponse {
string uid = 1;
string username = 2;
string token = 3;
int64 expires = 4;
string refresh_token = 5;
}
message LogoutRequest {
@ -455,10 +442,4 @@ service AuthService {
body: "*"
};
}
rpc RefreshToken(RefreshTokenRequest) returns (RefreshTokenResponse) {
option (google.api.http) = {
post: "/passport/refresh-token"
body: "*"
};
}
}

View File

@ -869,9 +869,8 @@ var MenuService_ServiceDesc = grpc.ServiceDesc{
}
const (
AuthService_Login_FullMethodName = "/organize.AuthService/Login"
AuthService_Logout_FullMethodName = "/organize.AuthService/Logout"
AuthService_RefreshToken_FullMethodName = "/organize.AuthService/RefreshToken"
AuthService_Login_FullMethodName = "/organize.AuthService/Login"
AuthService_Logout_FullMethodName = "/organize.AuthService/Logout"
)
// AuthServiceClient is the client API for AuthService service.
@ -882,7 +881,6 @@ const (
type AuthServiceClient interface {
Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error)
Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error)
RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error)
}
type authServiceClient struct {
@ -913,16 +911,6 @@ func (c *authServiceClient) Logout(ctx context.Context, in *LogoutRequest, opts
return out, nil
}
func (c *authServiceClient) RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RefreshTokenResponse)
err := c.cc.Invoke(ctx, AuthService_RefreshToken_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// AuthServiceServer is the server API for AuthService service.
// All implementations must embed UnimplementedAuthServiceServer
// for forward compatibility.
@ -931,7 +919,6 @@ func (c *authServiceClient) RefreshToken(ctx context.Context, in *RefreshTokenRe
type AuthServiceServer interface {
Login(context.Context, *LoginRequest) (*LoginResponse, error)
Logout(context.Context, *LogoutRequest) (*LogoutResponse, error)
RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error)
mustEmbedUnimplementedAuthServiceServer()
}
@ -948,9 +935,6 @@ func (UnimplementedAuthServiceServer) Login(context.Context, *LoginRequest) (*Lo
func (UnimplementedAuthServiceServer) Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented")
}
func (UnimplementedAuthServiceServer) RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RefreshToken not implemented")
}
func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {}
func (UnimplementedAuthServiceServer) testEmbeddedByValue() {}
@ -1008,24 +992,6 @@ func _AuthService_Logout_Handler(srv interface{}, ctx context.Context, dec func(
return interceptor(ctx, in, info, handler)
}
func _AuthService_RefreshToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RefreshTokenRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthServiceServer).RefreshToken(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuthService_RefreshToken_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServiceServer).RefreshToken(ctx, req.(*RefreshTokenRequest))
}
return interceptor(ctx, in, info, handler)
}
// AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -1041,10 +1007,6 @@ var AuthService_ServiceDesc = grpc.ServiceDesc{
MethodName: "Logout",
Handler: _AuthService_Logout_Handler,
},
{
MethodName: "RefreshToken",
Handler: _AuthService_RefreshToken_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "organize.proto",

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-aeus. DO NOT EDIT.
// source: organize.proto
// date: 2025-07-22 18:30:59
// date: 2025-07-22 16:59:46
package pb
@ -65,8 +65,6 @@ type AuthServiceHttpServer interface {
Login(ctx context.Context, req *LoginRequest) (res *LoginResponse, err error)
Logout(ctx context.Context, req *LogoutRequest) (res *LogoutResponse, err error)
RefreshToken(ctx context.Context, req *RefreshTokenRequest) (res *RefreshTokenResponse, err error)
}
// 获取用户菜单
@ -369,24 +367,6 @@ func handleAuthServiceLogout(s AuthServiceHttpServer) http.HandleFunc {
}
}
func handleAuthServiceRefreshToken(s AuthServiceHttpServer) http.HandleFunc {
return func(ctx *http.Context) (err error) {
req := &RefreshTokenRequest{}
if err := ctx.Bind(req); err != nil {
return ctx.Error(errors.Invalid, err.Error())
}
if res, err := s.RefreshToken(ctx.Context(), req); err != nil {
if er, ok := err.(*errors.Error); ok {
return ctx.Error(er.Code, er.Message)
} else {
return ctx.Error(errors.Unavailable, err.Error())
}
} else {
return ctx.Success(res)
}
}
}
func RegisterUserServiceRouter(hs *http.Server, s UserServiceHttpServer) {
// Register handle GetMenus route
@ -456,7 +436,4 @@ func RegisterAuthServiceRouter(hs *http.Server, s AuthServiceHttpServer) {
// Register handle Logout route
hs.POST("/passport/logout", handleAuthServiceLogout(s))
// Register handle RefreshToken route
hs.POST("/passport/refresh-token", handleAuthServiceRefreshToken(s))
}

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-aeus. DO NOT EDIT.
// source: organize.proto
// date: 2025-07-22 18:30:59
// date: 2025-07-22 16:59:46
package pb

View File

@ -355,23 +355,23 @@ var File_system_proto protoreflect.FileDescriptor
const file_system_proto_rawDesc = "" +
"\n" +
"\fsystem.proto\x12\x06system\x1a\x0faeus/rest.proto\x1a\x17validate/validate.proto\x1a google/protobuf/descriptor.proto\x1a\x1cgoogle/api/annotations.proto\"\xb7\x04\n" +
"\fsystem.proto\x12\x06system\x1a\x0faeus/rest.proto\x1a\x17validate/validate.proto\x1a google/protobuf/descriptor.proto\x1a\x1cgoogle/api/annotations.proto\"\xc0\x04\n" +
"\aSetting\x12$\n" +
"\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" +
"\n" +
"primaryKey\x12\x02IDR\x02id\x12>\n" +
"primaryKey\x12\x02IDR\x02id\x12E\n" +
"\n" +
"created_at\x18\x02 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f创建时间\x1a\vview;exportR\tcreatedAt\x12>\n" +
"created_at\x18\x02 \x01(\x03B&\xb2\xb9\x19\"\x12\f创建时间\x1a\x12search;view;exportR\tcreatedAt\x12E\n" +
"\n" +
"updated_at\x18\x03 \x01(\x03B\x1f\xb2\xb9\x19\x1b\x12\f更新时间\x1a\vview;exportR\tupdatedAt\x12N\n" +
"updated_at\x18\x03 \x01(\x03B&\xb2\xb9\x19\"\x12\f更新时间\x1a\x12search;view;exportR\tupdatedAt\x12N\n" +
"\x04name\x18\x04 \x01(\tB:\xfaB\x04r\x02\x18\x14\xb2\xb9\x19/\n" +
"\asize:60\x12\t配置项2\x0freadonly:update:\brequiredR\x04name\x12e\n" +
"\x04type\x18\x05 \x01(\tBQ\xfaB\x04r\x02\x18\x14\xb2\xb9\x19F\n" +
"\asize:20\x12\f数据类型:\brequiredR#text:文本;number:数字;json:JSONR\x04type\x12L\n" +
"\x05value\x18\x06 \x01(\tB6\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19*\n" +
"\tsize:1024\x12\t配置值*\btextarea:\brequiredR\x05value\x12q\n" +
"\vdescription\x18\a \x01(\tBO\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19C\n" +
"\tsize:1024\x12\f备注说明\x1a\x1elist;create;update;view;export*\btextareaR\vdescription:\x0e\xba\xb9\x19\n" +
"\tsize:1024\x12\t配置值*\btextarea:\brequiredR\x05value\x12l\n" +
"\vdescription\x18\a \x01(\tBJ\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19>\n" +
"\tsize:1024\x12\f备注说明\x1a\x19create;update;view;export*\btextareaR\vdescription:\x0e\xba\xb9\x19\n" +
"\n" +
"\bsettings\"\xe2\x05\n" +
"\bActivity\x12$\n" +

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-aeus. DO NOT EDIT.
// source: system.proto
// date: 2025-07-22 18:30:59
// date: 2025-07-22 16:59:46
package pb

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-aeus. DO NOT EDIT.
// source: system.proto
// date: 2025-07-22 18:30:59
// date: 2025-07-22 16:59:46
package pb
@ -10,12 +10,12 @@ import (
type SettingModel struct {
Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey;column:id" comment:"ID"`
CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" gorm:"column:created_at" comment:"创建时间" scenarios:"view;export"`
UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"column:updated_at" comment:"更新时间" scenarios:"view;export"`
CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" gorm:"column:created_at" comment:"创建时间" scenarios:"search;view;export"`
UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"column:updated_at" comment:"更新时间" scenarios:"search;view;export"`
Name string `json:"name" yaml:"name" xml:"name" gorm:"size:60;column:name" comment:"配置项" props:"readonly:update" rule:"required"`
Type string `json:"type" yaml:"type" xml:"type" gorm:"size:20;column:type" comment:"数据类型" rule:"required" enum:"text:文本;number:数字;json:JSON"`
Value string `json:"value" yaml:"value" xml:"value" gorm:"size:1024;column:value" comment:"配置值" format:"textarea" rule:"required"`
Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024;column:description" comment:"备注说明" scenarios:"list;create;update;view;export" format:"textarea"`
Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024;column:description" comment:"备注说明" scenarios:"create;update;view;export" format:"textarea"`
}
func (m *SettingModel) TableName() string {

View File

@ -27,7 +27,6 @@ type (
tokenStore TokenStore
turnstileValidateUrl string
turnstileSiteKey string
enableRefreshToken bool
}
turnstileRequest struct {
@ -66,12 +65,6 @@ func WithAuthCache(cache cache.Cache) AuthOption {
}
}
func WithRefreshToken() AuthOption {
return func(o *authOptions) {
o.enableRefreshToken = true
}
}
func WithTokenStore(store TokenStore) AuthOption {
return func(o *authOptions) {
o.tokenStore = store
@ -159,25 +152,14 @@ func (s *AuthService) Login(ctx context.Context, req *pb.LoginRequest) (res *pb.
IssuedAt: time.Now().Unix(),
ExpirationAt: time.Now().Add(time.Second * time.Duration(s.opts.ttl)).Unix(),
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
res = &pb.LoginResponse{}
if res.Token, err = token.SignedString(s.opts.secret); err == nil {
res.Uid = model.Uid
res.Username = model.Username
res.Expires = s.opts.ttl
}
if s.opts.enableRefreshToken {
refreshClaims := types.Claims{
Uid: model.Uid,
Role: model.Role,
Admin: model.Admin,
IssuedAt: time.Now().Unix(),
ExpirationAt: time.Now().Add(time.Hour * 48).Unix(),
}
refreshToken := jwt.NewWithClaims(jwt.SigningMethodHS256, refreshClaims)
res.RefreshToken, err = refreshToken.SignedString(s.opts.secret)
}
loginModel := &models.Login{}
loginModel.Uid = model.Uid
loginModel.AccessToken = res.Token
@ -204,39 +186,6 @@ func (s *AuthService) Logout(ctx context.Context, req *pb.LogoutRequest) (res *p
return
}
func (s *AuthService) RefreshToken(ctx context.Context, req *pb.RefreshTokenRequest) (res *pb.RefreshTokenResponse, err error) {
var (
refreshToken *jwt.Token
)
if !s.opts.enableRefreshToken {
err = errors.ErrAccessDenied
return
}
if refreshToken, err = jwt.ParseWithClaims(req.RefreshToken, &types.Claims{}, func(token *jwt.Token) (interface{}, error) {
return s.opts.secret, nil
}); err != nil {
return
}
refreshClaims, ok := refreshToken.Claims.(*types.Claims)
if !ok {
err = errors.ErrIncompatible
}
tokenClaims := types.Claims{
Uid: refreshClaims.Uid,
Role: refreshClaims.Role,
Admin: refreshClaims.Admin,
IssuedAt: time.Now().Unix(),
ExpirationAt: time.Now().Add(time.Second * time.Duration(s.opts.ttl)).Unix(),
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, tokenClaims)
res = &pb.RefreshTokenResponse{}
if res.Token, err = token.SignedString(s.opts.secret); err == nil {
res.Uid = refreshClaims.Uid
res.Expires = s.opts.ttl
}
return
}
func NewAuthService(cbs ...AuthOption) *AuthService {
opts := &authOptions{
ttl: 7200,