Реализация на 5

This commit is contained in:
Grbisba
2026-11-17 13:08:13 +03:00
parent 470d9d6f1e
commit 60f48c0337
229 changed files with 74928 additions and 47 deletions
@@ -0,0 +1,35 @@
package jwtprovider
import (
"crypto/rsa"
"fmt"
"os"
"github.com/golang-jwt/jwt/v5"
)
func readPrivateKeyFromFile(path string) (*rsa.PrivateKey, error) {
key, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("failed to read public key: %w", err)
}
privateKey, err := jwt.ParseRSAPrivateKeyFromPEM(key)
if err != nil {
return nil, fmt.Errorf("failed to parse private key: %w", err)
}
return privateKey, nil
}
func readPublicKeyFromFile(path string) (*rsa.PublicKey, error) {
key, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("failed to read public key: %w", err)
}
privateKey, err := jwt.ParseRSAPublicKeyFromPEM(key)
if err != nil {
return nil, fmt.Errorf("failed to parse private key: %w", err)
}
return privateKey, nil
}