forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docker-restapi]: Fix authentication in restapi (sonic-net#4383)
- enabling http/https endpoint and mounting the certificates directory - updating the sonic-restapi submodule
- Loading branch information
1 parent
59ab6b9
commit ed08975
Showing
8 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
############################################################################### | ||
## Monit configuration for restapi container | ||
## process list: | ||
## restapi | ||
############################################################################### | ||
check process restapi matching "/usr/sbin/go-server-server" | ||
if does not exist for 5 times within 5 cycles then alert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
restapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
RESTAPI_ARGS="" | ||
while true | ||
do | ||
client_auth=`sonic-cfggen -d -v "RESTAPI['config']['client_auth']"` | ||
if [[ $client_auth == 'true' ]]; then | ||
certs=`sonic-cfggen -d -v "RESTAPI['certs']"` | ||
allow_insecure=`sonic-cfggen -d -v "RESTAPI['config']['allow_insecure']"` | ||
if [[ $allow_insecure == 'true' ]]; then | ||
RESTAPI_ARGS=" -enablehttp=true" | ||
else | ||
RESTAPI_ARGS=" -enablehttp=false" | ||
fi | ||
if [[ -n "$certs" ]]; then | ||
SERVER_CRT=`sonic-cfggen -d -v "RESTAPI['certs']['server_crt']"` | ||
SERVER_KEY=`sonic-cfggen -d -v "RESTAPI['certs']['server_key']"` | ||
CLIENT_CA_CRT=`sonic-cfggen -d -v "RESTAPI['certs']['client_ca_crt']"` | ||
CLIENT_CRT_CNAME=`sonic-cfggen -d -v "RESTAPI['certs']['client_crt_cname']"` | ||
if [[ -f $SERVER_CRT && -f $SERVER_KEY && -f $CLIENT_CA_CRT ]]; then | ||
RESTAPI_ARGS+=" -enablehttps=true -servercert=$SERVER_CRT -serverkey=$SERVER_KEY -clientcert=$CLIENT_CA_CRT -clientcertcommonname=$CLIENT_CRT_CNAME" | ||
break | ||
fi | ||
fi | ||
fi | ||
logger "Waiting for certificates..." | ||
sleep 60 | ||
done | ||
|
||
LOG_LEVEL=`sonic-cfggen -d -v "RESTAPI['config']['log_level']"` | ||
if [ ! -z $LOG_LEVEL ]; then | ||
RESTAPI_ARGS+=" -loglevel=$LOG_LEVEL" | ||
else | ||
RESTAPI_ARGS+=" -loglevel=trace" | ||
fi | ||
|
||
logger "RESTAPI_ARGS: $RESTAPI_ARGS" | ||
exec /usr/sbin/go-server-server ${RESTAPI_ARGS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule sonic-restapi
updated
from 163ee2 to c219e3