Skip to content

Commit

Permalink
Address merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaSBrown committed Nov 26, 2023
2 parents ef6a21d + e8fcdcf commit b5ceab3
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 11 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ config/datafed-ws.cfg
core/database/foxx/api/version_router.js
core/database/foxx/manifest.json
core/server/Version.hpp
docs/.buildinfo
docs/.doctrees/
docs/.nojekyll
python/datafed_pkg/datafed/VERSION.py
python/datafed_pkg/datafed.egg-info/
python/datafed_pkg/datafed/SDMS_Anon_pb2.py
python/datafed_pkg/datafed/SDMS_Auth_pb2.py
python/datafed_pkg/datafed/SDMS_pb2.py
python/datafed_pkg/datafed/Version_pb2.py
python/datafed_pkg/datafed/__pycache__/
python/datafed_pkg/dist/
web/package.json
repository/gridftp/globus5/authz/source/Version.hpp
repository/server/Version.hpp
scripts/globus/datafed-home-repo.sh
Expand Down
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

## MAJOR Breaking changes

## MINOR Feature
1. [909] - Added Support for Google Analytics

## PATCH Bug fixes/Technical Debt/Documentation
1. [914] - Improve GitHub template
2. [910] - Static code analysis and status checks fixed, improvements to CI
1. [915] - Refactor CI to use pipelines Gitlab feature along with pipelines
script
3. [923] - Fixed missing flag in certificate refresh script
4. [917] - Add additional files to .gitignore
5. [915] - Refactor CI to use pipelines Gitlab feature along with pipelines

# v2023.10.23.15.50

Expand Down
4 changes: 2 additions & 2 deletions scripts/generate_certificate_refresh_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SOURCE=$(dirname "$SCRIPT")
PROJECT_ROOT=$(realpath "${SOURCE}/..")
source "${PROJECT_ROOT}/config/datafed.sh"

VERSION="1.0.0"
VERSION="1.0.1"
echo "$FILE_NAME $VERSION"

ERROR_DETECTED=0
Expand Down Expand Up @@ -54,7 +54,7 @@ cat << OUTER_EOF > "$PROJECT_ROOT/scripts/admin_refresh_certs.sh"
# and root root
DOMAIN="${DATAFED_DOMAIN}"
systemctl stop datafed-ws.service
lego --email="${DATAFED_LEGO_EMAIL}" --domains="${DATAFED_DOMAIN}" --tls run
lego --accept-tos --email="${DATAFED_LEGO_EMAIL}" --domains="${DATAFED_DOMAIN}" --tls run
DIR_NAME=\$(date +%m-%Y)
mkdir -p "\${DIR_NAME}"
# Create a copy so we can always go back and check when the last time was
Expand Down
11 changes: 11 additions & 0 deletions scripts/generate_datafed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ else
local_DATAFED_CORE_ADDRESS_PORT_INTERNAL=$(printenv DATAFED_CORE_ADDRESS_PORT_INTERNAL)
fi

if [ -z "${DATAFED_GOOGLE_ANALYTICS_TAG}" ]
then
local_DATAFED_GOOGLE_ANALYTICS_TAG=""
else
local_DATAFED_GOOGLE_ANALYTICS_TAG=$(printenv DATAFED_GOOGLE_ANALYTICS_TAG)
fi

if [ ! -d "$PATH_TO_CONFIG_DIR" ]
then
mkdir -p "$PATH_TO_CONFIG_DIR"
Expand Down Expand Up @@ -212,6 +219,10 @@ export DATAFED_WEB_CERT_PATH="$local_DATAFED_WEB_CERT_PATH"
export DATAFED_WEB_USER=""
# How the web server communicates with the core server, assumes an internal network
export DATAFED_CORE_ADDRESS_PORT_INTERNAL="$local_DATAFED_CORE_ADDRESS_PORT_INTERNAL"
# The id for the associated Google Analytics tag, if left empty, Google Analytics will be disabled
# You can find your tag id by going to the stream details page and it is the field marked as "Measurement ID"
# It will be in the form of "G-XXXXXXXXXX"
export DATAFED_GOOGLE_ANALYTICS_TAG="$local_DATAFED_GOOGLE_ANALYTICS_TAG"
# ****************************************************************************
# Env Variables for DataFed Core server administrative and operational scripts
Expand Down
21 changes: 19 additions & 2 deletions scripts/generate_ws_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Help()
{
echo "$(basename $0) Will set up a configuration file for the core server"
echo
echo "Syntax: $(basename $0) [-h|s|i|z|y|w|k]"
echo "Syntax: $(basename $0) [-h|s|i|z|y|w|k|t]"
echo "options:"
echo "-h, --help Print this help message."
echo "-s, --globus-secret Globus App secret used by DataFed to authenticate"
Expand All @@ -38,6 +38,7 @@ Help()
echo "-y, --zeromq-system-secret ZeroMQ system secret"
echo "-w, --web-cert-path Path to web server certificate file."
echo "-k, --web-key-path Path to web server key file."
echo "-t, --google-analytics-tag The tag associated with a Google Analytics stream"
}

# Set defaults use environment variables by default
Expand Down Expand Up @@ -97,8 +98,15 @@ else
local_DATAFED_CORE_ADDRESS_PORT_INTERNAL=$(printenv DATAFED_CORE_ADDRESS_PORT_INTERNAL)
fi

if [ -z "${DATAFED_GOOGLE_ANALYTICS_TAG}" ]
then
local_DATAFED_GOOGLE_ANALYTICS_TAG=""
else
local_DATAFED_GOOGLE_ANALYTICS_TAG=$(printenv DATAFED_GOOGLE_ANALYTICS_TAG)
fi


