Skip to content
Snippets Groups Projects

Add basic application framework and example application to show interaction between events an NBI

Merged Ghost User requested to merge istaester/init-application-framework into develop
1 file
+ 3
3
Compare changes
  • Side-by-side
  • Inline
+ 3
3
@@ -106,7 +106,7 @@ func startGrpc() error {
log.Infof("listening to %v", lislisten.Addr())
jwtManager := rbacImpl.NewJWTManager(config.JWTSecret, config.JWTDuration)
setupGRPCServerWithCorrectSecurityLevel(jwtManager)
setupGRPCServerWithCorrectSecurityLevel(jwtManager, c.userService, c.roleService)
c.nbi = nbi.NewNBI(c.pndStore, c.userService, c.roleService, *jwtManager)
@@ -286,13 +286,13 @@ func callback(id uuid.UUID, ch chan device.Details) {
// This allows users to operate on the controller without any authentication/authorization,
// but they could still login if they want to.
// Use insecure only for testing purposes and with caution.
func setupGRPCServerWithCorrectSecurityLevel(jwt *rbacImpl.JWTManager) {
func setupGRPCServerWithCorrectSecurityLevel(jwt *rbacImpl.JWTManager, userService rbac.UserService, roleService rbac.RoleService) {
securityLevel := viper.GetString("security")
if securityLevel == "insecure" {
c.grpcServer = grpc.NewServer()
log.Info("set up grpc server in insecure mode")
} else {
interceptor := server.NewAuthInterceptor(jwt)
interceptor := server.NewAuthInterceptor(jwt, userService, roleService)
c.grpcServer = grpc.NewServer(grpc.UnaryInterceptor(interceptor.Unary()), grpc.StreamInterceptor(interceptor.Stream()))
log.Info("set up grpc server in secure mode")
}
Loading