Skip to content

Commit

Permalink
Merge pull request #783 from rwblair/use_drf_tokens
Browse files Browse the repository at this point in the history
Use DRF built in token auth, add views to create and regen this token
  • Loading branch information
rwblair committed Apr 28, 2023
2 parents f76e06b + ac906e3 commit 7c85cab
Show file tree
Hide file tree
Showing 30 changed files with 291 additions and 802 deletions.
50 changes: 49 additions & 1 deletion compose/django/Dockerfile
@@ -1,4 +1,4 @@
FROM python:3.10-slim
FROM python:3.10-slim AS neurovault

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
Expand All @@ -10,6 +10,54 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
libpq-dev \
git

RUN apt-get -y update \
&& apt-get install -y wget subversion && \
wget -qO- ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.0/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz | tar zxv -C /opt \
--exclude='freesurfer/trctrain' \
--exclude='freesurfer/subjects/fsaverage_sym' \
--exclude='freesurfer/subjects/fsaverage3' \
--exclude='freesurfer/subjects/fsaverage4' \
--exclude='freesurfer/subjects/fsaverage5' \
--exclude='freesurfer/subjects/fsaverage6' \
--exclude='freesurfer/subjects/cvs_avg35' \
--exclude='freesurfer/subjects/cvs_avg35_inMNI152' \
--exclude='freesurfer/subjects/bert' \
--exclude='freesurfer/subjects/V1_average' \
--exclude='freesurfer/average/mult-comp-cor' \
--exclude='freesurfer/lib/cuda' \
--exclude='freesurfer/lib/qt' && \
apt-get install -y tcsh bc tar libgomp1 perl-modules curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Set up the environment
ENV OS Linux
ENV FS_OVERRIDE 0
ENV FIX_VERTEX_AREA=
ENV SUBJECTS_DIR /opt/freesurfer/subjects
ENV FSF_OUTPUT_FORMAT nii.gz
ENV MNI_DIR /opt/freesurfer/mni
ENV LOCAL_DIR /opt/freesurfer/local
ENV FREESURFER_HOME /opt/freesurfer
ENV FSFAST_HOME /opt/freesurfer/fsfast
ENV MINC_BIN_DIR /opt/freesurfer/mni/bin
ENV MINC_LIB_DIR /opt/freesurfer/mni/lib
ENV MNI_DATAPATH /opt/freesurfer/mni/data
ENV FMRI_ANALYSIS_DIR /opt/freesurfer/fsfast
ENV PERL5LIB /opt/freesurfer/mni/lib/perl5/5.8.5
ENV MNI_PERL5LIB /opt/freesurfer/mni/lib/perl5/5.8.5
ENV PATH /opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
RUN echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh

RUN svn export --force https://github.com/NeuroVault/neurovault_data/trunk/pycortex_datastore /usr/local/share/pycortex/
RUN apt-get update && apt-get -y install tcsh libglu1-mesa libxmu6
RUN /opt/freesurfer/bin/mri_convert /opt/freesurfer/subjects/fsaverage/mri/brain.mgz /opt/freesurfer/subjects/fsaverage/mri/brain.nii.gz
RUN mkdir /usr/local/share/pycortex/db/fsaverage/transforms/
RUN pip install tornado

RUN apt-get update && apt-get -y install zip
RUN wget https://ndownloader.figshare.com/files/6891069 -O icbm.zip && unzip icbm.zip -d /opt/freesurfer/subjects/ && rm icbm.zip

COPY ./compose/django/requirements.txt requirements.txt
RUN pip install -r requirements.txt

Expand Down
49 changes: 0 additions & 49 deletions compose/django/Dockerfile_fs

This file was deleted.

68 changes: 0 additions & 68 deletions compose/django/Dockerfile_multi

This file was deleted.

8 changes: 4 additions & 4 deletions docker-compose.yml
Expand Up @@ -4,9 +4,9 @@ services:
restart: always
build:
context: .
dockerfile: ./compose/django/Dockerfile_multi
target: neurovault_fs
image: neurovault/neurovault_fs
dockerfile: ./compose/django/Dockerfile
target: neurovault
image: neurovault/neurovault
command: python manage.py runserver 0.0.0.0:8000
ports:
- "8000:8000"
Expand Down Expand Up @@ -35,7 +35,7 @@ services:
worker:
build:
context: .
dockerfile: ./compose/django/Dockerfile_multi
dockerfile: ./compose/django/Dockerfile
target: neurovault
image: neurovault/neurovault
command: celery -A neurovault.celery worker -Q default -n default@%h
Expand Down
Binary file not shown.
Binary file not shown.
16 changes: 0 additions & 16 deletions neurovault/apps/users/forms.py
Expand Up @@ -2,7 +2,6 @@
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
from django.utils.translation import gettext_lazy as _
from oauth2_provider.models import Application


class UserCreateForm(UserCreationForm):
Expand Down Expand Up @@ -57,18 +56,3 @@ def save(self, commit=True):

def clean_password(self):
return ""


class ApplicationEditForm(forms.ModelForm):
name = forms.CharField(required=True)

class Meta:
model = Application
fields = (
"name",
"client_id",
"client_secret",
"client_type",
"authorization_grant_type",
"redirect_uris",
)
3 changes: 3 additions & 0 deletions neurovault/apps/users/migrations/0001_initial.py
Expand Up @@ -5,12 +5,15 @@


def create_default_app(apps, schema_editor):
'''
Application = apps.get_registered_model("oauth2_provider", "Application")
Application.objects.get_or_create(
name=settings.DEFAULT_OAUTH_APP_NAME,
redirect_uris=["http://localhost"],
pk=settings.DEFAULT_OAUTH_APPLICATION_ID,
)
'''
pass


class Migration(migrations.Migration):
Expand Down
6 changes: 0 additions & 6 deletions neurovault/apps/users/templates/base_settings.html
Expand Up @@ -15,12 +15,6 @@ <h2>Settings</h2>
<li class="nav-item" {% block personalaccesstokenstab %}{% endblock %}>
<a class="nav-link" href="{% url 'users:token_list' %}">Personal access tokens</a>
</li>
<li class="nav-item" {% block connectedappstab %}{% endblock %}>
<a class="nav-link" href="{% url 'oauth2_provider:list' %}">Connected applications</a>
</li>
<li class="nav-item" {% block developerappstab %}{% endblock %}>
<a class="nav-link" href="{% url 'users:developerapps_list' %}">Developer applications</a>
</li>
</ul>
{% block setting_content %}{% endblock %}
{% endblock %}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 7c85cab

Please sign in to comment.