auth

package
v0.0.0-...-f6ab580 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OwnerOID             = asn1.ObjectIdentifier([]int{2, 5, 4, 32})
	X500UniqueIdentifier = asn1.ObjectIdentifier([]int{2, 5, 4, 45})
)

Functions

func GenerateToken

func GenerateToken(username string, secret string, expire time.Duration) (string, error)

GenerateToken генерирует токен подписанный секретом

func GetJWTConfig

func GetJWTConfig(secret string) echojwt.Config

GetJWTConfig возвращает настройки для middleware которое проверяет jwt у входящих запросов

func ParseCert

func ParseCert(certPEMBlock []byte) (*x509.Certificate, error)

ParseCert парсит pem блок в структуру сертификата

func ParsePKey

func ParsePKey(pkeyPEMBlock []byte) (any, error)

ParsePKey парсит pem блок в структуру приватного ключа

Types

type CertKeyPair

type CertKeyPair struct {
	Cert *x509.Certificate
	PKey any
}

func LoadKeyPair

func LoadKeyPair(certFile string, pkeyFile string) (CertKeyPair, error)

LoadKeyPair загружает с диска файлы сертификата и ключа и парсит их

type ClientCert

type ClientCert struct {
	Cert []byte
}

func GenerateCert

func GenerateCert(
	caKeyPair CertKeyPair,
	ownerName string,
	clientID string,
	allowedDNS []string,
) (ClientCert, error)

GenerateCert генерирует пару сертификат/ключ для идентификации клиентского приложения возвращает pem блоки с сертификатом X.509 v3 и rsa приватным ключом в кодировке PKCS #8 также в сертификат добавлены два объекта: owner - содержит имя пользователя telegram, которое использует хозяин клиентского приложения X500UniqueIdentifier - уникальный идентификатор клиентского приложения

type JwtCustomClaims

type JwtCustomClaims struct {
	Username string `json:"username"`
	jwt.RegisteredClaims
}

JwtCustomClaims параметры которые хранятся jwt

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL