mirror of
https://github.com/openziti/zrok.git
synced 2025-08-17 11:21:07 +02:00
authentication; enable only (for now) (#11)
This commit is contained in:
@ -4,11 +4,27 @@ import (
|
||||
"crypto/rand"
|
||||
"crypto/x509"
|
||||
"encoding/hex"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti/edge/rest_management_api_client"
|
||||
"github.com/openziti/edge/rest_util"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func ZrokAuthenticate(token string) (*rest_model_zrok.Principal, error) {
|
||||
logrus.Infof("authenticating")
|
||||
tx, err := Str.Begin()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if a, err := Str.FindAccountWithToken(token, tx); err == nil {
|
||||
principal := rest_model_zrok.Principal(a.Token)
|
||||
return &principal, nil
|
||||
} else {
|
||||
return nil, errors.Wrap(err, "error authenticating")
|
||||
}
|
||||
}
|
||||
|
||||
func edgeClient() (*rest_management_api_client.ZitiEdgeManagement, error) {
|
||||
ctrlAddress := "https://linux:1280"
|
||||
caCerts, err := rest_util.GetControllerWellKnownCas(ctrlAddress)
|
||||
|
Reference in New Issue
Block a user