Skip to content

Commit

Permalink
More granularity to grafana authentication and anonymous login
Browse files Browse the repository at this point in the history
  • Loading branch information
amnonh committed Feb 27, 2023
1 parent 8bfc1a8 commit 6eea123
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
6 changes: 6 additions & 0 deletions start-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ for arg; do
;;
(--victoria-metrics) VICTORIA_METRICS="1"
;;
(--auth)
GRAFANA_ENV_COMMAND="$GRAFANA_ENV_COMMAND --auth"
;;
(--disable-anonymous)
GRAFANA_ENV_COMMAND="$GRAFANA_ENV_COMMAND --disable-anonymous"
;;
(--limit)
LIMIT="1"
;;
Expand Down
25 changes: 18 additions & 7 deletions start-grafana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ if [ -f CURRENT_VERSION.sh ]; then
CURRENT_VERSION=`cat CURRENT_VERSION.sh`
fi
LOCAL=""
GRAFANA_ADMIN_PASSWORD="admin"
GRAFANA_AUTH=false
GRAFANA_AUTH_ANONYMOUS=true
if [ -z "$GRAFANA_ADMIN_PASSWORD" ]; then
GRAFANA_ADMIN_PASSWORD="admin"
fi
if [ -z "$GRAFANA_AUTH" ]; then
GRAFANA_AUTH=false
fi
if [ -z "$GRAFANA_AUTH_ANONYMOUS" ]; then
GRAFANA_AUTH_ANONYMOUS=true
fi
DOCKER_PARAM=""
EXTERNAL_VOLUME=""
BIND_ADDRESS=""
ANONYMOUS_ROLE="Admin"
if [ -z "$ANONYMOUS_ROLE" ]; then
ANONYMOUS_ROLE="Admin"
fi
SPECIFIC_SOLUTION=""
LDAP_FILE=""

Expand Down Expand Up @@ -49,6 +57,12 @@ for arg; do
LIMIT="1"
PARAM="1"
;;
(--auth)
GRAFANA_AUTH=true
;;
(--disable-anonymous)
GRAFANA_AUTH_ANONYMOUS=false
;;
(*) set -- "$@" "$arg"
;;
esac
Expand Down Expand Up @@ -122,8 +136,6 @@ while getopts ':hlEg:n:p:v:a:x:c:j:m:G:M:D:A:S:P:L:Q:' option; do
Q) ANONYMOUS_ROLE=$OPTARG
;;
a) GRAFANA_ADMIN_PASSWORD=$OPTARG
GRAFANA_AUTH=true
GRAFANA_AUTH_ANONYMOUS=false
;;
x) HTTP_PROXY="$OPTARG"
;;
Expand Down Expand Up @@ -228,7 +240,6 @@ if [ ! -z $RUN_RENDERER ]; then
GRAFANA_ENV_COMMAND="$GRAFANA_ENV_COMMAND -e GF_RENDERING_SERVER_URL=http://$DOCKER_HOST:8081/render -e GF_RENDERING_CALLBACK_URL=http://$DOCKER_HOST:$GRAFANA_PORT/"
fi


docker run -d $DOCKER_PARAM ${DOCKER_LIMITS["grafana"]} -i $USER_PERMISSIONS $PORT_MAPPING \
-e "GF_AUTH_BASIC_ENABLED=$GRAFANA_AUTH" \
-e "GF_AUTH_ANONYMOUS_ENABLED=$GRAFANA_AUTH_ANONYMOUS" \
Expand Down

0 comments on commit 6eea123

Please sign in to comment.