VALID_ARGS=$(getopt -o hs:i:z:y:w:k:c: --long 'help',globus-secret:,globus-id:,zeromq-session-secret:,zeromq-system-secret:,web-cert-path:,web-key-path:,core-address-port: -- "$@")
VALID_ARGS=$(getopt -o hs:i:z:y:w:k:c:t: --long 'help',globus-secret:,globus-id:,zeromq-session-secret:,zeromq-system-secret:,web-cert-path:,web-key-path:,core-address-port:,google-analytics-tag: -- "$@")
if [[ $? -ne 0 ]]; then
exit 1;
fi
Expand Down Expand Up @@ -145,6 +153,11 @@ while [ : ]; do
local_DATAFED_CORE_ADDRESS_PORT_INTERNAL=$2
shift 2
;;
-t | --google-analytics-tag)
echo "Processing 'DataFed Google Analytics tag' option. Input argument is '$2'"
local_DATAFED_GOOGLE_ANALYTICS_TAG=$2
shift 2
;;
--) shift;
break
;;
Expand Down Expand Up @@ -227,6 +240,10 @@ client_secret=${local_DATAFED_GLOBUS_APP_SECRET}
# This is the address to talk with the core server which is listening on
# port 7513, assuming internal network.
server_address=tcp://${local_DATAFED_CORE_ADDRESS_PORT_INTERNAL}
[operations]
# This is the tag associated with a Google Analytics installation that metrics will be sent to.
google_analytics_tag=${local_DATAFED_GOOGLE_ANALYTICS_TAG}
EOF

echo
Expand Down
15 changes: 10 additions & 5 deletions web/datafed-ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ var g_host,
g_ver_api_major,
g_ver_api_minor,
g_ver_api_patch,
g_tls;
g_tls,
g_google_analytics;

const nullfr = Buffer.from([]);

Expand Down Expand Up @@ -294,7 +295,7 @@ app.get('/ui/welcome', (a_req, a_resp) => {
const nonce = crypto.randomBytes(16).toString('base64');
a_resp.locals.nonce = nonce;
a_resp.setHeader('Content-Security-Policy', `script-src 'nonce-${nonce}' auth.globus.org`);
a_resp.render('index',{nonce:a_resp.locals.nonce, theme:theme,version:g_version,test_mode:g_test});
a_resp.render('index',{nonce:a_resp.locals.nonce, theme:theme,version:g_version,test_mode:g_test,...g_google_analytics});
}
});

Expand All @@ -306,7 +307,7 @@ app.get('/ui/main', (a_req, a_resp) => {
const nonce = crypto.randomBytes(16).toString('base64');
a_resp.locals.nonce = nonce;
a_resp.setHeader('Content-Security-Policy', `script-src 'nonce-${nonce}'`);
a_resp.render('main',{nonce:a_resp.locals.nonce,user_uid:a_req.session.uid,theme:theme,version:g_version,test_mode:g_test});
a_resp.render('main',{nonce:a_resp.locals.nonce,user_uid:a_req.session.uid,theme:theme,version:g_version,test_mode:g_test,...g_google_analytics});
}else{
// datafed-user cookie not set, so clear datafed-id before redirect
//a_resp.clearCookie( 'datafed-id' );
Expand All @@ -333,7 +334,7 @@ app.get('/ui/register', (a_req, a_resp) => {
const nonce = crypto.randomBytes(16).toString('base64');
a_resp.locals.nonce = nonce;
a_resp.setHeader('Content-Security-Policy', `script-src 'nonce-${nonce}' auth.globus.org`);
a_resp.render('register', {nonce:a_resp.locals.nonce, uid: a_req.session.uid, uname: clean, theme: theme, version: g_version, test_mode: g_test });
a_resp.render('register', {nonce:a_resp.locals.nonce, uid: a_req.session.uid, uname: clean, theme: theme, version: g_version, test_mode: g_test, ...g_google_analytics });
}
});

Expand Down Expand Up @@ -368,7 +369,7 @@ app.get('/ui/error', (a_req, a_resp) => {
const nonce = crypto.randomBytes(16).toString('base64');
a_resp.locals.nonce = nonce;
a_resp.setHeader('Content-Security-Policy', `script-src 'nonce-${nonce}'`);
a_resp.render('error',{nonce:a_resp.locals.nonce,theme:"light",version:g_version,test_mode:g_test});
a_resp.render('error',{nonce:a_resp.locals.nonce,theme:"light",version:g_version,test_mode:g_test,...g_google_analytics});
});

/* This is the OAuth redirect URL after a user authenticates with Globus
Expand Down Expand Up @@ -1824,6 +1825,10 @@ function loadSettings(){
if ( !g_extern_url ){
g_extern_url = "http"+(g_tls?'s':'')+"://" + g_host + ":" + g_port;
}

if ( config.operations ){
g_google_analytics = { enableGoogleAnalytics: config.operations.google_analytics_tag !== '', googleAnalyticsTag: config.operations.google_analytics_tag };
}
}catch( e ){
logger.error(loadSettings.name, getCurrentLineNumber(), "Could not open/parse configuration file: " + process.argv[2] );
logger.error(loadSettings.name, getCurrentLineNumber(), e.message );
Expand Down
11 changes: 11 additions & 0 deletions web/views/head.ect
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<% if @enableGoogleAnalytics : %>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<%- @googleAnalyticsTag %>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<%- @googleAnalyticsTag %>');
</script>
<% end %>
<link rel="stylesheet" type="text/css" href="/style.css"/>
<link rel="icon" type="image/png" href="/favicon.png">
<script nonce="<%= @nonce %>" src="/js-cookie/js-cookie.js"></script>
Expand Down

0 comments on commit b5ceab3

Please sign in to comment.