Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package cmd
import (
"context"
"fmt"
"net"
"os"
"os/signal"
"strconv"
"strings"
"time"

Expand All @@ -25,6 +27,7 @@ import (
"github.com/authorizerdev/authorizer/internal/memory_store"
"github.com/authorizerdev/authorizer/internal/metrics"
"github.com/authorizerdev/authorizer/internal/oauth"
"github.com/authorizerdev/authorizer/internal/grpcsrv"
"github.com/authorizerdev/authorizer/internal/rate_limit"
"github.com/authorizerdev/authorizer/internal/server"
"github.com/authorizerdev/authorizer/internal/service"
Expand Down Expand Up @@ -103,6 +106,13 @@ func init() {
f.IntVar(&rootArgs.config.GraphQLMaxAliases, "graphql-max-aliases", 30, "Maximum total number of aliased fields per GraphQL operation")
f.Int64Var(&rootArgs.config.GraphQLMaxBodyBytes, "graphql-max-body-bytes", 1<<20, "Maximum allowed GraphQL request body size in bytes (default 1MB)")

// gRPC server flags
f.IntVar(&rootArgs.config.GRPCPort, "grpc-port", 8081, "Port the gRPC server listens on")
f.BoolVar(&rootArgs.config.EnableGRPCReflection, "enable-grpc-reflection", true, "Enable the gRPC server-reflection service")
f.StringVar(&rootArgs.config.GRPCTLSCert, "grpc-tls-cert", "", "Path to the TLS certificate for the gRPC server")
f.StringVar(&rootArgs.config.GRPCTLSKey, "grpc-tls-key", "", "Path to the TLS private key for the gRPC server")
f.BoolVar(&rootArgs.config.GRPCInsecure, "grpc-insecure", false, "Allow the gRPC server to run without TLS (dev only)")

// Organization flags
f.StringVar(&rootArgs.config.OrganizationLogo, "organization-logo", defaultOrganizationLogo, "Logo of the organization")
f.StringVar(&rootArgs.config.OrganizationName, "organization-name", defaultOrganizationName, "Name of the organization")
Expand Down Expand Up @@ -566,11 +576,27 @@ func runRoot(c *cobra.Command, args []string) {
if err != nil {
log.Fatal().Err(err).Msg("failed to create http provider")
}

// gRPC server — listens on --grpc-port. The REST gateway built by
// server.Run wraps this same gRPC server in-process so /v1/* REST
// calls translate to local gRPC method invocations (no network hop).
grpcAddr := net.JoinHostPort(rootArgs.server.Host, strconv.Itoa(rootArgs.config.GRPCPort))
grpcSrv, err := grpcsrv.New(grpcAddr, &grpcsrv.Dependencies{
Log: &log,
Config: &rootArgs.config,
ServiceProvider: serviceProvider,
})
if err != nil {
log.Fatal().Err(err).Msg("failed to create grpc server")
}
rootArgs.server.GRPCPort = rootArgs.config.GRPCPort

// Prepare server
deps := &server.Dependencies{
Log: &log,
AppConfig: &rootArgs.config,
HTTPProvider: httpProvider,
GRPCServer: grpcSrv,
}
// Create the server
svr, err := server.New(&rootArgs.server, deps)
Expand Down
262 changes: 262 additions & 0 deletions gen/go/authorizer/authz/v1/authz_service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading