Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [FC-0006] add Verifiable Credentials optional feature #1973

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Contributor

@justinhynes justinhynes May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, the __init__.py of a Django app should have a default_app_config defined and point to the Config class defined in the apps.py (in this case the VerifiableCredentialsConfig class).

Not sure if this was missed or just being planned for later, but figured I'd add it here in case it was missed.

(I also have a half-baked assumption that since the ready function isn't defined as part of the VerifiableCredentialsConfig class, we might not be able to add a declaration for the default_app_config yet)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I also see that there is a larger part 2 OSPR I wasn't immediately aware of, we could probably address that there)

Empty file.
3 changes: 3 additions & 0 deletions credentials/apps/verifiable_credentials/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Admin section configuration.
"""
6 changes: 6 additions & 0 deletions credentials/apps/verifiable_credentials/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class VerifiableCredentialsConfig(AppConfig):
name = "credentials.apps.verifiable_credentials"
verbose_name = "Verifiable Credentials"
3 changes: 3 additions & 0 deletions credentials/apps/verifiable_credentials/checks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Verifiable Credentials self-checks.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Verifiable Credentials different data models specifications.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
Open Badges 3.0.* data model.
See specification: https://1edtech.github.io/openbadges-specification/ob_v3p0.html
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Complementary schemas for verifiable credential composition.
"""
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Composition utils.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Verifiable Credentials v1.1 data model.

See specification: https://www.w3.org/TR/vc-data-model/
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Issuance module.
"""
3 changes: 3 additions & 0 deletions credentials/apps/verifiable_credentials/issuance/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Issuance line processor.
"""
3 changes: 3 additions & 0 deletions credentials/apps/verifiable_credentials/issuance/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Verifiable Credentials DB models.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Verifiable credentials renderers.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Verifiable Credentials serializers.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Status List issuance utils.

Status list is managed for each Issuer separately.
Status lists are verifiable credentials themselves, but with a specific shape.
"""
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions credentials/apps/verifiable_credentials/issuance/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Issuance utils.
"""
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions credentials/apps/verifiable_credentials/permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Verifiable credentials specific permissions.
"""
Empty file.
8 changes: 8 additions & 0 deletions credentials/apps/verifiable_credentials/rest_api/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Root API URLs for verifiable_credentials."""
from django.conf.urls import include
from django.urls import re_path


urlpatterns = [
re_path(r"^v1/", include(("credentials.apps.verifiable_credentials.rest_api.v1.urls", "v1"), namespace="v1")),
]
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions credentials/apps/verifiable_credentials/rest_api/v1/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Verifiable Credentials API v1 URLs.
"""
from rest_framework import routers


router = routers.DefaultRouter()

urlpatterns = []

urlpatterns += router.urls
Empty file.
13 changes: 13 additions & 0 deletions credentials/apps/verifiable_credentials/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Settings for Verifiable Credentials are all namespaced in the VERIFIABLE_CREDENTIALS setting.
This is pretty similar to what the DRF does, like this:

VERIFIABLE_CREDENTIALS = {
'setting_1': 'value_1',
'setting_2': 'value_2',
}

This module provides the `vc_setting` object, that is used to access
Verifiable Credentials settings, checking for explicit settings first, then falling
back to the defaults.
"""
3 changes: 3 additions & 0 deletions credentials/apps/verifiable_credentials/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Verifiable Credentials signal handlers.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Verifiable Credentials built-in storage backends.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Status List 2021 storage.
"""
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions credentials/apps/verifiable_credentials/storages/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Storages utils.
"""
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
21 changes: 21 additions & 0 deletions credentials/apps/verifiable_credentials/toggles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
Toggles for verifiable_credentials app.
"""

from edx_toggles.toggles import SettingToggle


# .. toggle_name: ENABLE_VERIFIABLE_CREDENTIALS
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
# .. toggle_description: Determines if the Credentials IDA uses digital credentials issuance.
# .. toggle_warning: Requires the Learner Record MFE to be deployed and used in a given environment if toggled to true.
# .. toggle_life_expectancy: permanent
# .. toggle_permanent_justification: Digital Credentials are optional for usage.
# .. toggle_creation_date: 2023-02-02
# .. toggle_use_cases: open_edx
ENABLE_VERIFIABLE_CREDENTIALS = SettingToggle("ENABLE_VERIFIABLE_CREDENTIALS", default=False, module_name=__name__)


def is_verifiable_credentials_enabled():
return ENABLE_VERIFIABLE_CREDENTIALS.is_enabled()
10 changes: 10 additions & 0 deletions credentials/apps/verifiable_credentials/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
URLs for verifiable_credentials.
"""
from django.conf.urls import include
from django.urls import re_path


urlpatterns = [
re_path(r"^api/", include(("credentials.apps.verifiable_credentials.rest_api.urls", "api"), namespace="api")),
]
Empty file.
1 change: 1 addition & 0 deletions credentials/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"credentials.apps.credentials_theme_openedx",
"credentials.apps.records",
"credentials.apps.plugins",
"credentials.apps.verifiable_credentials",
]

INSTALLED_APPS += THIRD_PARTY_APPS
Expand Down
4 changes: 4 additions & 0 deletions credentials/settings/private.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ PROGRAMS_CACHE_TTL = 60
# USER API CONFIGURATION
# Specified in seconds. Enable caching by setting this to a value greater than 0.
USER_CACHE_TTL = 60

# Verifiable Credentials
USE_LEARNER_RECORD_MFE = True
ENABLE_VERIFIABLE_CREDENTIALS = True
10 changes: 10 additions & 0 deletions credentials/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,13 @@
)
STATICFILES_STORAGE = None
add_plugins(__name__, PROJECT_TYPE, SettingsType.TEST)

# Verifiable Credentials
ENABLE_VERIFIABLE_CREDENTIALS = True
VERIFIABLE_CREDENTIALS = {
"DEFAULT_ISSUER": {
"ID": "test-issuer-did",
"KEY": "test-issuer-key",
"NAME": "test-issuer-name",
}
}
12 changes: 12 additions & 0 deletions credentials/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from credentials.apps.core import views as core_views
from credentials.apps.plugins.constants import PROJECT_TYPE
from credentials.apps.records.views import ProgramListingView
from credentials.apps.verifiable_credentials.toggles import is_verifiable_credentials_enabled
from credentials.views import FaviconView, MockToggleStateView


Expand Down Expand Up @@ -70,6 +71,17 @@
re_path(r"^hijack/", include("hijack.urls", namespace="hijack")),
]

if is_verifiable_credentials_enabled():
urlpatterns += [
re_path(
r"^verifiable_credentials/",
include(
("credentials.apps.verifiable_credentials.urls", "verifiable_credentials"),
namespace="verifiable_credentials",
),
),
]

# edx-drf-extensions csrf app
urlpatterns += [
path("", include("csrf.urls")),
Expand Down