basic sessions (#337)

This commit is contained in:
Jim authored and GitHub committed 2020-09-16 12:02:02 -04:00
1 parent 0a44ed3edd
commit 611288bdc7
35 files changed
+5934 -111

No files matched your search

+4 -23
View File
@@ -2,13 +2,9 @@ package controller
import (
"context"
"crypto/rand"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
"math/big"
mathrand "math/rand"
"net/http"
"os"
"strings"
@@ -28,7 +24,7 @@ import (
"github.com/hashicorp/boundary/internal/servers/controller/handlers/authmethods"
"github.com/hashicorp/boundary/internal/servers/controller/handlers/host_sets"
"github.com/hashicorp/boundary/internal/servers/controller/handlers/targets"
"github.com/hashicorp/boundary/internal/sessions"
"github.com/hashicorp/boundary/internal/session"
"github.com/hashicorp/boundary/internal/types/scope"
"github.com/hashicorp/boundary/sdk/strutil"
"github.com/hashicorp/shared-secure-libs/configutil"
@@ -369,24 +365,9 @@ func jobTestingHandler(c *Controller) http.Handler {
errorResp(err)
return
}
jobId = "s_" + jobId
pubKey, privKey, err := sessions.DeriveED25519Key(wrapper, "u_1234567890", jobId)
template := &x509.Certificate{
ExtKeyUsage: []x509.ExtKeyUsage{
x509.ExtKeyUsageServerAuth,
x509.ExtKeyUsageClientAuth,
},
DNSNames: []string{jobId},
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment | x509.KeyUsageKeyAgreement | x509.KeyUsageCertSign,
SerialNumber: big.NewInt(mathrand.Int63()),
NotBefore: time.Now().Add(-1 * time.Minute),
NotAfter: time.Now().Add(5 * time.Minute),
BasicConstraintsValid: true,
IsCA: true,
}
certBytes, err := x509.CreateCertificate(rand.Reader, template, template, pubKey, privKey)
// TODO (jimlambrt 8/2020): this is quite correct. We need to create a
// new session here (in the session repo) which would have a cert.
privKey, certBytes, err := session.TestCert(wrapper, "u_1234567890", jobId)
if err != nil {
errorResp(err)
return