Merge pull request #163 from paralus/update-readme-dev-false

Set dev to false by default
This commit is contained in:
Akshay Gaikwad
2022-06-08 14:59:47 +05:30
committed by GitHub
2 changed files with 20 additions and 26 deletions

View File

@@ -3,7 +3,6 @@ RPC_PORT=10000
API_PORT=11000
DEBUG_PORT=12000
API_ADDR=localhost:11000
DEV=true
# db
DB_ADDR=localhost:5432

45
main.go
View File

@@ -175,7 +175,7 @@ func setup() {
viper.SetDefault(apiPortEnv, 11000)
viper.SetDefault(debugPortEnv, 12000)
viper.SetDefault(apiAddrEnv, "localhost:11000")
viper.SetDefault(devEnv, true)
viper.SetDefault(devEnv, false)
// db
viper.SetDefault(dbAddrEnv, "localhost:5432")
@@ -581,26 +581,24 @@ func runRPC(wg *sync.WaitGroup, ctx context.Context) {
}
var opts []_grpc.ServerOption
var asv authv3.AuthService
if !dev {
_log.Infow("adding auth interceptor")
ac := authv3.NewAuthContext(db, kc, ks, as)
asv = authv3.NewAuthService(ac)
o := authv3.Option{
ExcludeRPCMethods: []string{
"/rafay.dev.sentry.rpc.Bootstrap/GetBootstrapAgentTemplate",
"/rafay.dev.sentry.rpc.Bootstrap/RegisterBootstrapAgent",
"/rafay.dev.sentry.rpc.KubeConfig/GetForClusterWebSession", //TODO: enable auth from prompt
"/rafay.dev.rpc.v3.Auth/IsRequestAllowed",
},
ExcludeAuthzMethods: []string{
"/rafay.dev.rpc.v3.User/GetUserInfo",
},
}
opts = append(opts, _grpc.UnaryInterceptor(
ac.NewAuthUnaryInterceptor(o),
))
// var asv authv3.AuthService
_log.Infow("adding auth interceptor")
ac := authv3.NewAuthContext(db, kc, ks, as)
asv := authv3.NewAuthService(ac)
o := authv3.Option{
ExcludeRPCMethods: []string{
"/rafay.dev.sentry.rpc.Bootstrap/GetBootstrapAgentTemplate",
"/rafay.dev.sentry.rpc.Bootstrap/RegisterBootstrapAgent",
"/rafay.dev.sentry.rpc.KubeConfig/GetForClusterWebSession", //TODO: enable auth from prompt
"/rafay.dev.rpc.v3.Auth/IsRequestAllowed",
},
ExcludeAuthzMethods: []string{
"/rafay.dev.rpc.v3.User/GetUserInfo",
},
}
opts = append(opts, _grpc.UnaryInterceptor(
ac.NewAuthUnaryInterceptor(o),
))
s, err := grpc.NewServer(opts...)
if err != nil {
_log.Fatalw("unable to create grpc server", "error", err)
@@ -637,11 +635,8 @@ func runRPC(wg *sync.WaitGroup, ctx context.Context) {
auditrpc.RegisterAuditLogServer(s, auditLogServer)
auditrpc.RegisterRelayAuditServer(s, relayAuditServer)
if !dev {
// if !dev, we should have the asv populated
authServer := server.NewAuthServer(asv)
authrpc.RegisterAuthServer(s, authServer)
}
authServer := server.NewAuthServer(asv)
authrpc.RegisterAuthServer(s, authServer)
_log.Infow("starting rpc server", "port", rpcPort)
err = s.Serve(l)