mirror of
https://github.com/twofas/2fas-server.git
synced 2025-01-05 22:15:56 +01:00
Merge pull request #45 from twofas/feat/connect-firebase-sdk
feat: connect firebase sdk
This commit is contained in:
commit
6a7d36b955
@ -7,6 +7,7 @@ type PassConfig struct {
|
||||
KMSKeyID string `envconfig:"KMS_KEY_ID" default:"alias/pass_service_signing_key"`
|
||||
AWSEndpoint string `envconfig:"AWS_ENDPOINT" default:""`
|
||||
AWSRegion string `envconfig:"AWS_REGION" default:"us-east-2"`
|
||||
FirebaseServiceAccount string `envconfig:"FIREBASE_SA"`
|
||||
FakeMobilePush bool `envconfig:"FAKE_MOBILE_PUSH" default:"false"`
|
||||
PairingRequestTokenValidityDuration time.Duration `envconfig:"PAIRING_REQUEST_TOKEN_VALIDITY_DURATION" default:"8765h"` // 1 year
|
||||
}
|
||||
|
@ -20,6 +20,10 @@
|
||||
}
|
||||
],
|
||||
"secrets": [
|
||||
{
|
||||
"name": "FIREBASE_SA",
|
||||
"valueFrom": "arn:aws:secretsmanager:us-east-2:<AWS_ACCOUNT_ID>:secret:prod/pass-8pVN76:pass_firebase_sa::"
|
||||
}
|
||||
],
|
||||
"logConfiguration": {
|
||||
"logDriver": "awslogs",
|
||||
|
@ -1,12 +1,16 @@
|
||||
package pass
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
firebase "firebase.google.com/go/v4"
|
||||
"firebase.google.com/go/v4/messaging"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/kms"
|
||||
"github.com/gin-gonic/gin"
|
||||
"google.golang.org/api/option"
|
||||
|
||||
"github.com/twofas/2fas-server/config"
|
||||
httphelpers "github.com/twofas/2fas-server/internal/common/http"
|
||||
@ -51,6 +55,22 @@ func NewServer(cfg config.PassConfig) *Server {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
var fcmClient *messaging.Client
|
||||
if cfg.FirebaseServiceAccount != "" {
|
||||
opt := option.WithCredentialsJSON([]byte(cfg.FirebaseServiceAccount))
|
||||
app, err := firebase.NewApp(ctx, nil, opt)
|
||||
if err != nil {
|
||||
log.Fatalf("Error initializing FCM App: %v", err)
|
||||
}
|
||||
fcmClient, err = app.Messaging(ctx)
|
||||
if err != nil {
|
||||
log.Fatalf("Error initializing Messaging Client: %v", err)
|
||||
}
|
||||
}
|
||||
// TODO: use client in later phase.
|
||||
_ = fcmClient
|
||||
|
||||
pairingApp := pairing.NewApp(signSvc, cfg.PairingRequestTokenValidityDuration)
|
||||
proxyPairingApp := connection.NewProxyServer("device_id")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user