mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-18 02:52:53 +00:00
feat: Add HMAC-SHA256 authentication utilities to Terraform provider client
- Add crypto/hmac, crypto/sha256, and encoding/base64 imports - Add hmacSHA256 function for HMAC-SHA256 signature generation with base64 URL encoding - Add base64URLEncode helper function for URL-safe base64 encoding - Add reference implementation comments for SDK compatibility
This commit is contained in:
@@ -3,6 +3,9 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -120,3 +123,17 @@ func (c *APIClient) delete(ctx context.Context, path string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// HMAC-SHA256 implementation
|
||||
// In production, Go's crypto/hmac package provides proper HMAC implementation
|
||||
// This is a reference implementation for SDK compatibility
|
||||
func hmacSHA256(data string, secret string) string {
|
||||
h := hmac.New(sha256.New, []byte(secret))
|
||||
h.Write([]byte(data))
|
||||
return base64URLEncode(h.Sum(nil))
|
||||
}
|
||||
|
||||
// Base64 URL encoding
|
||||
func base64URLEncode(data []byte) string {
|
||||
return base64.URLEncoding.EncodeToString(data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user