Skip to content

Commit

Permalink
Merge pull request #324 from helxplatform/develop
Browse files Browse the repository at this point in the history
Develop Merge
  • Loading branch information
waTeim authored Oct 27, 2023
2 parents 6612c0d + 11a59c1 commit 57611a8
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 69 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9.17-slim-bullseye
FROM python:3.9.18-slim-bullseye

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ COMMIT_HASH := $(shell git rev-parse --short HEAD)
SHELL := /bin/bash

# If env defines a registry, use it, else use the default
DEFAULT_REGISTRY := docker.io
DEFAULT_REGISTRY := containers.renci.org
ifdef DOCKER_REGISTRY
ifeq "$(origin DOCKER_REGISTRY)" "environment"
DOCKER_REGISTRY := ${DOCKER_REGISTRY}
Expand Down Expand Up @@ -143,7 +143,7 @@ start: build.postgresql.local
#build: Build the Docker image
build:
if [ -z "$(VER)" ]; then echo "Please provide a value for the VER variable like this:"; echo "make VER=4 build"; false; fi;
docker build --no-cache --pull -t ${DOCKER_IMAGE} -f Dockerfile .
docker build --no-cache --platform=linux/amd64 --pull -t ${DOCKER_IMAGE} -f Dockerfile .
docker tag ${DOCKER_IMAGE} ${DOCKER_REGISTRY}/${DOCKER_IMAGE}
docker tag ${DOCKER_IMAGE} ${DOCKER_REGISTRY}/${DOCKER_IMAGE}-${COMMIT_HASH}

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ make install
#### With Tycho cloned locally

> NOTE: To work with Tycho and appstore locally comment
> `tycho-api` in requirements.txt and setup.cfg.
> `tycho-api` in requirements.txt.
Clone Tycho repo locally outside the appstore project.

Expand Down Expand Up @@ -448,8 +448,7 @@ python setup.py publish

#### Updating Appstore

1. Go to appstore code base and update tycho version in following files `requirements.txt`
and `setup.cfg` created in the publishing step
1. Go to appstore code base and update tycho version in following files `requirements.txt` created in the publishing step

2. Build and publish appstore

Expand Down
7 changes: 7 additions & 0 deletions appstore/appstore/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import os
import logging
import json
from pathlib import Path

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -44,6 +45,9 @@
DEV_PHASE = os.environ.get("DEV_PHASE", "local")
TYCHO_MODE = os.environ.get("TYCHO_MODE", "null" if DEV_PHASE == "stub" else "live")

# Needs to be JSON-encoded since expressions can contain basically any character that would be used as a delimiter.
AUTO_WHITELIST_PATTERNS = json.loads(os.environ.get("AUTO_WHITELIST_PATTERNS", "[]"))

# Variables used for an external Tycho app registry.
# ToDo: Consider setting the default value of TYCHO_APP_REGISTRY_REPO to
# "https://github.com/helxplatform/helx-apps/raw" and remove any other similar
Expand Down Expand Up @@ -88,6 +92,9 @@
"drf_spectacular",
]

## Setting to allow for a seamless login that was breaking at django-allauth 0.47.
SOCIALACCOUNT_LOGIN_ON_GET=True

LOCAL_APPS = [
"api",
"core",
Expand Down
13 changes: 13 additions & 0 deletions appstore/middleware/filter_whitelist_middleware.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import re

from django.conf import settings
from django.contrib.auth.models import Group
Expand Down Expand Up @@ -60,12 +61,24 @@ def is_whitelisted(user):
if user.groups.filter(name="whitelisted").exists():
return True
return False

@staticmethod
def is_auto_whitelisted_email(user):
email = user.email
for pattern in settings.AUTO_WHITELIST_PATTERNS:
if re.match(pattern, email) is not None:
return True
return False

@staticmethod
def is_authorized(user):
if AuthorizedUser.objects.filter(email=user.email).exists():
logger.debug(f"found user email {user.email} in AuthorizedUser")
return True
if AllowWhiteListedUserOnly.is_auto_whitelisted_email(user):
# authorize the user automatically, and allow them through.
AuthorizedUser.objects.create(email=user.email)
return True
logger.debug(f"user email {user.email} not found in AuthorizedUser")
return False

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ python3-openid==3.1.0
requests==2.31.0
requests-oauthlib
selenium==3.141.0
tycho-api>=1.17.2
tycho-api>=1.17
webdriver-manager==3.2.1
sqlparse==0.4.2
asgiref==3.4.1
psycopg2-binary
python-irodsclient==1.1.5
python-irodsclient==1.1.5
61 changes: 0 additions & 61 deletions setup.cfg

This file was deleted.

0 comments on commit 57611a8

Please sign in to comment.