Sponsor: remove Creem license key activation (#31824)
This commit is contained in:
parent
75cb289a61
commit
8b243c2a25
22 changed files with 104 additions and 534 deletions
|
|
@ -8,30 +8,19 @@ option go_package = "proto/pb";
|
|||
|
||||
service Auth {
|
||||
rpc IsAuthorized (AuthRequest) returns (AuthReply) {}
|
||||
rpc Activate (ActivateRequest) returns (ActivateReply) {}
|
||||
rpc IsAuthorizedHardware (HardwareRequest) returns (HardwareReply) {}
|
||||
}
|
||||
|
||||
message AuthRequest {
|
||||
string token = 1;
|
||||
string machine_id = 2;
|
||||
}
|
||||
|
||||
message AuthReply {
|
||||
reserved 4; // was activation_key
|
||||
bool authorized = 1;
|
||||
string subject = 2;
|
||||
google.protobuf.Timestamp expires_at = 3;
|
||||
string activation_key = 4;
|
||||
}
|
||||
|
||||
message ActivateRequest {
|
||||
string key = 1;
|
||||
string email = 2;
|
||||
string machine_id = 3;
|
||||
}
|
||||
|
||||
message ActivateReply {
|
||||
string token = 1;
|
||||
string error = 2;
|
||||
}
|
||||
|
||||
message HardwareRequest {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v7.34.1
|
||||
// protoc v7.35.1
|
||||
// source: proto/auth.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -26,6 +25,7 @@ const (
|
|||
type AuthRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
|
||||
MachineId string `protobuf:"bytes,2,opt,name=machine_id,json=machineId,proto3" json:"machine_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
|
@ -67,12 +67,18 @@ func (x *AuthRequest) GetToken() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (x *AuthRequest) GetMachineId() string {
|
||||
if x != nil {
|
||||
return x.MachineId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type AuthReply struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Authorized bool `protobuf:"varint,1,opt,name=authorized,proto3" json:"authorized,omitempty"`
|
||||
Subject string `protobuf:"bytes,2,opt,name=subject,proto3" json:"subject,omitempty"`
|
||||
ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
|
||||
ActivationKey string `protobuf:"bytes,4,opt,name=activation_key,json=activationKey,proto3" json:"activation_key,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
|
@ -128,125 +134,6 @@ func (x *AuthReply) GetExpiresAt() *timestamppb.Timestamp {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (x *AuthReply) GetActivationKey() string {
|
||||
if x != nil {
|
||||
return x.ActivationKey
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ActivateRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
|
||||
MachineId string `protobuf:"bytes,3,opt,name=machine_id,json=machineId,proto3" json:"machine_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ActivateRequest) Reset() {
|
||||
*x = ActivateRequest{}
|
||||
mi := &file_proto_auth_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ActivateRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ActivateRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ActivateRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_auth_proto_msgTypes[2]
|
||||
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 ActivateRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ActivateRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_auth_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ActivateRequest) GetKey() string {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivateRequest) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivateRequest) GetMachineId() string {
|
||||
if x != nil {
|
||||
return x.MachineId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ActivateReply struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
|
||||
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ActivateReply) Reset() {
|
||||
*x = ActivateReply{}
|
||||
mi := &file_proto_auth_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ActivateReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ActivateReply) ProtoMessage() {}
|
||||
|
||||
func (x *ActivateReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_auth_proto_msgTypes[3]
|
||||
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 ActivateReply.ProtoReflect.Descriptor instead.
|
||||
func (*ActivateReply) Descriptor() ([]byte, []int) {
|
||||
return file_proto_auth_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *ActivateReply) GetToken() string {
|
||||
if x != nil {
|
||||
return x.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivateReply) GetError() string {
|
||||
if x != nil {
|
||||
return x.Error
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type HardwareRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
MachineId string `protobuf:"bytes,1,opt,name=machine_id,json=machineId,proto3" json:"machine_id,omitempty"`
|
||||
|
|
@ -258,7 +145,7 @@ type HardwareRequest struct {
|
|||
|
||||
func (x *HardwareRequest) Reset() {
|
||||
*x = HardwareRequest{}
|
||||
mi := &file_proto_auth_proto_msgTypes[4]
|
||||
mi := &file_proto_auth_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -270,7 +157,7 @@ func (x *HardwareRequest) String() string {
|
|||
func (*HardwareRequest) ProtoMessage() {}
|
||||
|
||||
func (x *HardwareRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_auth_proto_msgTypes[4]
|
||||
mi := &file_proto_auth_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -283,7 +170,7 @@ func (x *HardwareRequest) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use HardwareRequest.ProtoReflect.Descriptor instead.
|
||||
func (*HardwareRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_auth_proto_rawDescGZIP(), []int{4}
|
||||
return file_proto_auth_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *HardwareRequest) GetMachineId() string {
|
||||
|
|
@ -317,7 +204,7 @@ type HardwareReply struct {
|
|||
|
||||
func (x *HardwareReply) Reset() {
|
||||
*x = HardwareReply{}
|
||||
mi := &file_proto_auth_proto_msgTypes[5]
|
||||
mi := &file_proto_auth_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -329,7 +216,7 @@ func (x *HardwareReply) String() string {
|
|||
func (*HardwareReply) ProtoMessage() {}
|
||||
|
||||
func (x *HardwareReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_auth_proto_msgTypes[5]
|
||||
mi := &file_proto_auth_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -342,7 +229,7 @@ func (x *HardwareReply) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use HardwareReply.ProtoReflect.Descriptor instead.
|
||||
func (*HardwareReply) Descriptor() ([]byte, []int) {
|
||||
return file_proto_auth_proto_rawDescGZIP(), []int{5}
|
||||
return file_proto_auth_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *HardwareReply) GetAuthorized() bool {
|
||||
|
|
@ -363,25 +250,18 @@ var File_proto_auth_proto protoreflect.FileDescriptor
|
|||
|
||||
const file_proto_auth_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x10proto/auth.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"#\n" +
|
||||
"\x10proto/auth.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"B\n" +
|
||||
"\vAuthRequest\x12\x14\n" +
|
||||
"\x05token\x18\x01 \x01(\tR\x05token\"\xa7\x01\n" +
|
||||
"\x05token\x18\x01 \x01(\tR\x05token\x12\x1d\n" +
|
||||
"\n" +
|
||||
"machine_id\x18\x02 \x01(\tR\tmachineId\"\x86\x01\n" +
|
||||
"\tAuthReply\x12\x1e\n" +
|
||||
"\n" +
|
||||
"authorized\x18\x01 \x01(\bR\n" +
|
||||
"authorized\x12\x18\n" +
|
||||
"\asubject\x18\x02 \x01(\tR\asubject\x129\n" +
|
||||
"\n" +
|
||||
"expires_at\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\x12%\n" +
|
||||
"\x0eactivation_key\x18\x04 \x01(\tR\ractivationKey\"X\n" +
|
||||
"\x0fActivateRequest\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
|
||||
"\x05email\x18\x02 \x01(\tR\x05email\x12\x1d\n" +
|
||||
"\n" +
|
||||
"machine_id\x18\x03 \x01(\tR\tmachineId\";\n" +
|
||||
"\rActivateReply\x12\x14\n" +
|
||||
"\x05token\x18\x01 \x01(\tR\x05token\x12\x14\n" +
|
||||
"\x05error\x18\x02 \x01(\tR\x05error\"\xc1\x01\n" +
|
||||
"expires_at\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAtJ\x04\b\x04\x10\x05\"\xc1\x01\n" +
|
||||
"\x0fHardwareRequest\x12\x1d\n" +
|
||||
"\n" +
|
||||
"machine_id\x18\x01 \x01(\tR\tmachineId\x12\x16\n" +
|
||||
|
|
@ -394,11 +274,10 @@ const file_proto_auth_proto_rawDesc = "" +
|
|||
"\n" +
|
||||
"authorized\x18\x01 \x01(\bR\n" +
|
||||
"authorized\x12\x18\n" +
|
||||
"\asubject\x18\x02 \x01(\tR\asubject2\x9e\x01\n" +
|
||||
"\asubject\x18\x02 \x01(\tR\asubject2n\n" +
|
||||
"\x04Auth\x12*\n" +
|
||||
"\fIsAuthorized\x12\f.AuthRequest\x1a\n" +
|
||||
".AuthReply\"\x00\x12.\n" +
|
||||
"\bActivate\x12\x10.ActivateRequest\x1a\x0e.ActivateReply\"\x00\x12:\n" +
|
||||
".AuthReply\"\x00\x12:\n" +
|
||||
"\x14IsAuthorizedHardware\x12\x10.HardwareRequest\x1a\x0e.HardwareReply\"\x00B\n" +
|
||||
"Z\bproto/pbb\x06proto3"
|
||||
|
||||
|
|
@ -414,28 +293,24 @@ func file_proto_auth_proto_rawDescGZIP() []byte {
|
|||
return file_proto_auth_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_proto_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_proto_auth_proto_goTypes = []any{
|
||||
(*AuthRequest)(nil), // 0: AuthRequest
|
||||
(*AuthReply)(nil), // 1: AuthReply
|
||||
(*ActivateRequest)(nil), // 2: ActivateRequest
|
||||
(*ActivateReply)(nil), // 3: ActivateReply
|
||||
(*HardwareRequest)(nil), // 4: HardwareRequest
|
||||
(*HardwareReply)(nil), // 5: HardwareReply
|
||||
nil, // 6: HardwareRequest.MetadataEntry
|
||||
(*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp
|
||||
(*HardwareRequest)(nil), // 2: HardwareRequest
|
||||
(*HardwareReply)(nil), // 3: HardwareReply
|
||||
nil, // 4: HardwareRequest.MetadataEntry
|
||||
(*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp
|
||||
}
|
||||
var file_proto_auth_proto_depIdxs = []int32{
|
||||
7, // 0: AuthReply.expires_at:type_name -> google.protobuf.Timestamp
|
||||
6, // 1: HardwareRequest.metadata:type_name -> HardwareRequest.MetadataEntry
|
||||
5, // 0: AuthReply.expires_at:type_name -> google.protobuf.Timestamp
|
||||
4, // 1: HardwareRequest.metadata:type_name -> HardwareRequest.MetadataEntry
|
||||
0, // 2: Auth.IsAuthorized:input_type -> AuthRequest
|
||||
2, // 3: Auth.Activate:input_type -> ActivateRequest
|
||||
4, // 4: Auth.IsAuthorizedHardware:input_type -> HardwareRequest
|
||||
1, // 5: Auth.IsAuthorized:output_type -> AuthReply
|
||||
3, // 6: Auth.Activate:output_type -> ActivateReply
|
||||
5, // 7: Auth.IsAuthorizedHardware:output_type -> HardwareReply
|
||||
5, // [5:8] is the sub-list for method output_type
|
||||
2, // [2:5] is the sub-list for method input_type
|
||||
2, // 3: Auth.IsAuthorizedHardware:input_type -> HardwareRequest
|
||||
1, // 4: Auth.IsAuthorized:output_type -> AuthReply
|
||||
3, // 5: Auth.IsAuthorizedHardware:output_type -> HardwareReply
|
||||
4, // [4:6] is the sub-list for method output_type
|
||||
2, // [2:4] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
|
|
@ -452,7 +327,7 @@ func file_proto_auth_proto_init() {
|
|||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_auth_proto_rawDesc), len(file_proto_auth_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 7,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.1
|
||||
// - protoc v7.34.1
|
||||
// - protoc v7.35.1
|
||||
// source: proto/auth.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
|
@ -21,7 +20,6 @@ const _ = grpc.SupportPackageIsVersion9
|
|||
|
||||
const (
|
||||
Auth_IsAuthorized_FullMethodName = "/Auth/IsAuthorized"
|
||||
Auth_Activate_FullMethodName = "/Auth/Activate"
|
||||
Auth_IsAuthorizedHardware_FullMethodName = "/Auth/IsAuthorizedHardware"
|
||||
)
|
||||
|
||||
|
|
@ -30,7 +28,6 @@ const (
|
|||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type AuthClient interface {
|
||||
IsAuthorized(ctx context.Context, in *AuthRequest, opts ...grpc.CallOption) (*AuthReply, error)
|
||||
Activate(ctx context.Context, in *ActivateRequest, opts ...grpc.CallOption) (*ActivateReply, error)
|
||||
IsAuthorizedHardware(ctx context.Context, in *HardwareRequest, opts ...grpc.CallOption) (*HardwareReply, error)
|
||||
}
|
||||
|
||||
|
|
@ -52,16 +49,6 @@ func (c *authClient) IsAuthorized(ctx context.Context, in *AuthRequest, opts ...
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authClient) Activate(ctx context.Context, in *ActivateRequest, opts ...grpc.CallOption) (*ActivateReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ActivateReply)
|
||||
err := c.cc.Invoke(ctx, Auth_Activate_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authClient) IsAuthorizedHardware(ctx context.Context, in *HardwareRequest, opts ...grpc.CallOption) (*HardwareReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(HardwareReply)
|
||||
|
|
@ -77,7 +64,6 @@ func (c *authClient) IsAuthorizedHardware(ctx context.Context, in *HardwareReque
|
|||
// for forward compatibility.
|
||||
type AuthServer interface {
|
||||
IsAuthorized(context.Context, *AuthRequest) (*AuthReply, error)
|
||||
Activate(context.Context, *ActivateRequest) (*ActivateReply, error)
|
||||
IsAuthorizedHardware(context.Context, *HardwareRequest) (*HardwareReply, error)
|
||||
mustEmbedUnimplementedAuthServer()
|
||||
}
|
||||
|
|
@ -92,9 +78,6 @@ type UnimplementedAuthServer struct{}
|
|||
func (UnimplementedAuthServer) IsAuthorized(context.Context, *AuthRequest) (*AuthReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method IsAuthorized not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServer) Activate(context.Context, *ActivateRequest) (*ActivateReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Activate not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServer) IsAuthorizedHardware(context.Context, *HardwareRequest) (*HardwareReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method IsAuthorizedHardware not implemented")
|
||||
}
|
||||
|
|
@ -137,24 +120,6 @@ func _Auth_IsAuthorized_Handler(srv interface{}, ctx context.Context, dec func(i
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Auth_Activate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ActivateRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServer).Activate(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Auth_Activate_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServer).Activate(ctx, req.(*ActivateRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Auth_IsAuthorizedHardware_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(HardwareRequest)
|
||||
if err := dec(in); err != nil {
|
||||
|
|
@ -184,10 +149,6 @@ var Auth_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "IsAuthorized",
|
||||
Handler: _Auth_IsAuthorized_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Activate",
|
||||
Handler: _Auth_Activate_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "IsAuthorizedHardware",
|
||||
Handler: _Auth_IsAuthorizedHardware_Handler,
|
||||
|
|
|
|||
|
|
@ -11,10 +11,7 @@
|
|||
:disable-remove="!hasUiToken"
|
||||
disable-cancel
|
||||
@changed="$emit('changed')"
|
||||
@open="
|
||||
showForm = false;
|
||||
activeTab = 'github';
|
||||
"
|
||||
@open="showForm = false"
|
||||
>
|
||||
<template #default="{ values }">
|
||||
<div class="mt-4 mb-3">
|
||||
|
|
@ -22,104 +19,28 @@
|
|||
</div>
|
||||
<hr class="my-4" />
|
||||
<div v-if="showTokenForm">
|
||||
<!-- hidden feature: tab navigation
|
||||
<ul v-if="$hiddenFeatures()" class="nav nav-tabs mb-3" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button
|
||||
class="nav-link"
|
||||
:class="{ active: activeTab === 'github' }"
|
||||
type="button"
|
||||
@click="
|
||||
if (activeTab !== 'github') {
|
||||
values.token = '';
|
||||
values.email = '';
|
||||
}
|
||||
activeTab = 'github';
|
||||
"
|
||||
>
|
||||
Sponsor Token
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button
|
||||
class="nav-link"
|
||||
:class="{ active: activeTab === 'direct' }"
|
||||
type="button"
|
||||
@click="
|
||||
if (activeTab !== 'direct') {
|
||||
values.token = '';
|
||||
values.email = '';
|
||||
}
|
||||
activeTab = 'direct';
|
||||
"
|
||||
>
|
||||
Activation Key 🧪
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
-->
|
||||
<div v-if="activeTab === 'github'">
|
||||
<label for="sponsorToken" class="my-2">
|
||||
{{ $t("config.sponsor.enterYourToken") }}
|
||||
</label>
|
||||
<textarea
|
||||
id="sponsorToken"
|
||||
v-model.trim="values.token"
|
||||
class="form-control mb-1"
|
||||
required
|
||||
rows="5"
|
||||
spellcheck="false"
|
||||
@paste="(event) => handlePaste(event, values)"
|
||||
/>
|
||||
<i18n-t tag="small" keypath="config.sponsor.descriptionToken" scope="global">
|
||||
<template #url>
|
||||
<a href="https://sponsor.evcc.io" target="_blank">sponsor.evcc.io</a>
|
||||
</template>
|
||||
<template #trialToken>
|
||||
<a :href="trialTokenLink" target="_blank">{{
|
||||
$t("config.sponsor.trialToken")
|
||||
}}</a>
|
||||
</template>
|
||||
</i18n-t>
|
||||
</div>
|
||||
<div v-else-if="activeTab === 'direct'">
|
||||
<label for="sponsorEmail" class="my-2">{{ $t("config.sponsor.email") }}</label>
|
||||
<input
|
||||
id="sponsorEmail"
|
||||
v-model.trim="values.email"
|
||||
type="email"
|
||||
class="form-control mb-1"
|
||||
required
|
||||
/>
|
||||
<i18n-t
|
||||
tag="small"
|
||||
keypath="config.sponsor.emailHint"
|
||||
scope="global"
|
||||
class="mb-3 d-block text-muted"
|
||||
>
|
||||
<template #url>
|
||||
<a href="https://sponsor.evcc.io/" target="_blank">direct sponsoring</a>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<label for="licenseKey" class="my-2">{{
|
||||
$t("config.sponsor.activationKey")
|
||||
}}</label>
|
||||
<input
|
||||
id="licenseKey"
|
||||
v-model.trim="values.token"
|
||||
class="form-control mb-1 font-monospace"
|
||||
required
|
||||
spellcheck="false"
|
||||
pattern="[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}"
|
||||
title="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
|
||||
@input="values.token = values.token.toUpperCase()"
|
||||
/>
|
||||
<i18n-t tag="small" keypath="config.sponsor.activationKeyHint" scope="global">
|
||||
<template #url>
|
||||
<a href="about:blank" target="_blank">Customer Portal</a>
|
||||
</template>
|
||||
</i18n-t>
|
||||
</div>
|
||||
<label for="sponsorToken" class="my-2">
|
||||
{{ $t("config.sponsor.enterYourToken") }}
|
||||
</label>
|
||||
<textarea
|
||||
id="sponsorToken"
|
||||
v-model.trim="values.token"
|
||||
class="form-control mb-1"
|
||||
required
|
||||
rows="5"
|
||||
spellcheck="false"
|
||||
@paste="(event) => handlePaste(event, values)"
|
||||
/>
|
||||
<i18n-t tag="small" keypath="config.sponsor.descriptionToken" scope="global">
|
||||
<template #url>
|
||||
<a href="https://sponsor.evcc.io" target="_blank">sponsor.evcc.io</a>
|
||||
</template>
|
||||
<template #trialToken>
|
||||
<a :href="trialTokenLink" target="_blank">{{
|
||||
$t("config.sponsor.trialToken")
|
||||
}}</a>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<div v-if="hasUiToken" class="d-flex justify-content-end mt-3">
|
||||
<button
|
||||
type="button"
|
||||
|
|
@ -127,7 +48,6 @@
|
|||
@click="
|
||||
editMode = false;
|
||||
values.token = '';
|
||||
values.email = '';
|
||||
"
|
||||
>
|
||||
{{ $t("config.general.cancel") }}
|
||||
|
|
@ -135,64 +55,32 @@
|
|||
</div>
|
||||
</div>
|
||||
<div v-else-if="token">
|
||||
<div v-if="activationKey">
|
||||
<label for="existingEmail" class="fw-bold my-2">{{
|
||||
$t("config.sponsor.email")
|
||||
}}</label>
|
||||
<div class="text-muted mb-3">
|
||||
<input id="existingEmail" :value="name" disabled class="form-control" />
|
||||
</div>
|
||||
<label for="existingActivationKey" class="fw-bold my-2">{{
|
||||
$t("config.sponsor.activationKey")
|
||||
}}</label>
|
||||
<div class="text-muted">
|
||||
<input
|
||||
id="existingActivationKey"
|
||||
:value="activationKey"
|
||||
disabled
|
||||
class="form-control font-monospace"
|
||||
:class="{ 'is-invalid': error }"
|
||||
/>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end mt-2">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-link text-nowrap"
|
||||
:class="error ? 'text-danger' : 'text-muted'"
|
||||
@click="editMode = true"
|
||||
>
|
||||
{{ $t("config.general.change") }}
|
||||
</button>
|
||||
</div>
|
||||
<label for="existingToken" class="fw-bold my-2">{{
|
||||
$t("config.sponsor.yourToken")
|
||||
}}</label>
|
||||
<div class="text-muted">
|
||||
<input
|
||||
id="existingToken"
|
||||
:value="token"
|
||||
disabled
|
||||
rows="1"
|
||||
class="form-control"
|
||||
:class="{ 'is-invalid': error }"
|
||||
/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<label for="existingToken" class="fw-bold my-2">{{
|
||||
$t("config.sponsor.yourToken")
|
||||
}}</label>
|
||||
<div class="text-muted">
|
||||
<input
|
||||
id="existingToken"
|
||||
:value="token"
|
||||
disabled
|
||||
rows="1"
|
||||
class="form-control"
|
||||
:class="{ 'is-invalid': error }"
|
||||
/>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end mt-2">
|
||||
<span v-if="fromYaml" class="text-nowrap small text-muted">
|
||||
{{ $t("config.sponsor.viaYaml") }}
|
||||
</span>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="btn btn-link text-nowrap"
|
||||
:class="error ? 'text-danger' : 'text-muted'"
|
||||
@click="editMode = true"
|
||||
>
|
||||
{{ $t("config.sponsor.changeToken") }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end mt-2">
|
||||
<span v-if="fromYaml" class="text-nowrap small text-muted">
|
||||
{{ $t("config.sponsor.viaYaml") }}
|
||||
</span>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="btn btn-link text-nowrap"
|
||||
:class="error ? 'text-danger' : 'text-muted'"
|
||||
@click="editMode = true"
|
||||
>
|
||||
{{ $t("config.sponsor.changeToken") }}
|
||||
</button>
|
||||
</div>
|
||||
<SponsorTokenExpires v-bind="sponsor" />
|
||||
</div>
|
||||
|
|
@ -216,7 +104,6 @@ export default {
|
|||
emits: ["changed"],
|
||||
data: () => ({
|
||||
editMode: false,
|
||||
activeTab: "github",
|
||||
}),
|
||||
computed: {
|
||||
sponsor() {
|
||||
|
|
@ -225,9 +112,6 @@ export default {
|
|||
token() {
|
||||
return this.sponsor?.status?.token;
|
||||
},
|
||||
activationKey() {
|
||||
return this.sponsor?.status?.activationKey;
|
||||
},
|
||||
fromYaml() {
|
||||
return !!this.sponsor?.yamlSource;
|
||||
},
|
||||
|
|
@ -249,21 +133,12 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
transformReadValues() {
|
||||
return { token: "", email: "" };
|
||||
return { token: "" };
|
||||
},
|
||||
handlePaste(event, values) {
|
||||
event.preventDefault();
|
||||
const text = event.clipboardData.getData("text");
|
||||
const cleaned = cleanYaml(text, "sponsortoken");
|
||||
values.token = cleaned;
|
||||
if (this.activeTab === "github" && this.isLicenseKey(cleaned)) {
|
||||
this.activeTab = "direct";
|
||||
}
|
||||
},
|
||||
isLicenseKey(token) {
|
||||
// Match pattern XXXXX-XXXXX-XXXXX-XXXXX-XXXXX (case-insensitive alphanumeric)
|
||||
const pattern = /^[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}$/i;
|
||||
return pattern.test(token || "");
|
||||
values.token = cleanYaml(text, "sponsortoken");
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -744,14 +744,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Licenční klíč",
|
||||
"activationKeyHint": "Odesláno e-mailem. Najdete na adrese {url}.",
|
||||
"addToken": "Zadejte token",
|
||||
"changeToken": "Změnit token",
|
||||
"description": "Sponzorský model nám pomáhá udržovat projekt a udržitelně vyvíjet nové a vzrušující funkce. Jako sponzor získáte přístup ke všem implementacím nabíječek.",
|
||||
"descriptionToken": "Sponzorský token získáte na {url}. Pro začátek nabízíme také zkušební token {trialToken}.",
|
||||
"email": "E-mail",
|
||||
"emailHint": "E-mailová adresa, kterou jste použili pro {url}",
|
||||
"enterYourToken": "Váš sponzorský token",
|
||||
"error": "Sponzorský token není platný.",
|
||||
"invalid": "Neplatný sponzorský token",
|
||||
|
|
|
|||
|
|
@ -779,14 +779,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Licensnøgle",
|
||||
"activationKeyHint": "Er sendt via email. Findes i {url}.",
|
||||
"addToken": "Indtast token",
|
||||
"changeToken": "Udskift token",
|
||||
"description": "Sponsormodellen hjælper os med at vedligeholde projektet og bæredygtigt bygge nye og spændende funktioner. Som sponsor får du adgang til alle opladning mulighederne.",
|
||||
"descriptionToken": "Som GitHub sponsor finder du din token på {url}. For at komme i gang tilbyder vi en {trialToken}.",
|
||||
"email": "Email",
|
||||
"emailHint": "Den email adresse du benyttede for {url}",
|
||||
"enterYourToken": "Din Sponsor token",
|
||||
"error": "Dit Sponsortoken er ikke gyldigt.",
|
||||
"invalid": "ugyldig",
|
||||
|
|
|
|||
|
|
@ -840,14 +840,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Lizenzschlüssel",
|
||||
"activationKeyHint": "Per E-Mail zugesandt. Kann im {url} gefunden werden.",
|
||||
"addToken": "Token eingeben",
|
||||
"changeToken": "Token ändern",
|
||||
"description": "Das Sponsoring-Modell hilft uns, das Projekt zu pflegen und nachhaltig neue und spannende Funktionen zu entwickeln. Als Sponsor erhältst du Zugriff auf alle Wallbox-Implementierungen.",
|
||||
"descriptionToken": "Als GitHub-Sponsor findest du dein Token auf {url}. Zum Ausprobieren gibt's ein {trialToken}.",
|
||||
"email": "E-Mail",
|
||||
"emailHint": "E-Mail-Adresse, die du für {url} verwendet hast",
|
||||
"enterYourToken": "Dein Sponsor Token",
|
||||
"error": "Das Sponsortoken ist ungültig.",
|
||||
"invalid": "ungültig",
|
||||
|
|
|
|||
|
|
@ -840,14 +840,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "License Key",
|
||||
"activationKeyHint": "Sent to you via email. Can be found in the {url}.",
|
||||
"addToken": "Enter token",
|
||||
"changeToken": "Change token",
|
||||
"description": "The sponsoring model helps us to maintain the project and sustainably build new and exciting features. As a sponsor you get access to all charger implementations.",
|
||||
"descriptionToken": "As GitHub Sponsor you find your token on {url}. For getting-started, we offer a {trialToken}.",
|
||||
"email": "Email",
|
||||
"emailHint": "Email address you used for {url}",
|
||||
"enterYourToken": "Your Sponsor Token",
|
||||
"error": "The sponsor token is not valid.",
|
||||
"invalid": "invalid",
|
||||
|
|
|
|||
|
|
@ -778,14 +778,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Lisenssiavain",
|
||||
"activationKeyHint": "Lähetetty sähköpostitse. Löytyy osoitteesta {url}.",
|
||||
"addToken": "Anna tunnus",
|
||||
"changeToken": "Vaihda tunnus",
|
||||
"description": "Sponsorointi auttaa meitä ylläpitämään projektia ja rakentamaan kestävästi uusia ja jännittäviä ominaisuuksia. Sponsorina saat käyttöösi kaikki latureiden toteutukset.",
|
||||
"descriptionToken": "GitHub-sponsorina löydät sponsorointitunnuksesi osoitteesta {url}. Päästäksesi alkuun tarjoamme {trialToken}.",
|
||||
"email": "Sähköposti",
|
||||
"emailHint": "Sähköpostiosoite, jota käytit {url}:een",
|
||||
"enterYourToken": "Sponsorointitunnuksesi",
|
||||
"error": "Sponsoritunnus ei kelpaa.",
|
||||
"invalid": "epäkelpo",
|
||||
|
|
|
|||
|
|
@ -782,14 +782,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Clé de licence",
|
||||
"activationKeyHint": "Vous a été envoyé par email. Peut être trouvé via {url}.",
|
||||
"addToken": "Entrer le jeton",
|
||||
"changeToken": "Modifier le jeton",
|
||||
"description": "Le modèle de parrainage nous aide à maintenir le projet et à construire de manière durable de nouvelles fonctionnalités passionnantes. En tant que parrain, vous avez accès à toutes les implémentations de chargeurs.",
|
||||
"descriptionToken": "En tant que sponsor GitHub, vous pouvez obtenir un jeton sur {url}. Pour démarrer, nous offrons également un jeton d’essai pour les tests {trialToken}.",
|
||||
"email": "Email",
|
||||
"emailHint": "L’adresse email que vous avez utilisé pour {url}",
|
||||
"enterYourToken": "Votre jeton de sponsor",
|
||||
"error": "Le jeton de parrain n’est pas valide.",
|
||||
"invalid": "invalide",
|
||||
|
|
|
|||
|
|
@ -691,14 +691,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Chiave di licenza",
|
||||
"activationKeyHint": "Inviata via mail. Puoi trovarla in{url}.",
|
||||
"addToken": "Inserisci il token",
|
||||
"changeToken": "Modifica il token",
|
||||
"description": "Il modello di sponsorizzazione ci aiuta a mantenere il progetto e a introdurre in modo sostenibile nuove ed entusiasmanti funzionalità. Come sponsor hai accesso a tutte le implementazioni del caricabatterie.",
|
||||
"descriptionToken": "In qualità di sponsor su GitGub, trovi il tuo token in {url}. Offriamo anche un token di prova per i test {trialToken}.",
|
||||
"email": "Email",
|
||||
"emailHint": "Email usata per {url}",
|
||||
"enterYourToken": "Il tuo token Sponsor",
|
||||
"error": "Il token sponsor non è valido.",
|
||||
"invalid": "non valido",
|
||||
|
|
|
|||
|
|
@ -700,14 +700,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "ライセンスキー",
|
||||
"activationKeyHint": "メールにて送付されます。{url} で確認することも可能です。",
|
||||
"addToken": "トークンを入力",
|
||||
"changeToken": "トークンを変更",
|
||||
"description": "スポンサーシップモデルは、プロジェクトの維持や、新しい魅力的な機能の継続的な開発に役立ちます。スポンサーになると、すべての充電器の統合機能にアクセスできるようになります。",
|
||||
"descriptionToken": "GitHubスポンサーの方は、{url} でトークンを確認できます。まず試してみたい方のために、{trialToken} もご用意しています。",
|
||||
"email": "メールアドレス",
|
||||
"emailHint": "{url} で使用したメールアドレス",
|
||||
"enterYourToken": "スポンサートークンを入力",
|
||||
"error": "スポンサートークンが無効です。",
|
||||
"invalid": "無効",
|
||||
|
|
|
|||
|
|
@ -706,14 +706,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Lizenzschlëssel",
|
||||
"activationKeyHint": "Per E-Mail un Iech geschéckt. Op der {url} ze fannen.",
|
||||
"addToken": "Token aginn",
|
||||
"changeToken": "Token änneren",
|
||||
"description": "De Sponsoring Modell hëlleft eis de Projet z'erhalen an nohalteg nei a spannend Fonctiounen z'entwéckelen. Als Sponsor kriss du Zougank zu all Wallbox-Implementatiounen.",
|
||||
"descriptionToken": "Als GitHub-Sponsor fannt Dir Ären Token op {url}. Mir bidden och ee Test-Token un fir ze testen {trialToken}.",
|
||||
"email": "E-Mail",
|
||||
"emailHint": "E-Mail-Adress, déi Dir fir {url} benotzt hutt",
|
||||
"enterYourToken": "Äre Sponsor-Token",
|
||||
"error": "De Sponsortoken ass ongülteg.",
|
||||
"invalid": "ongülteg",
|
||||
|
|
|
|||
|
|
@ -783,14 +783,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Licencijos Raktas",
|
||||
"activationKeyHint": "Išsiųstas jums el. paštu. Galima rasti adresu {url}.",
|
||||
"addToken": "Įveskite žetoną",
|
||||
"changeToken": "Pakeisti žetoną",
|
||||
"description": "Rėmimo modelis padeda mums išlaikyti projektą ir tvariai kurti naujas, įdomias funkcijas. Kaip rėmėjas jūs galite valdyti įkroviklius, kurių naudojimui reikia rėmimo.",
|
||||
"descriptionToken": "GitHub rėmėjai gali matyti savo žetoną (token) {url}. Pradžiai - pasibandymui siūlome {trialToken}.",
|
||||
"email": "El. paštas",
|
||||
"emailHint": "El. pašto adresas, kurį naudojote {url}",
|
||||
"enterYourToken": "Jūsų rėmėjo žetonas",
|
||||
"error": "Rėmėjo žetonas (token) negalioja.",
|
||||
"invalid": "negalioja",
|
||||
|
|
|
|||
|
|
@ -769,14 +769,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Licences atslēga",
|
||||
"activationKeyHint": "Nostūtīts jums pa e-pastu. Atrodams {url}.",
|
||||
"addToken": "Ievadiet marķieri",
|
||||
"changeToken": "Mainīt marķieri",
|
||||
"description": "Sponsorēšanas modelis palīdz mums uzturēt projektu un ilgtspējīgi veidot jaunas un aizraujošas funkcijas. Kā sponsors jūs iegūstat piekļuvi visām lādētāju implementācijām.",
|
||||
"descriptionToken": "Kā GitHub Sponsors jūs atrodat savu marķieri {url}. Iesākumam piedāvājam {trialToken}.",
|
||||
"email": "E-pasts",
|
||||
"emailHint": "E-pasta adrese ko izmantojāt {url}",
|
||||
"enterYourToken": "Jūsu sponsora marķieris",
|
||||
"error": "Sponsora marķieris nav derīgs.",
|
||||
"invalid": "nederīgs",
|
||||
|
|
|
|||
|
|
@ -763,14 +763,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Licentiesleutel",
|
||||
"activationKeyHint": "Verzonden via email. Deze kan hier gevonden worden: {url}.",
|
||||
"addToken": "Token invoeren",
|
||||
"changeToken": "Token bewerken",
|
||||
"description": "Het sponsormodel helpt ons het project te onderhouden en nieuwe toffe functies te ontwikkelen. Als sponsor krijg je toegang tot de implementaties voor alle laadpunten.",
|
||||
"descriptionToken": "Als GitHub-sponsor vind je jouw token op {url}. Om aan de slag te kunnen, bieden we een {trialToken}.",
|
||||
"email": "E-mail",
|
||||
"emailHint": "Email adres dat u gebruikte voor {url}",
|
||||
"enterYourToken": "Jouw sponsortoken",
|
||||
"error": "De sponsortoken is ongeldig.",
|
||||
"invalid": "ongeldig",
|
||||
|
|
|
|||
|
|
@ -698,14 +698,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Chave de licença",
|
||||
"activationKeyHint": "Enviado por e-mail. Pode ser consultado em {url}.",
|
||||
"addToken": "Insira token",
|
||||
"changeToken": "Alterar token",
|
||||
"description": "O modelo de apoio (sponsoring) ajuda-nos a manter o projeto e a desenvolver, de forma sustentável, novas funcionalidades. Como apoiante (sponsor), terá acesso às integrações de todos os Carregadores.",
|
||||
"descriptionToken": "Como patrocinado do GitHub, pode encontrar o seu token em {url}. Para começar, disponibilizamos um {trialToken}.",
|
||||
"email": "E-mail",
|
||||
"emailHint": "Endereço de e-mail que utilizou para {url}",
|
||||
"enterYourToken": "O teu token de patrocinador",
|
||||
"error": "O token de Apoiante (Sponsor) não é válido.",
|
||||
"invalid": "inválido",
|
||||
|
|
|
|||
|
|
@ -772,14 +772,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Licenčný kľúč",
|
||||
"activationKeyHint": "Odoslané e-mailom. Nájdete ho na adrese {url}.",
|
||||
"addToken": "Zadajte token",
|
||||
"changeToken": "Zmena tokenu",
|
||||
"description": "Model sponzorstva nám pomáha udržiavať projekt a trvalo vytvárať nové a zaujímavé funkcie. Ako sponzor získate prístup ku všetkým implementáciám nabíjačiek.",
|
||||
"descriptionToken": "Ako GitHub sponzor nájdete token na {url}. Pre začiatok ponúkame {trialToken}.",
|
||||
"email": "E-mail",
|
||||
"emailHint": "E-mailová adresa, ktorú ste použili pre {url}",
|
||||
"enterYourToken": "Váš sponzorský Token",
|
||||
"error": "Sponzorský token nie je platný.",
|
||||
"invalid": "neplatný",
|
||||
|
|
|
|||
|
|
@ -753,14 +753,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Licensnyckel",
|
||||
"activationKeyHint": "Skickas med epost. Finns här {url}.",
|
||||
"addToken": "Ange sponsor-token",
|
||||
"changeToken": "Ändra sponsor-token",
|
||||
"description": "Sponsormodellen hjälper oss att underhålla projektet och hållbart bygga nya och spännande funktioner. Som sponsor får du tillgång till alla laddningsmöjligheter.",
|
||||
"descriptionToken": "Som GitHub-sponsor hittar du din token på {url}. För att komma igång erbjuder vi en {trialToken}.",
|
||||
"email": "Epost",
|
||||
"emailHint": "Epost du använt för {url}",
|
||||
"enterYourToken": "Din sponsor-token",
|
||||
"error": "Din sponsor-token är inte giltig.",
|
||||
"invalid": "ogiltig",
|
||||
|
|
|
|||
|
|
@ -730,14 +730,10 @@
|
|||
"title": "SMA Sunny Home Manager"
|
||||
},
|
||||
"sponsor": {
|
||||
"activationKey": "Lisans Anahtarı",
|
||||
"activationKeyHint": "Sana e-posta yoluyla gönderildi. {url} adresinde bulabilirsin.",
|
||||
"addToken": "Jetonu gir",
|
||||
"changeToken": "Jetonu değiştir",
|
||||
"description": "Destek modeli, projeyi sürdürmemize ve sürdürülebilir bir şekilde yeni ve heyecan verici özellikler geliştirmemize yardımcı oluyor. Destekçi olarak tüm doldurma cihazı uygulamalarına erişimin oluyor.",
|
||||
"descriptionToken": "GitHub Destekçisi olarak jetonunu {url} adresinde bulabilirsin. Deneyebilmen için sana bir {trialToken} veriyoruz.",
|
||||
"email": "E-posta",
|
||||
"emailHint": "{url} için kullandığın e-posta adresi",
|
||||
"enterYourToken": "Destekçi Jetonun",
|
||||
"error": "Destekçi jetonu geçerli değil.",
|
||||
"invalid": "geçersiz",
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@ package server
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/evcc-io/evcc/api/globalconfig"
|
||||
"github.com/evcc-io/evcc/core/keys"
|
||||
|
|
@ -13,8 +10,6 @@ import (
|
|||
"github.com/evcc-io/evcc/util/sponsor"
|
||||
)
|
||||
|
||||
var licenseKeyPattern = regexp.MustCompile(`^[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}$`)
|
||||
|
||||
func setOptimizer(pub publisher) func(bool) error {
|
||||
return func(b bool) error {
|
||||
settings.SetBool(keys.Optimizer, b)
|
||||
|
|
@ -45,7 +40,6 @@ func updateSponsortokenHandler(pub publisher) func(w http.ResponseWriter, r *htt
|
|||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
Token string `json:"token"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
|
|
@ -53,27 +47,7 @@ func updateSponsortokenHandler(pub publisher) func(w http.ResponseWriter, r *htt
|
|||
return
|
||||
}
|
||||
|
||||
var token string
|
||||
|
||||
// License key activation flow
|
||||
if req.Email != "" {
|
||||
// Validate token matches license key pattern
|
||||
if !licenseKeyPattern.MatchString(strings.ToUpper(req.Token)) {
|
||||
jsonError(w, http.StatusBadRequest, fmt.Errorf("invalid license key format"))
|
||||
return
|
||||
}
|
||||
|
||||
// Activate license key and receive JWT token
|
||||
var err error
|
||||
token, err = sponsor.ActivateSponsorship(req.Token, req.Email)
|
||||
if err != nil {
|
||||
jsonError(w, http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// Use provided JWT token directly
|
||||
token = req.Token
|
||||
}
|
||||
token := req.Token
|
||||
|
||||
if token != "" {
|
||||
if err := sponsor.ConfigureSponsorship(token); err != nil {
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
mu sync.RWMutex
|
||||
Subject, Token, ActivationKey string
|
||||
ExpiresAt time.Time
|
||||
mu sync.RWMutex
|
||||
Subject, Token string
|
||||
ExpiresAt time.Time
|
||||
)
|
||||
|
||||
func machineID() string {
|
||||
|
|
@ -58,35 +58,6 @@ func IsAuthorizedForApi() bool {
|
|||
return IsAuthorized() && Subject != unavailable && Token != ""
|
||||
}
|
||||
|
||||
// ActivateSponsorship activates a license key with email and returns the JWT token
|
||||
func ActivateSponsorship(licenseKey, email string) (string, error) {
|
||||
conn, err := cloud.Connection()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("connection failed: %w", err)
|
||||
}
|
||||
|
||||
client := pb.NewAuthClient(conn)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
res, err := client.Activate(ctx, &pb.ActivateRequest{
|
||||
Key: licenseKey,
|
||||
Email: email,
|
||||
MachineId: machineID(),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("activation failed: %w", err)
|
||||
}
|
||||
|
||||
if res.Error != "" {
|
||||
return "", fmt.Errorf("%s", res.Error)
|
||||
}
|
||||
|
||||
return res.Token, nil
|
||||
}
|
||||
|
||||
// check and set sponsorship token
|
||||
func ConfigureSponsorship(token string) error {
|
||||
mu.Lock()
|
||||
|
|
@ -130,10 +101,9 @@ func ConfigureSponsorship(token string) error {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
res, err := client.IsAuthorized(ctx, &pb.AuthRequest{Token: token})
|
||||
res, err := client.IsAuthorized(ctx, &pb.AuthRequest{Token: token, MachineId: machineID()})
|
||||
if err == nil && res.Authorized {
|
||||
Subject = res.Subject
|
||||
ActivationKey = res.ActivationKey
|
||||
ExpiresAt = res.ExpiresAt.AsTime()
|
||||
}
|
||||
|
||||
|
|
@ -161,20 +131,11 @@ func redactToken(token string) string {
|
|||
return token[:6] + "......." + token[len(token)-6:]
|
||||
}
|
||||
|
||||
// redactKey returns a redacted version of the activation key showing only the first segment
|
||||
func redactKey(key string) string {
|
||||
if idx := strings.Index(key, "-"); idx > 0 {
|
||||
return key[:idx] + "-XXXXX-XXXXX-XXXXX-XXXXX"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Status struct {
|
||||
Name string `json:"name"`
|
||||
ExpiresAt time.Time `json:"expiresAt,omitempty"`
|
||||
ExpiresSoon bool `json:"expiresSoon,omitempty"`
|
||||
Token string `json:"token,omitempty"`
|
||||
ActivationKey string `json:"activationKey,omitempty"`
|
||||
Name string `json:"name"`
|
||||
ExpiresAt time.Time `json:"expiresAt,omitempty"`
|
||||
ExpiresSoon bool `json:"expiresSoon,omitempty"`
|
||||
Token string `json:"token,omitempty"`
|
||||
}
|
||||
|
||||
// RedactedStatus returns the sponsorship status
|
||||
|
|
@ -188,10 +149,9 @@ func RedactedStatus() Status {
|
|||
}
|
||||
|
||||
return Status{
|
||||
Name: Subject,
|
||||
ExpiresAt: ExpiresAt,
|
||||
ExpiresSoon: expiresSoon,
|
||||
Token: redactToken(Token),
|
||||
ActivationKey: redactKey(ActivationKey),
|
||||
Name: Subject,
|
||||
ExpiresAt: ExpiresAt,
|
||||
ExpiresSoon: expiresSoon,
|
||||
Token: redactToken(Token),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue