Skip to content

weekly-bot: Add hedgedoc email authentication

Guillaume Samson requested to merge weekly_email_auth into production

Related to swh/infra/sysadm-environment#5461

These modifications will update the weekly-bot scripts (planning and management) to use email authentication.
Anonymous access has been removed and these scripts didn't work anymore.
Oauth2 authentication via api is not yet implemented, it will be in Hedgedoc version2, see v2.0.0-alpha.3 Features.
An email user has been created and will be use in weekly-bot scripts.

octocatalog-diff
diff origin/production/pergamon.softwareheritage.org current/pergamon.softwareheritage.org
*******************************************
+ Concat_fragment[profile::cron::weekly-management-bot] =>
   parameters =>
     "content": "# Cron snippet weekly-management-bot\n30 13 * * thu nobody chron...
     "order": "10",
     "tag": "profile::cron::default",
     "target": "profile::cron::default"
*******************************************
+ Concat_fragment[profile::cron::weekly-planning-bot] =>
   parameters =>
     "content": "# Cron snippet weekly-planning-bot\n42 13 * * fri nobody chronic...
     "order": "10",
     "tag": "profile::cron::default",
     "target": "profile::cron::default"
*******************************************
  File[/usr/local/bin/weekly-management-bot] =>
   parameters =>
     content =>
      @@ -3,17 +3,37 @@
       set -e
      _
      -DEST=swh-management@inria.fr
       AUTHOR=swh-management@inria.fr
      +COOKIE_FILE=/tmp/cookie.txt
      +DATE=$(date +%G-W%V -d 'monday 12:00')
      +DEST=swh-management@inria.fr
      +PASSWORD="xxx"
       TEMPLATE_ID="OGAEXlDiShGabI14j_3LeA"
       URL="https://hedgedoc.softwareheritage.org"
      -DATE=$(date +%G-W%V -d 'monday 12:00')
      +USERNAME=swh-sysadmin@inria.fr
      _
       # Retrieve the template's content
      -TEMPLATE=$(curl -s "${URL}/${TEMPLATE_ID}/download")
      -TEMPLATE=$(echo "$TEMPLATE" | sed -e "s/\$DATE/$DATE/g" | sed -e "/^tags:/s/, template//")
      +TEMPLATE=$(curl -s "${URL}/${TEMPLATE_ID}/download" | \
      +  sed -e "s/\$DATE/$DATE/g" -e "/^tags:/s/, template//")
      +
      +# Login
      +curl -X POST -s \
      +  -c "$COOKIE_FILE" \
      +  -d "email=$USERNAME" \
      +  -d "password=$PASSWORD" \
      +  "${URL}/login" > /dev/null
      _
       # Create a new page initialized with the template content
      -RESP=$(curl -s -A POST -H "Content-Type: text/markdown" "${URL}/new" --data-binary "$TEMPLATE")
      -LOCATION=$(echo "$RESP" | awk '{print $4}')
      +LOCATION=$(curl -s -A POST \
      +  -H "Content-Type: text/markdown" \
      +  -b "$COOKIE_FILE" "${URL}/new" \
      +  --data-binary "$TEMPLATE" | \
      +  awk '{print $4}')
      +
      +# Logout
      +curl -s \
      +  -b "$COOKIE_FILE" \
      +  -c "$COOKIE_FILE" \
      +  "${URL}/logout" > /dev/null && \
      +  rm "$COOKIE_FILE"
      _
       if [ -n "$LOCATION" ] ; then
*******************************************
  File[/usr/local/bin/weekly-planning-bot] =>
   parameters =>
     content =>
      @@ -3,17 +3,37 @@
       set -e
      _
      -DEST=swh-team@inria.fr
       AUTHOR=swh-team@inria.fr
      +COOKIE_FILE=/tmp/cookie.txt
      +DATE=$(date +%G-W%V -d 'monday 12:00')
      +DEST=swh-team@inria.fr
      +PASSWORD="hedgedoc-weekly-bot-password"
       TEMPLATE_ID="6YKT5osoST-amJQ0MusH2Q"
       URL="https://hedgedoc.softwareheritage.org"
      -DATE=$(date +%G-W%V -d 'monday 12:00')
      +USERNAME=swh-sysadmin@inria.fr
      _
       # Retrieve the template's content
      -TEMPLATE=$(curl -s "${URL}/${TEMPLATE_ID}/download")
      -TEMPLATE=$(echo "$TEMPLATE" | sed -e "s/\$DATE/$DATE/g" | sed -e "/^tags:/s/, template//")
      +TEMPLATE=$(curl -s "${URL}/${TEMPLATE_ID}/download" | \
      +  sed -e "s/\$DATE/$DATE/g" -e "/^tags:/s/, template//")
      +
      +# Login
      +curl -X POST -s \
      +  -c "$COOKIE_FILE" \
      +  -d "email=$USERNAME" \
      +  -d "password=$PASSWORD" \
      +  "${URL}/login" > /dev/null
      _
       # Create a new page initialized with the template content
      -RESP=$(curl -s -A POST -H "Content-Type: text/markdown" "${URL}/new" --data-binary "$TEMPLATE")
      -LOCATION=$(echo "$RESP" | awk '{print $4}')
      +LOCATION=$(curl -s -A POST \
      +  -H "Content-Type: text/markdown" \
      +  -b "$COOKIE_FILE" "${URL}/new" \
      +  --data-binary "$TEMPLATE" | \
      +  awk '{print $4}')
      +
      +# Logout
      +curl -s \
      +  -b "$COOKIE_FILE" \
      +  -c "$COOKIE_FILE" \
      +  "${URL}/logout" > /dev/null && \
      +  rm "$COOKIE_FILE"
      _
       if [ -n "$LOCATION" ] ; then
*******************************************
+ Profile::Cron::D[weekly-management-bot] =>
   parameters =>
     "command": "chronic /usr/local/bin/weekly-management-bot",
     "hour": 13,
     "minute": 30,
     "target": "default",
     "unique_tag": "weekly-management-bot",
     "user": "nobody",
     "weekday": "thu"
*******************************************
+ Profile::Cron::D[weekly-planning-bot] =>
   parameters =>
     "command": "chronic /usr/local/bin/weekly-planning-bot",
     "hour": 13,
     "minute": 42,
     "target": "default",
     "unique_tag": "weekly-planning-bot",
     "user": "nobody",
     "weekday": "fri"
*******************************************
*** End octocatalog-diff on pergamon.softwareheritage.org

Merge request reports

Loading