From 2dfd93afb1df562101fec01a7b9dba9282101da7 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 20 Feb 2020 13:45:22 +0100 Subject: [PATCH 01/25] core: add more fields for metadata of applications --- passbook/core/api/applications.py | 10 ++++--- passbook/core/forms/applications.py | 20 ++++++++----- .../migrations/0008_auto_20200220_1242.py | 29 +++++++++++++++++++ passbook/core/models.py | 12 +++++--- 4 files changed, 55 insertions(+), 16 deletions(-) create mode 100644 passbook/core/migrations/0008_auto_20200220_1242.py diff --git a/passbook/core/api/applications.py b/passbook/core/api/applications.py index 9e4930c46..f0b4c69e2 100644 --- a/passbook/core/api/applications.py +++ b/passbook/core/api/applications.py @@ -15,11 +15,13 @@ class ApplicationSerializer(ModelSerializer): "pk", "name", "slug", - "launch_url", - "icon_url", - "provider", - "policies", "skip_authorization", + "provider", + "meta_launch_url", + "meta_icon_url", + "meta_description", + "meta_publisher", + "policies", ] diff --git a/passbook/core/forms/applications.py b/passbook/core/forms/applications.py index 0d6756585..4ed05137c 100644 --- a/passbook/core/forms/applications.py +++ b/passbook/core/forms/applications.py @@ -19,19 +19,23 @@ class ApplicationForm(forms.ModelForm): fields = [ "name", "slug", - "launch_url", - "icon_url", - "provider", - "policies", "skip_authorization", + "provider", + "meta_launch_url", + "meta_icon_url", + "meta_description", + "meta_publisher", + "policies", ] widgets = { "name": forms.TextInput(), - "launch_url": forms.TextInput(), - "icon_url": forms.TextInput(), + "meta_launch_url": forms.TextInput(), + "meta_icon_url": forms.TextInput(), + "meta_publisher": forms.TextInput(), "policies": FilteredSelectMultiple(_("policies"), False), } labels = { - "launch_url": _("Launch URL"), - "icon_url": _("Icon URL"), + "meta_launch_url": _("Launch URL"), + "meta_icon_url": _("Icon URL"), } + help_texts = {"policies": _("Policies required to access this Application.")} diff --git a/passbook/core/migrations/0008_auto_20200220_1242.py b/passbook/core/migrations/0008_auto_20200220_1242.py new file mode 100644 index 000000000..fe35fffe1 --- /dev/null +++ b/passbook/core/migrations/0008_auto_20200220_1242.py @@ -0,0 +1,29 @@ +# Generated by Django 3.0.3 on 2020-02-20 12:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("passbook_core", "0007_auto_20200217_1934"), + ] + + operations = [ + migrations.RenameField( + model_name="application", old_name="icon_url", new_name="meta_icon_url", + ), + migrations.RenameField( + model_name="application", old_name="launch_url", new_name="meta_launch_url", + ), + migrations.AddField( + model_name="application", + name="meta_description", + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name="application", + name="meta_publisher", + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/passbook/core/models.py b/passbook/core/models.py index bcd00b43b..1d718a6f7 100644 --- a/passbook/core/models.py +++ b/passbook/core/models.py @@ -143,16 +143,19 @@ class Application(ExportModelOperationsMixin("application"), PolicyModel): name = models.TextField() slug = models.SlugField() - launch_url = models.URLField(null=True, blank=True) - icon_url = models.TextField(null=True, blank=True) + skip_authorization = models.BooleanField(default=False) provider = models.OneToOneField( "Provider", null=True, blank=True, default=None, on_delete=models.SET_DEFAULT ) - skip_authorization = models.BooleanField(default=False) + + meta_launch_url = models.URLField(null=True, blank=True) + meta_icon_url = models.TextField(null=True, blank=True) + meta_description = models.TextField(null=True, blank=True) + meta_publisher = models.TextField(null=True, blank=True) objects = InheritanceManager() - def get_provider(self): + def get_provider(self) -> Optional[Provider]: """Get casted provider instance""" if not self.provider: return None @@ -167,6 +170,7 @@ class Source(ExportModelOperationsMixin("source"), PolicyModel): name = models.TextField() slug = models.SlugField() + enabled = models.BooleanField(default=True) property_mappings = models.ManyToManyField( "PropertyMapping", default=None, blank=True From c96571bdba4f13b347ec466270e6ff5937c7529e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 20 Feb 2020 13:50:05 +0100 Subject: [PATCH 02/25] core: fix discord logo being hard to see --- passbook/core/static/img/logos/discord.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/passbook/core/static/img/logos/discord.svg b/passbook/core/static/img/logos/discord.svg index 4613aa9ae..9084f5046 100644 --- a/passbook/core/static/img/logos/discord.svg +++ b/passbook/core/static/img/logos/discord.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file From 3c2b8e5ee1584d9dc9fdd3fd6dfdc66fceb05d7f Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 20 Feb 2020 13:51:41 +0100 Subject: [PATCH 03/25] all: prefix all UI related methods with ui_, switch to property and return dataclass --- .../templates/administration/source/list.html | 2 +- passbook/core/models.py | 32 ++++++----------- .../templatetags/passbook_user_settings.py | 31 ++++++++++------- passbook/core/types.py | 29 ++++++++++++++++ passbook/core/views/authentication.py | 6 ++-- passbook/factors/otp/models.py | 13 ++++--- passbook/factors/password/models.py | 12 ++++--- passbook/policies/expression/evaluator.py | 2 +- passbook/sources/oauth/models.py | 34 +++++++++++-------- passbook/sources/saml/models.py | 16 +++++---- 10 files changed, 110 insertions(+), 67 deletions(-) create mode 100644 passbook/core/types.py diff --git a/passbook/admin/templates/administration/source/list.html b/passbook/admin/templates/administration/source/list.html index b2de358b2..e0e5c9e36 100644 --- a/passbook/admin/templates/administration/source/list.html +++ b/passbook/admin/templates/administration/source/list.html @@ -36,7 +36,7 @@ {{ source.name }} {{ source|fieldtype }} - {{ source.additional_info|safe }} + {{ source.ui_additional_info|safe|default:"" }} {% trans 'Edit' %} diff --git a/passbook/core/models.py b/passbook/core/models.py index 1d718a6f7..32bda701b 100644 --- a/passbook/core/models.py +++ b/passbook/core/models.py @@ -21,6 +21,7 @@ from jinja2.nativetypes import NativeEnvironment from model_utils.managers import InheritanceManager from structlog import get_logger +from passbook.core.types import UIUserSettings, UILoginButton from passbook.core.exceptions import PropertyMappingExpressionException from passbook.core.signals import password_changed from passbook.lib.models import CreatedUpdatedModel, UUIDModel @@ -102,19 +103,6 @@ class PolicyModel(UUIDModel, CreatedUpdatedModel): policies = models.ManyToManyField("Policy", blank=True) -class UserSettings: - """Dataclass for Factor and Source's user_settings""" - - name: str - icon: str - view_name: str - - def __init__(self, name: str, icon: str, view_name: str): - self.name = name - self.icon = icon - self.view_name = view_name - - class Factor(ExportModelOperationsMixin("factor"), PolicyModel): """Authentication factor, multiple instances of the same Factor can be used""" @@ -127,9 +115,10 @@ class Factor(ExportModelOperationsMixin("factor"), PolicyModel): type = "" form = "" - def user_settings(self) -> Optional[UserSettings]: + @property + def ui_user_settings(self) -> Optional[UIUserSettings]: """Entrypoint to integrate with User settings. Can either return None if no - user settings are available, or an instanace of UserSettings.""" + user settings are available, or an instanace of UIUserSettings.""" return None def __str__(self): @@ -181,19 +170,20 @@ class Source(ExportModelOperationsMixin("source"), PolicyModel): objects = InheritanceManager() @property - def login_button(self): - """Return a tuple of URL, Icon name and Name - if Source should get a link on the login page""" + def ui_login_button(self) -> Optional[UILoginButton]: + """If source uses a http-based flow, return UI Information about the login + button. If source doesn't use http-based flow, return None.""" return None @property - def additional_info(self): + def ui_additional_info(self) -> Optional[str]: """Return additional Info, such as a callback URL. Show in the administration interface.""" return None - def user_settings(self) -> Optional[UserSettings]: + @property + def ui_user_settings(self) -> Optional[UIUserSettings]: """Entrypoint to integrate with User settings. Can either return None if no - user settings are available, or an instanace of UserSettings.""" + user settings are available, or an instanace of UIUserSettings.""" return None def __str__(self): diff --git a/passbook/core/templatetags/passbook_user_settings.py b/passbook/core/templatetags/passbook_user_settings.py index 82c7ec60c..39773799e 100644 --- a/passbook/core/templatetags/passbook_user_settings.py +++ b/passbook/core/templatetags/passbook_user_settings.py @@ -1,46 +1,53 @@ """passbook user settings template tags""" -from typing import List +from typing import List, Iterable from django import template from django.template.context import RequestContext -from passbook.core.models import Factor, Source, UserSettings +from passbook.core.types import UIUserSettings +from passbook.core.models import Factor, Source from passbook.policies.engine import PolicyEngine register = template.Library() @register.simple_tag(takes_context=True) -def user_factors(context: RequestContext) -> List[UserSettings]: +def user_factors(context: RequestContext) -> List[UIUserSettings]: """Return list of all factors which apply to user""" user = context.get("request").user - _all_factors = ( + _all_factors: Iterable[Factor] = ( Factor.objects.filter(enabled=True).order_by("order").select_subclasses() ) - matching_factors: List[UserSettings] = [] + matching_factors: List[UIUserSettings] = [] for factor in _all_factors: - user_settings = factor.user_settings() + user_settings = factor.ui_user_settings + if not user_settings: + continue policy_engine = PolicyEngine( factor.policies.all(), user, context.get("request") ) policy_engine.build() - if policy_engine.passing and user_settings: + if policy_engine.passing: matching_factors.append(user_settings) return matching_factors @register.simple_tag(takes_context=True) -def user_sources(context: RequestContext) -> List[UserSettings]: +def user_sources(context: RequestContext) -> List[UIUserSettings]: """Return a list of all sources which are enabled for the user""" user = context.get("request").user - _all_sources = Source.objects.filter(enabled=True).select_subclasses() - matching_sources: List[UserSettings] = [] + _all_sources: Iterable[Source] = ( + Source.objects.filter(enabled=True).select_subclasses() + ) + matching_sources: List[UIUserSettings] = [] for factor in _all_sources: - user_settings = factor.user_settings() + user_settings = factor.ui_user_settings + if not user_settings: + continue policy_engine = PolicyEngine( factor.policies.all(), user, context.get("request") ) policy_engine.build() - if policy_engine.passing and user_settings: + if policy_engine.passing: matching_sources.append(user_settings) return matching_sources diff --git a/passbook/core/types.py b/passbook/core/types.py new file mode 100644 index 000000000..17937b527 --- /dev/null +++ b/passbook/core/types.py @@ -0,0 +1,29 @@ +"""passbook core dataclasses""" +from typing import Optional +from dataclasses import dataclass + + +@dataclass +class UIUserSettings: + """Dataclass for Factor and Source's user_settings""" + + name: str + icon: str + view_name: str + + +@dataclass +class UILoginButton: + """Dataclass for Source's ui_ui_login_button""" + + # Name, ran through i18n + name: str + + # URL Which Button points to + url: str + + # Icon name, ran through django's static + icon_path: Optional[str] = None + + # Icon URL, used as-is + icon_url: Optional[str] = None diff --git a/passbook/core/views/authentication.py b/passbook/core/views/authentication.py index f85aaa019..05bee8ba1 100644 --- a/passbook/core/views/authentication.py +++ b/passbook/core/views/authentication.py @@ -47,9 +47,9 @@ class LoginView(UserPassesTestMixin, FormView): kwargs["sources"] = [] sources = Source.objects.filter(enabled=True).select_subclasses() for source in sources: - login_button = source.login_button - if login_button: - kwargs["sources"].append(login_button) + ui_login_button = source.ui_login_button + if ui_login_button: + kwargs["sources"].append(ui_login_button) if kwargs["sources"]: self.template_name = "login/with_sources.html" return super().get_context_data(**kwargs) diff --git a/passbook/factors/otp/models.py b/passbook/factors/otp/models.py index daf9fb4a2..8e751e625 100644 --- a/passbook/factors/otp/models.py +++ b/passbook/factors/otp/models.py @@ -1,9 +1,9 @@ """OTP Factor""" - from django.db import models from django.utils.translation import gettext as _ -from passbook.core.models import Factor, UserSettings +from passbook.core.types import UIUserSettings +from passbook.core.models import Factor class OTPFactor(Factor): @@ -17,9 +17,12 @@ class OTPFactor(Factor): type = "passbook.factors.otp.factors.OTPFactor" form = "passbook.factors.otp.forms.OTPFactorForm" - def user_settings(self) -> UserSettings: - return UserSettings( - _("OTP"), "pficon-locked", "passbook_factors_otp:otp-user-settings" + @property + def ui_user_settings(self) -> UIUserSettings: + return UIUserSettings( + name="OTP", + icon="pficon-locked", + view_name="passbook_factors_otp:otp-user-settings", ) def __str__(self): diff --git a/passbook/factors/password/models.py b/passbook/factors/password/models.py index b5ed6bdf5..e9af9722a 100644 --- a/passbook/factors/password/models.py +++ b/passbook/factors/password/models.py @@ -3,7 +3,8 @@ from django.contrib.postgres.fields import ArrayField from django.db import models from django.utils.translation import gettext_lazy as _ -from passbook.core.models import Factor, Policy, User, UserSettings +from passbook.core.types import UIUserSettings +from passbook.core.models import Factor, Policy, User class PasswordFactor(Factor): @@ -18,9 +19,12 @@ class PasswordFactor(Factor): type = "passbook.factors.password.factor.PasswordFactor" form = "passbook.factors.password.forms.PasswordFactorForm" - def user_settings(self): - return UserSettings( - _("Change Password"), "pficon-key", "passbook_core:user-change-password" + @property + def ui_user_settings(self) -> UIUserSettings: + return UIUserSettings( + name="Change Password", + icon="pficon-key", + view_name="passbook_core:user-change-password", ) def password_passes(self, user: User) -> bool: diff --git a/passbook/policies/expression/evaluator.py b/passbook/policies/expression/evaluator.py index 042a4d9db..db14c7eba 100644 --- a/passbook/policies/expression/evaluator.py +++ b/passbook/policies/expression/evaluator.py @@ -76,7 +76,7 @@ class Evaluator: src=expression_source, req=request, ) - return PolicyRequest(False) + return PolicyResult(False) if isinstance(result, list) and len(result) == 2: return PolicyResult(*result) if result: diff --git a/passbook/sources/oauth/models.py b/passbook/sources/oauth/models.py index 40d070df6..1c1cabfd9 100644 --- a/passbook/sources/oauth/models.py +++ b/passbook/sources/oauth/models.py @@ -4,7 +4,8 @@ from django.db import models from django.urls import reverse, reverse_lazy from django.utils.translation import gettext_lazy as _ -from passbook.core.models import Source, UserSettings, UserSourceConnection +from passbook.core.types import UILoginButton, UIUserSettings +from passbook.core.models import Source, UserSourceConnection from passbook.sources.oauth.clients import get_client @@ -28,30 +29,35 @@ class OAuthSource(Source): form = "passbook.sources.oauth.forms.OAuthSourceForm" @property - def login_button(self): - url = reverse_lazy( - "passbook_sources_oauth:oauth-client-login", - kwargs={"source_slug": self.slug}, + def ui_login_button(self) -> UILoginButton: + return UILoginButton( + url=reverse_lazy( + "passbook_sources_oauth:oauth-client-login", + kwargs={"source_slug": self.slug}, + ), + icon_path=f"{self.provider_type}.svg", + name=self.name, ) - return url, self.provider_type, self.name @property - def additional_info(self): - return "Callback URL:
%s
" % reverse_lazy( + def ui_additional_info(self) -> str: + url = reverse_lazy( "passbook_sources_oauth:oauth-client-callback", kwargs={"source_slug": self.slug}, ) + return f"Callback URL:
{url}
" - def user_settings(self) -> UserSettings: + @property + def ui_user_settings(self) -> UIUserSettings: icon_type = self.provider_type if icon_type == "azure ad": icon_type = "windows" - icon_class = "fa fa-%s" % icon_type + icon_class = f"fa fa-{icon_type}" view_name = "passbook_sources_oauth:oauth-client-user" - return UserSettings( - self.name, - icon_class, - reverse((view_name), kwargs={"source_slug": self.slug}), + return UIUserSettings( + name=self.name, + icon=icon_class, + view_name=reverse((view_name), kwargs={"source_slug": self.slug}), ) class Meta: diff --git a/passbook/sources/saml/models.py b/passbook/sources/saml/models.py index 273380382..36356fdfa 100644 --- a/passbook/sources/saml/models.py +++ b/passbook/sources/saml/models.py @@ -3,11 +3,12 @@ from django.db import models from django.urls import reverse_lazy from django.utils.translation import gettext_lazy as _ +from passbook.core.types import UILoginButton from passbook.core.models import Source class SAMLSource(Source): - """SAML2 Source""" + """SAML Source""" entity_id = models.TextField(blank=True, default=None, verbose_name=_("Entity ID")) idp_url = models.URLField(verbose_name=_("IDP URL")) @@ -20,14 +21,17 @@ class SAMLSource(Source): form = "passbook.sources.saml.forms.SAMLSourceForm" @property - def login_button(self): - url = reverse_lazy( - "passbook_sources_saml:login", kwargs={"source_slug": self.slug} + def ui_login_button(self) -> UILoginButton: + return UILoginButton( + name=self.name, + url=reverse_lazy( + "passbook_sources_saml:login", kwargs={"source_slug": self.slug} + ), + icon_path="", ) - return url, "", self.name @property - def additional_info(self): + def ui_additional_info(self) -> str: metadata_url = reverse_lazy( "passbook_sources_saml:metadata", kwargs={"source_slug": self} ) From 2bef5f3911de0f92d1321da2096ec6e7d6227cd7 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 20 Feb 2020 13:52:05 +0100 Subject: [PATCH 04/25] policies: struct -> types to match core --- passbook/core/models.py | 2 +- passbook/policies/engine.py | 10 +++++----- passbook/policies/expiry/models.py | 2 +- passbook/policies/expression/evaluator.py | 2 +- passbook/policies/expression/models.py | 2 +- passbook/policies/password/models.py | 2 +- passbook/policies/process.py | 2 +- passbook/policies/reputation/models.py | 2 +- passbook/policies/{struct.py => types.py} | 0 passbook/policies/webhook/models.py | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) rename passbook/policies/{struct.py => types.py} (100%) diff --git a/passbook/core/models.py b/passbook/core/models.py index 32bda701b..a27668b45 100644 --- a/passbook/core/models.py +++ b/passbook/core/models.py @@ -26,7 +26,7 @@ from passbook.core.exceptions import PropertyMappingExpressionException from passbook.core.signals import password_changed from passbook.lib.models import CreatedUpdatedModel, UUIDModel from passbook.policies.exceptions import PolicyException -from passbook.policies.struct import PolicyRequest, PolicyResult +from passbook.policies.types import PolicyRequest, PolicyResult LOGGER = get_logger() NATIVE_ENVIRONMENT = NativeEnvironment() diff --git a/passbook/policies/engine.py b/passbook/policies/engine.py index 25709f166..62455b0f0 100644 --- a/passbook/policies/engine.py +++ b/passbook/policies/engine.py @@ -9,7 +9,7 @@ from structlog import get_logger from passbook.core.models import Policy, User from passbook.policies.process import PolicyProcess, cache_key -from passbook.policies.struct import PolicyRequest, PolicyResult +from passbook.policies.types import PolicyRequest, PolicyResult LOGGER = get_logger() # This is only really needed for macOS, because Python 3.8 changed the default to spawn @@ -63,13 +63,13 @@ class PolicyEngine: for policy in self._select_subclasses(): cached_policy = cache.get(cache_key(policy, self.request.user), None) if cached_policy and self.use_cache: - LOGGER.debug("Taking result from cache", policy=policy) + LOGGER.debug("P_ENG: Taking result from cache", policy=policy) self.__cached_policies.append(cached_policy) continue - LOGGER.debug("Evaluating policy", policy=policy) + LOGGER.debug("P_ENG: Evaluating policy", policy=policy) our_end, task_end = Pipe(False) task = PolicyProcess(policy, self.request, task_end) - LOGGER.debug("Starting Process", policy=policy) + LOGGER.debug("P_ENG: Starting Process", policy=policy) task.start() self.__processes.append( PolicyProcessInfo(process=task, connection=our_end, policy=policy) @@ -90,7 +90,7 @@ class PolicyEngine: x.result for x in self.__processes if x.result ] for result in process_results + self.__cached_policies: - LOGGER.debug("result", passing=result.passing) + LOGGER.debug("P_ENG: result", passing=result.passing) if result.messages: messages += result.messages if not result.passing: diff --git a/passbook/policies/expiry/models.py b/passbook/policies/expiry/models.py index 94c59a01e..102360dad 100644 --- a/passbook/policies/expiry/models.py +++ b/passbook/policies/expiry/models.py @@ -7,7 +7,7 @@ from django.utils.translation import gettext as _ from structlog import get_logger from passbook.core.models import Policy -from passbook.policies.struct import PolicyRequest, PolicyResult +from passbook.policies.types import PolicyRequest, PolicyResult LOGGER = get_logger() diff --git a/passbook/policies/expression/evaluator.py b/passbook/policies/expression/evaluator.py index db14c7eba..baa22e278 100644 --- a/passbook/policies/expression/evaluator.py +++ b/passbook/policies/expression/evaluator.py @@ -9,7 +9,7 @@ from jinja2.nativetypes import NativeEnvironment from structlog import get_logger from passbook.factors.view import AuthenticationView -from passbook.policies.struct import PolicyRequest, PolicyResult +from passbook.policies.types import PolicyRequest, PolicyResult if TYPE_CHECKING: from passbook.core.models import User diff --git a/passbook/policies/expression/models.py b/passbook/policies/expression/models.py index 8ec07211f..2ba3827a6 100644 --- a/passbook/policies/expression/models.py +++ b/passbook/policies/expression/models.py @@ -4,7 +4,7 @@ from django.utils.translation import gettext as _ from passbook.core.models import Policy from passbook.policies.expression.evaluator import Evaluator -from passbook.policies.struct import PolicyRequest, PolicyResult +from passbook.policies.types import PolicyRequest, PolicyResult class ExpressionPolicy(Policy): diff --git a/passbook/policies/password/models.py b/passbook/policies/password/models.py index 6d81d2109..03b552a21 100644 --- a/passbook/policies/password/models.py +++ b/passbook/policies/password/models.py @@ -6,7 +6,7 @@ from django.utils.translation import gettext as _ from structlog import get_logger from passbook.core.models import Policy -from passbook.policies.struct import PolicyRequest, PolicyResult +from passbook.policies.types import PolicyRequest, PolicyResult LOGGER = get_logger() diff --git a/passbook/policies/process.py b/passbook/policies/process.py index 9615300cf..b8114380f 100644 --- a/passbook/policies/process.py +++ b/passbook/policies/process.py @@ -7,7 +7,7 @@ from structlog import get_logger from passbook.core.models import Policy from passbook.policies.exceptions import PolicyException -from passbook.policies.struct import PolicyRequest, PolicyResult +from passbook.policies.types import PolicyRequest, PolicyResult LOGGER = get_logger() diff --git a/passbook/policies/reputation/models.py b/passbook/policies/reputation/models.py index c1f36e0b8..dfc9014c3 100644 --- a/passbook/policies/reputation/models.py +++ b/passbook/policies/reputation/models.py @@ -4,7 +4,7 @@ from django.utils.translation import gettext as _ from passbook.core.models import Policy, User from passbook.lib.utils.http import get_client_ip -from passbook.policies.struct import PolicyRequest, PolicyResult +from passbook.policies.types import PolicyRequest, PolicyResult class ReputationPolicy(Policy): diff --git a/passbook/policies/struct.py b/passbook/policies/types.py similarity index 100% rename from passbook/policies/struct.py rename to passbook/policies/types.py diff --git a/passbook/policies/webhook/models.py b/passbook/policies/webhook/models.py index d5487ec3f..9e1f29296 100644 --- a/passbook/policies/webhook/models.py +++ b/passbook/policies/webhook/models.py @@ -3,7 +3,7 @@ from django.db import models from django.utils.translation import gettext as _ from passbook.core.models import Policy -from passbook.policies.struct import PolicyRequest, PolicyResult +from passbook.policies.types import PolicyRequest, PolicyResult class WebhookPolicy(Policy): From 22ae986c0b6ba14b76e241ab4c216bebff55482e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 20 Feb 2020 13:52:14 +0100 Subject: [PATCH 05/25] root: add logger name to log output --- passbook/root/settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/passbook/root/settings.py b/passbook/root/settings.py index 493d1291e..a1df40b1d 100644 --- a/passbook/root/settings.py +++ b/passbook/root/settings.py @@ -271,6 +271,7 @@ STATIC_URL = "/static/" structlog.configure_once( processors=[ structlog.stdlib.add_log_level, + structlog.stdlib.add_logger_name, structlog.stdlib.PositionalArgumentsFormatter(), structlog.processors.TimeStamper(), structlog.processors.StackInfoRenderer(), From 9d8675e54b2f0b78769050d3176e3eda3ae72d09 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 20 Feb 2020 13:57:46 +0100 Subject: [PATCH 06/25] new release: 0.8.2-beta --- .bumpversion.cfg | 2 +- .github/workflows/release.yml | 12 ++++++------ helm/Chart.yaml | 4 ++-- helm/values.yaml | 2 +- passbook/__init__.py | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 0fa656a04..36b533401 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.8.1-beta +current_version = 0.8.2-beta tag = True commit = True parse = (?P\d+)\.(?P\d+)\.(?P\d+)\-(?P.*) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4242de3c6..fbb481859 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,11 +16,11 @@ jobs: - name: Building Docker Image run: docker build --no-cache - -t beryju/passbook:0.8.1-beta + -t beryju/passbook:0.8.2-beta -t beryju/passbook:latest -f Dockerfile . - name: Push Docker Container to Registry (versioned) - run: docker push beryju/passbook:0.8.1-beta + run: docker push beryju/passbook:0.8.2-beta - name: Push Docker Container to Registry (latest) run: docker push beryju/passbook:latest build-gatekeeper: @@ -37,11 +37,11 @@ jobs: cd gatekeeper docker build \ --no-cache \ - -t beryju/passbook-gatekeeper:0.8.1-beta \ + -t beryju/passbook-gatekeeper:0.8.2-beta \ -t beryju/passbook-gatekeeper:latest \ -f Dockerfile . - name: Push Docker Container to Registry (versioned) - run: docker push beryju/passbook-gatekeeper:0.8.1-beta + run: docker push beryju/passbook-gatekeeper:0.8.2-beta - name: Push Docker Container to Registry (latest) run: docker push beryju/passbook-gatekeeper:latest build-static: @@ -66,11 +66,11 @@ jobs: run: docker build --no-cache --network=$(docker network ls | grep github | awk '{print $1}') - -t beryju/passbook-static:0.8.1-beta + -t beryju/passbook-static:0.8.2-beta -t beryju/passbook-static:latest -f static.Dockerfile . - name: Push Docker Container to Registry (versioned) - run: docker push beryju/passbook-static:0.8.1-beta + run: docker push beryju/passbook-static:0.8.2-beta - name: Push Docker Container to Registry (latest) run: docker push beryju/passbook-static:latest test-release: diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 46ef49f0d..6d8ee17f2 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 -appVersion: "0.8.1-beta" +appVersion: "0.8.2-beta" description: A Helm chart for passbook. name: passbook -version: "0.8.1-beta" +version: "0.8.2-beta" icon: https://git.beryju.org/uploads/-/system/project/avatar/108/logo.png diff --git a/helm/values.yaml b/helm/values.yaml index cbd1ccc3d..d920d0ae5 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -2,7 +2,7 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. image: - tag: 0.8.1-beta + tag: 0.8.2-beta nameOverride: "" diff --git a/passbook/__init__.py b/passbook/__init__.py index 447ab674f..256c3e211 100644 --- a/passbook/__init__.py +++ b/passbook/__init__.py @@ -1,2 +1,2 @@ """passbook""" -__version__ = "0.8.1-beta" +__version__ = "0.8.2-beta" From 6c889eff272b3a93781dc1f64d41e1e67d742d48 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 20 Feb 2020 14:30:06 +0100 Subject: [PATCH 07/25] core: fix application icons not loading, fix with_sources being broken --- passbook/core/forms/applications.py | 2 + .../core/templates/login/with_sources.html | 13 ++-- passbook/core/templates/overview/index.html | 68 ++++++++++--------- passbook/sources/oauth/models.py | 2 +- 4 files changed, 46 insertions(+), 39 deletions(-) diff --git a/passbook/core/forms/applications.py b/passbook/core/forms/applications.py index 4ed05137c..8c1a91603 100644 --- a/passbook/core/forms/applications.py +++ b/passbook/core/forms/applications.py @@ -37,5 +37,7 @@ class ApplicationForm(forms.ModelForm): labels = { "meta_launch_url": _("Launch URL"), "meta_icon_url": _("Icon URL"), + "meta_description": _("Description"), + "meta_publisher": _("Publisher"), } help_texts = {"policies": _("Policies required to access this Application.")} diff --git a/passbook/core/templates/login/with_sources.html b/passbook/core/templates/login/with_sources.html index afdb50af6..76f95bcdc 100644 --- a/passbook/core/templates/login/with_sources.html +++ b/passbook/core/templates/login/with_sources.html @@ -48,13 +48,16 @@