use keys from an ignored package

main
Nikita Tokarchuk 2 years ago
parent 927428bd87
commit 1278349259
Signed by: mainnika
GPG Key ID: A595FB7E3E56911C
  1. 15
      keys.example.go
  2. 9
      task1-backend/main.go
  3. 7
      task2-backend/main.go
  4. 7
      task3-backend/main.go

@ -0,0 +1,15 @@
package keys
var (
PublicKey = []byte(`-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqtyaUimtphsWdH6aRxsFMi/TXkff
lpM2JTy7A94ut9Gk2HhOF05hiJuwFQQUN78WNhauZnbU1lLWPKP5lJbZ7Q==
-----END PUBLIC KEY-----`)
PrivateKey = []byte(`-----BEGIN EC PRIVATE KEY-----
MHcCAQEEILLczON2Ou3TVZGzNZfNiP5XZCRALoPGLCoHe3m3jFQhoAoGCCqGSM49
AwEHoUQDQgAEqtyaUimtphsWdH6aRxsFMi/TXkfflpM2JTy7A94ut9Gk2HhOF05h
iJuwFQQUN78WNhauZnbU1lLWPKP5lJbZ7Q==
-----END EC PRIVATE KEY-----`)
Alg = `ES256`
Answer = []byte(`9834876dcfb05cb167a5c24953eba58c4ac89b1adf57f28f2f9d09af107ee8f0`)
)

@ -10,6 +10,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/valyala/fasthttp"
"github.com/mainnika/a-quest/keys"
"github.com/mainnika/a-quest/task1-backend/lib"
. "github.com/mainnika/a-quest/task1-backend/lib/configure"
. "github.com/mainnika/a-quest/task1-backend/lib/env"
@ -63,22 +64,22 @@ func main() {
log.Debugf("version: %s", version)
log.Debugf("cfg: %v", Config)
pubKey, err := jwtgo.ParseECPublicKeyFromPEM(publicKey)
pubKey, err := jwtgo.ParseECPublicKeyFromPEM(keys.PublicKey)
if err != nil {
log.Fatalf("can not parse jwt key: %s", err)
}
privKey, err := jwtgo.ParseECPrivateKeyFromPEM(privateKey)
privKey, err := jwtgo.ParseECPrivateKeyFromPEM(keys.PrivateKey)
if err != nil {
log.Fatalf("can not parse jwt key: %s", err)
}
apiserv := &lib.Api{
Base: Config.HttpAPI.Base,
Alg: alg,
Pub: pubKey,
Priv: privKey,
Answer: answer,
Alg: keys.Alg,
Answer: keys.Answer,
}
httpStart(apiserv)

@ -11,6 +11,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/valyala/fasthttp"
"github.com/mainnika/a-quest/keys"
"github.com/mainnika/a-quest/task2-backend/lib"
. "github.com/mainnika/a-quest/task2-backend/lib/configure"
. "github.com/mainnika/a-quest/task2-backend/lib/env"
@ -70,19 +71,19 @@ func main() {
DB: 0, // use default DB
})
pubKey, err := jwtgo.ParseECPublicKeyFromPEM(publicKey)
pubKey, err := jwtgo.ParseECPublicKeyFromPEM(keys.PublicKey)
if err != nil {
log.Fatalf("can not parse jwt key: %s", err)
}
privKey, err := jwtgo.ParseECPrivateKeyFromPEM(privateKey)
privKey, err := jwtgo.ParseECPrivateKeyFromPEM(keys.PrivateKey)
if err != nil {
log.Fatalf("can not parse jwt key: %s", err)
}
apiserv := &lib.Api{
Base: Config.HttpAPI.Base,
Alg: alg,
Alg: keys.Alg,
Pub: pubKey,
Priv: privKey,
ScoresKey: Config.Redis.ScoreKey,

@ -12,6 +12,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/valyala/fasthttp"
"github.com/mainnika/a-quest/keys"
"github.com/mainnika/a-quest/task3-backend/lib"
. "github.com/mainnika/a-quest/task3-backend/lib/configure"
. "github.com/mainnika/a-quest/task3-backend/lib/env"
@ -92,12 +93,12 @@ func main() {
log.Fatalf("can not init docklient: %s", err)
}
pubKey, err := jwtgo.ParseECPublicKeyFromPEM(publicKey)
pubKey, err := jwtgo.ParseECPublicKeyFromPEM(keys.PublicKey)
if err != nil {
log.Fatalf("can not parse jwt key: %s", err)
}
privKey, err := jwtgo.ParseECPrivateKeyFromPEM(privateKey)
privKey, err := jwtgo.ParseECPrivateKeyFromPEM(keys.PrivateKey)
if err != nil {
log.Fatalf("can not parse jwt key: %s", err)
}
@ -109,7 +110,7 @@ func main() {
}
taskserv := &lib.Server{
Alg: alg,
Alg: keys.Alg,
Pub: pubKey,
Priv: privKey,
Docker: docklient,

Loading…
Cancel
Save