Skip to content

Commit

Permalink
test removing pin of jwt (#31)
Browse files Browse the repository at this point in the history
* test removing pin of jwt
* remove black pin
* fixing bug with django url import
* update docstrings
* running isort
* black
* use method decorator in auth
* try adding to dispatch
* missing method decorate in image views

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Co-authored-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch and vsoch committed Jan 2, 2023
1 parent e60b2d0 commit e420c55
Show file tree
Hide file tree
Showing 60 changed files with 836 additions and 748 deletions.
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributing

Contributions are welcome, and they are greatly appreciated! Every
little bit helps, and credit will always be given.
little bit helps, and credit will always be given.

You can contribute in many ways:

Expand All @@ -28,7 +28,7 @@ is open to whoever wants to implement it.

### Write Documentation

django-oci could always use more documentation, whether as part of the
django-oci could always use more documentation, whether as part of the
official django-oci docs, in docstrings, or even on the web in blog posts,
articles, and such.

Expand Down
4 changes: 4 additions & 0 deletions .github/dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pre-commit
black
isort
flake8
20 changes: 9 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,22 @@ jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup black environment
- name: Setup black linter
run: conda create --quiet --name black pyflakes

- name: Check formatting with black
run: |
export PATH="/usr/share/miniconda/bin:$PATH"
source activate black
pip install black==20.8b1
black --check django_oci
- name: Check Spelling
uses: crate-ci/typos@7ad296c72fa8265059cc03d1eda562fbdfcd6df2 # v1.9.0
with:
files: ./docs/_docs/*.md ./docs/_docs/*/*.md

- name: Check imports with pyflakes
- name: Lint and format Python code
run: |
export PATH="/usr/share/miniconda/bin:$PATH"
source activate black
#pyflakes django_oci
pip install -r .github/dev-requirements.txt
pre-commit run --all-files
testing:
runs-on: ubuntu-latest
Expand Down
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending

- repo: local
hooks:
- id: black
name: black
language: python
types: [python]
entry: black

- id: isort
name: isort
args: [--filter-files]
language: python
types: [python]
entry: isort

- id: flake8
name: flake8
language: python
types: [python]
entry: flake8
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Changelog

This is a manually generated log to track changes to the repository for each release.
Each section should include general headers such as **Implemented enhancements**
and **Merged pull requests**. All closed issued and bug fixes should be
This is a manually generated log to track changes to the repository for each release.
Each section should include general headers such as **Implemented enhancements**
and **Merged pull requests**. All closed issued and bug fixes should be
represented by the pull requests that fixed them.
Critical items to know are:

Expand All @@ -14,6 +14,9 @@ Critical items to know are:
- changed behaviour

## [master](https://github.com/vsoch/django-oci/tree/master)
- unpinning pyjwt version (0.0.17)
- updating license headers
- support for Django 4.0+
- Better tweak MANIFEST for upload to not include pycache (0.0.16)
- Bug with filesystem save (saving without full image path) (0.0.15)
- Adding mount and HEAD new endpoints for distribution spec (0.0.14)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Apache Software License 2.0

Copyright (c) 2020, Vanessa Sochat
Copyright (c) 2020-2023, Vanessa Sochat

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![PyPI version](https://badge.fury.io/py/django-oci.svg)](https://badge.fury.io/py/django-oci)
![docs/assets/img/django-oci.png](docs/assets/img/django-oci.png)

Open Containers distribution API for Django.
Open Containers distribution API for Django.

This repository serves a Django app that can be used to provide an opencontainers
distribution (OCI) endpoint to push and pull containers. An [example](tests)
Expand Down Expand Up @@ -45,6 +45,6 @@ Add django-oci's URL patterns:
See the [documentation](https://vsoch.github.io/django-oci/) or [getting started guide](https://vsoch.github.io/django-oci/docs/getting-started/) for more details about setup, and testing. An [example application](tests) is provided
and described in the getting started guide as well. The latest [conformance testing](https://vsoch.github.io/django-oci/conformance/) is provided as well.

## Many Thanks
## Many Thanks

* [cookiecutter-djangopackage](https://github.com/pydanny/cookiecutter-djangopackage)
2 changes: 1 addition & 1 deletion django_oci/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.0.16"
__version__ = "0.0.17"
default_app_config = "django_oci.apps.DjangoOciConfig"
4 changes: 2 additions & 2 deletions django_oci/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (c) 2020, Vanessa Sochat
Copyright (c) 2020-2023, Vanessa Sochat
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@

from django.contrib import admin

from .models import Repository, Image
from .models import Image, Repository


@admin.register(Repository)
Expand Down
2 changes: 1 addition & 1 deletion django_oci/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (c) 2020, Vanessa Sochat
Copyright (c) 2020-2023, Vanessa Sochat
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
34 changes: 18 additions & 16 deletions django_oci/auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (c) 2020, Vanessa Sochat
Copyright (c) 2020-2023, Vanessa Sochat
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,24 +15,22 @@
limitations under the License.
"""
from django.urls import resolve
from django.contrib.auth.models import User

from django_oci import settings
from django_oci.utils import get_server
from django_oci.models import Repository

from rest_framework.authtoken.models import Token
from rest_framework.response import Response

from django.middleware import cache

from datetime import datetime
import uuid
import base64
import re
import time
import uuid
from datetime import datetime

import jwt
from django.contrib.auth.models import User
from django.middleware import cache
from django.urls import resolve
from rest_framework.authtoken.models import Token
from rest_framework.response import Response

from django_oci import settings
from django_oci.models import Repository
from django_oci.utils import get_server


def is_authenticated(
Expand Down Expand Up @@ -60,6 +58,10 @@ def is_authenticated(

# If authentication is disabled, return the original view
if settings.DISABLE_AUTHENTICATION or view_name not in settings.AUTHENTICATED_VIEWS:
print(f"{settings.DISABLE_AUTHENTICATION}")
print(
f"{view_name} is not in authenticated views: {settings.AUTHENTICATED_VIEWS}"
)
return True, None, None

# Ensure repository is valid, only if provided
Expand Down Expand Up @@ -212,7 +214,7 @@ def get_user(request):
token = Token.objects.get(key=token)
if token.user.username == username:
return token.user
except:
except Exception:
pass


Expand Down
11 changes: 6 additions & 5 deletions django_oci/files.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (c) 2020, Vanessa Sochat
Copyright (c) 2020-2023, Vanessa Sochat
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,14 +16,15 @@
"""

import hashlib
import os
from datetime import timezone

from django.core.files.base import ContentFile
from django.core.files.uploadedfile import UploadedFile
from django_oci.settings import MEDIA_ROOT
from django.db import models
from datetime import timezone

import os
import hashlib
from django_oci.settings import MEDIA_ROOT


class ChunkedUpload(models.Model):
Expand Down
16 changes: 8 additions & 8 deletions django_oci/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (c) 2020, Vanessa Sochat
Copyright (c) 2020-2023, Vanessa Sochat
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,18 +16,18 @@
"""

from django.core.files.storage import FileSystemStorage
from django_oci import settings
from django.urls import reverse
from django.db import models
from django.contrib.auth.models import User
from django.middleware import cache

import hashlib
import json
import os
import re

from django.contrib.auth.models import User
from django.core.files.storage import FileSystemStorage
from django.db import models
from django.middleware import cache
from django.urls import reverse

from django_oci import settings

PRIVACY_CHOICES = (
(False, "Public (The collection will be accessible by anyone)"),
Expand Down
9 changes: 6 additions & 3 deletions django_oci/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2020 Vanessa Sochat.
Copyright (C) 2020-2023 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -16,10 +16,11 @@
"""

from django.conf import settings
import logging
import uuid
import os
import uuid

from django.conf import settings

logger = logging.getLogger(__name__)

Expand All @@ -29,6 +30,8 @@
"django_oci.views.blobs.BlobDownload",
"django_oci.views.image.ImageTags",
"django_oci.views.image.ImageManifest",
"django_oci.views.image.view",
"django_oci.views.blobs.view",
]

DEFAULTS = {
Expand Down
7 changes: 4 additions & 3 deletions django_oci/signals.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (c) 2020, Vanessa Sochat
Copyright (c) 2020-2023, Vanessa Sochat
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,11 +15,12 @@
limitations under the License.
"""
from django.contrib.auth import get_user_model
from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver
from .models import Image
from rest_framework.authtoken.models import Token
from django.contrib.auth import get_user_model

from .models import Image

UserModel = get_user_model()

Expand Down

0 comments on commit e420c55

Please sign in to comment.