mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-09 15:17:39 +02:00
authenticate: unmarshal and verify state from jwt, instead of middleware authorize: embed opa policy using statik authorize: have IsAuthorized handle authorization for all routes authorize: if no signing key is provided, one is generated authorize: remove IsAdmin grpc endpoint authorize/client: return authorize decision struct cmd/pomerium: main logger no longer contains email and group cryptutil: add ECDSA signing methods dashboard: have impersonate form show up for all users, but have api gated by authz docs: fix typo in signed jwt header encoding/jws: remove unused es256 signer frontend: namespace static web assets internal/sessions: remove leeway to match authz policy proxy: move signing functionality to authz proxy: remove jwt attestation from proxy (authZ does now) proxy: remove non-signed headers from headers proxy: remove special handling of x-forwarded-host sessions: do not verify state in middleware sessions: remove leeway from state to match authz sessions/{all}: store jwt directly instead of state Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
60 lines
1 KiB
Go
60 lines
1 KiB
Go
package cryptutil
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
"crypto/elliptic"
|
|
"crypto/rand"
|
|
"testing"
|
|
)
|
|
|
|
func TestSign(t *testing.T) {
|
|
message := []byte("Hello, world!")
|
|
|
|
key, err := NewSigningKey()
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
signature, err := Sign(message, key)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
if !Verify(message, signature, &key.PublicKey) {
|
|
t.Error("signature was not correct")
|
|
return
|
|
}
|
|
|
|
message[0] ^= 0xff
|
|
if Verify(message, signature, &key.PublicKey) {
|
|
t.Error("signature was good for altered message")
|
|
}
|
|
}
|
|
|
|
func TestSignWithP384(t *testing.T) {
|
|
message := []byte("Hello, world!")
|
|
|
|
key, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
signature, err := Sign(message, key)
|
|
if err != nil {
|
|
t.Error(err)
|
|
return
|
|
}
|
|
|
|
if !Verify(message, signature, &key.PublicKey) {
|
|
t.Error("signature was not correct")
|
|
return
|
|
}
|
|
|
|
message[0] ^= 0xff
|
|
if Verify(message, signature, &key.PublicKey) {
|
|
t.Error("signature was good for altered message")
|
|
}
|
|
}
|