-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MF-1096 - Fix AuthN and Things Auth ENVARS #1066
Changes from 20 commits
3568a39
a99e8c9
9d18638
ada6233
a6b1c9a
499584f
0240e34
cbfc90f
2d4a4bc
92e797a
be46439
3a0b8ba
71b615f
9934f3e
4f2a2df
8919983
e7805f6
67a7b8a
5668410
5711b67
9bf02bb
5a48763
0cebd75
28fcbfc
88c02bb
e5d5c94
4ebc121
4476432
134f56b
e9d2c64
baf680c
fe819c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,8 @@ MF_JAEGER_URL=jaeger:6831 | |
MF_AUTHN_LOG_LEVEL=debug | ||
MF_AUTHN_HTTP_PORT=8189 | ||
MF_AUTHN_GRPC_PORT=8181 | ||
MF_AUTHN_GRPC_URL=authn:8181 | ||
MF_AUTHN_GRPC_TIMEOUT=1 | ||
MF_AUTHN_DB_PORT=5432 | ||
MF_AUTHN_DB_USER=mainflux | ||
MF_AUTHN_DB_PASS=mainflux | ||
|
@@ -60,6 +62,8 @@ MF_THINGS_LOG_LEVEL=debug | |
MF_THINGS_HTTP_PORT=8182 | ||
MF_THINGS_AUTH_HTTP_PORT=8989 | ||
MF_THINGS_AUTH_GRPC_PORT=8183 | ||
MF_THINGS_AUTH_GRPC_URL=things:8183 | ||
MF_THINGS_AUTH_GRPC_TIMEOUT=1 | ||
MF_THINGS_DB_PORT=5432 | ||
MF_THINGS_DB_USER=mainflux | ||
MF_THINGS_DB_PASS=mainflux | ||
|
@@ -141,18 +145,18 @@ MF_INFLUX_WRITER_PORT=8900 | |
MF_INFLUX_WRITER_BATCH_SIZE=5000 | ||
MF_INFLUX_WRITER_BATCH_TIMEOUT=5 | ||
MF_INFLUX_WRITER_DB_PORT=8086 | ||
MF_INFLUX_WRITER_DB_NAME=mainflux | ||
MF_INFLUX_WRITER_DB_USER=mainflux | ||
MF_INFLUX_WRITER_DB_PASS=mainflux | ||
MF_INFLUX_WRITER_DB_NAME=mainflux | ||
MF_INFLUX_WRITER_GRAFANA_PORT=3001 | ||
|
||
### InfluxDB Reader | ||
MF_INFLUX_READER_LOG_LEVEL=debug | ||
MF_INFLUX_READER_PORT=8905 | ||
MF_INFLUX_READER_DB_NAME=mainflux | ||
MF_INFLUX_READER_DB_PORT=8086 | ||
MF_INFLUX_READER_DB_USER=mainflux | ||
MF_INFLUX_READER_DB_PASS=mainflux | ||
MF_INFLUX_READER_DB_NAME=mainflux | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
MF_INFLUX_READER_SERVER_CERT= | ||
MF_INFLUX_READER_SERVER_KEY= | ||
|
||
|
@@ -201,7 +205,7 @@ MF_TWINS_LOG_LEVEL=debug | |
MF_TWINS_HTTP_PORT=9021 | ||
MF_TWINS_SERVER_CERT="" | ||
MF_TWINS_SERVER_KEY="" | ||
MF_TWINS_DB_NAME=mainflux-twins | ||
MF_TWINS_DB=mainflux-twins | ||
MF_TWINS_DB_HOST=twins-db | ||
MF_TWINS_DB_PORT=27018 | ||
MF_TWINS_SINGLE_USER_EMAIL="" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,48 +34,48 @@ import ( | |
const ( | ||
sep = "," | ||
|
||
defLogLevel = "error" | ||
defPort = "8180" | ||
defCluster = "127.0.0.1" | ||
defKeyspace = "mainflux" | ||
defDBUsername = "" | ||
defDBPassword = "" | ||
defDBPort = "9042" | ||
defThingsURL = "localhost:8181" | ||
defClientTLS = "false" | ||
defCACerts = "" | ||
defServerCert = "" | ||
defServerKey = "" | ||
defJaegerURL = "" | ||
defThingsTimeout = "1" // in seconds | ||
|
||
envLogLevel = "MF_CASSANDRA_READER_LOG_LEVEL" | ||
envPort = "MF_CASSANDRA_READER_PORT" | ||
envCluster = "MF_CASSANDRA_READER_DB_CLUSTER" | ||
envKeyspace = "MF_CASSANDRA_READER_DB_KEYSPACE" | ||
envDBUsername = "MF_CASSANDRA_READER_DB_USERNAME" | ||
envDBPassword = "MF_CASSANDRA_READER_DB_PASSWORD" | ||
envDBPort = "MF_CASSANDRA_READER_DB_PORT" | ||
envThingsURL = "MF_THINGS_URL" | ||
envClientTLS = "MF_CASSANDRA_READER_CLIENT_TLS" | ||
envCACerts = "MF_CASSANDRA_READER_CA_CERTS" | ||
envServerCert = "MF_CASSANDRA_READER_SERVER_CERT" | ||
envServerKey = "MF_CASSANDRA_READER_SERVER_KEY" | ||
envJaegerURL = "MF_JAEGER_URL" | ||
envThingsTimeout = "MF_CASSANDRA_READER_THINGS_TIMEOUT" | ||
defLogLevel = "error" | ||
defPort = "8180" | ||
defCluster = "127.0.0.1" | ||
defKeyspace = "messages" | ||
defDBUser = "mainflux" | ||
defDBPass = "mainflux" | ||
defDBPort = "9042" | ||
defClientTLS = "false" | ||
defCACerts = "" | ||
defServerCert = "" | ||
defServerKey = "" | ||
defJaegerURL = "" | ||
defThingsAuthURL = "localhost:8181" | ||
defThingsAuthTimeout = "1" // in seconds | ||
|
||
envLogLevel = "MF_CASSANDRA_READER_LOG_LEVEL" | ||
envPort = "MF_CASSANDRA_READER_PORT" | ||
envCluster = "MF_CASSANDRA_READER_DB_CLUSTER" | ||
envKeyspace = "MF_CASSANDRA_READER_DB_KEYSPACE" | ||
envDBUser = "MF_CASSANDRA_READER_DB_USERNAME" | ||
manuio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
envDBPass = "MF_CASSANDRA_READER_DB_PASSWORD" | ||
envDBPort = "MF_CASSANDRA_READER_DB_PORT" | ||
envClientTLS = "MF_CASSANDRA_READER_CLIENT_TLS" | ||
envCACerts = "MF_CASSANDRA_READER_CA_CERTS" | ||
envServerCert = "MF_CASSANDRA_READER_SERVER_CERT" | ||
envServerKey = "MF_CASSANDRA_READER_SERVER_KEY" | ||
envJaegerURL = "MF_JAEGER_URL" | ||
envThingsAuthURL = "MF_THINGS_AUTH_GRPC_URL" | ||
envThingsAuthTimeout = "MF_THINGS_AUTH_GRPC_TIMEOUT" | ||
) | ||
|
||
type config struct { | ||
logLevel string | ||
port string | ||
dbCfg cassandra.DBConfig | ||
thingsURL string | ||
clientTLS bool | ||
caCerts string | ||
serverCert string | ||
serverKey string | ||
jaegerURL string | ||
thingsTimeout time.Duration | ||
logLevel string | ||
port string | ||
dbCfg cassandra.DBConfig | ||
clientTLS bool | ||
caCerts string | ||
serverCert string | ||
serverKey string | ||
jaegerURL string | ||
thingsAuthURL string | ||
thingsAuthTimeout time.Duration | ||
} | ||
|
||
func main() { | ||
|
@@ -95,7 +95,7 @@ func main() { | |
thingsTracer, thingsCloser := initJaeger("things", cfg.jaegerURL, logger) | ||
defer thingsCloser.Close() | ||
|
||
tc := thingsapi.NewClient(conn, thingsTracer, cfg.thingsTimeout) | ||
tc := thingsapi.NewClient(conn, thingsTracer, cfg.thingsAuthTimeout) | ||
repo := newService(session, logger) | ||
|
||
errs := make(chan error, 2) | ||
|
@@ -121,8 +121,8 @@ func loadConfig() config { | |
dbCfg := cassandra.DBConfig{ | ||
Hosts: strings.Split(mainflux.Env(envCluster, defCluster), sep), | ||
Keyspace: mainflux.Env(envKeyspace, defKeyspace), | ||
Username: mainflux.Env(envDBUsername, defDBUsername), | ||
Password: mainflux.Env(envDBPassword, defDBPassword), | ||
Username: mainflux.Env(envDBUser, defDBUser), | ||
Password: mainflux.Env(envDBPass, defDBPass), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't because it comes from here: "github.com/influxdata/influxdb/client/v2" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is Cassandra config from |
||
Port: dbPort, | ||
} | ||
|
||
|
@@ -131,22 +131,22 @@ func loadConfig() config { | |
log.Fatalf("Invalid value passed for %s\n", envClientTLS) | ||
} | ||
|
||
timeout, err := strconv.ParseInt(mainflux.Env(envThingsTimeout, defThingsTimeout), 10, 64) | ||
timeout, err := strconv.ParseInt(mainflux.Env(envThingsAuthTimeout, defThingsAuthTimeout), 10, 64) | ||
if err != nil { | ||
log.Fatalf("Invalid %s value: %s", envThingsTimeout, err.Error()) | ||
log.Fatalf("Invalid %s value: %s", envThingsAuthTimeout, err.Error()) | ||
} | ||
|
||
return config{ | ||
logLevel: mainflux.Env(envLogLevel, defLogLevel), | ||
port: mainflux.Env(envPort, defPort), | ||
dbCfg: dbCfg, | ||
thingsURL: mainflux.Env(envThingsURL, defThingsURL), | ||
clientTLS: tls, | ||
caCerts: mainflux.Env(envCACerts, defCACerts), | ||
serverCert: mainflux.Env(envServerCert, defServerCert), | ||
serverKey: mainflux.Env(envServerKey, defServerKey), | ||
jaegerURL: mainflux.Env(envJaegerURL, defJaegerURL), | ||
thingsTimeout: time.Duration(timeout) * time.Second, | ||
logLevel: mainflux.Env(envLogLevel, defLogLevel), | ||
port: mainflux.Env(envPort, defPort), | ||
dbCfg: dbCfg, | ||
clientTLS: tls, | ||
caCerts: mainflux.Env(envCACerts, defCACerts), | ||
serverCert: mainflux.Env(envServerCert, defServerCert), | ||
serverKey: mainflux.Env(envServerKey, defServerKey), | ||
jaegerURL: mainflux.Env(envJaegerURL, defJaegerURL), | ||
thingsAuthURL: mainflux.Env(envThingsAuthURL, defThingsAuthURL), | ||
thingsAuthTimeout: time.Duration(timeout) * time.Second, | ||
} | ||
} | ||
|
||
|
@@ -176,7 +176,7 @@ func connectToThings(cfg config, logger logger.Logger) *grpc.ClientConn { | |
opts = append(opts, grpc.WithInsecure()) | ||
} | ||
|
||
conn, err := grpc.Dial(cfg.thingsURL, opts...) | ||
conn, err := grpc.Dial(cfg.thingsAuthURL, opts...) | ||
if err != nil { | ||
logger.Error(fmt.Sprintf("Failed to connect to things service: %s", err)) | ||
os.Exit(1) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
DB
?