mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-12-04 17:38:47 +00:00
feat: Add environment-based operator variant configuration with padding support
- Add os import for environment variable access - Update getOperatorVariant to read OP from OPERATOR_VARIANT env var - Add fallback to default "TelecomOP1234567" for development - Add zero-padding for OP values shorter than 16 bytes - Update comments to reference environment variable configuration
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nutcas3/telecom-platform/apps/api-server/internal/config"
|
"github.com/nutcas3/telecom-platform/apps/api-server/internal/config"
|
||||||
@@ -259,11 +260,25 @@ func (s *SubscriberService) generateAuthKeys() (string, string, error) {
|
|||||||
|
|
||||||
// getOperatorVariant returns the operator variant (OP) from configuration
|
// getOperatorVariant returns the operator variant (OP) from configuration
|
||||||
func (s *SubscriberService) getOperatorVariant() []byte {
|
func (s *SubscriberService) getOperatorVariant() []byte {
|
||||||
// In production, this should come from secure operator configuration
|
// Get operator variant from environment variable or secure configuration
|
||||||
// For now, using a hardcoded OP for demonstration
|
|
||||||
// This should be the same across all subscribers for the same operator
|
// This should be the same across all subscribers for the same operator
|
||||||
|
opStr := os.Getenv("OPERATOR_VARIANT")
|
||||||
|
if opStr == "" {
|
||||||
|
// Fallback to default for development
|
||||||
|
opStr = "TelecomOP1234567" // 16-byte operator variant
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure exactly 16 bytes for AES-128
|
||||||
op := make([]byte, 16)
|
op := make([]byte, 16)
|
||||||
copy(op, []byte("TelecomOP1234567")) // 16-byte operator variant
|
copy(op, []byte(opStr))
|
||||||
|
|
||||||
|
// If shorter than 16 bytes, pad with zeros
|
||||||
|
if len(opStr) < 16 {
|
||||||
|
for i := len(opStr); i < 16; i++ {
|
||||||
|
op[i] = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return op
|
return op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user