core: add setting to open application launch URL in a new browser tab (#3037)
* core: add setting to open application launch URL in a new browser tab * core: fix failing applications unit tests * core: fix formatting * core: include models only generated when debug mode is enabled
This commit is contained in:
		 Frédérick Permantier
					Frédérick Permantier
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							c11435780d
						
					
				
				
					commit
					2dfa6c2c82
				
			| @ -63,6 +63,7 @@ class ApplicationSerializer(ModelSerializer): | ||||
|             "provider", | ||||
|             "provider_obj", | ||||
|             "launch_url", | ||||
|             "open_in_new_tab", | ||||
|             "meta_launch_url", | ||||
|             "meta_icon", | ||||
|             "meta_description", | ||||
|  | ||||
| @ -0,0 +1,20 @@ | ||||
| # Generated by Django 4.0.5 on 2022-06-04 06:54 | ||||
|  | ||||
| from django.db import migrations, models | ||||
|  | ||||
|  | ||||
| class Migration(migrations.Migration): | ||||
|  | ||||
|     dependencies = [ | ||||
|         ("authentik_core", "0019_application_group"), | ||||
|     ] | ||||
|  | ||||
|     operations = [ | ||||
|         migrations.AddField( | ||||
|             model_name="application", | ||||
|             name="open_in_new_tab", | ||||
|             field=models.BooleanField( | ||||
|                 default=False, help_text="Open launch URL in a new browser tab or window." | ||||
|             ), | ||||
|         ), | ||||
|     ] | ||||
| @ -278,6 +278,11 @@ class Application(PolicyBindingModel): | ||||
|     meta_launch_url = models.TextField( | ||||
|         default="", blank=True, validators=[DomainlessURLValidator()] | ||||
|     ) | ||||
|  | ||||
|     open_in_new_tab = models.BooleanField( | ||||
|         default=False, help_text=_("Open launch URL in a new browser tab or window.") | ||||
|     ) | ||||
|  | ||||
|     # For template applications, this can be set to /static/authentik/applications/* | ||||
|     meta_icon = models.FileField( | ||||
|         upload_to="application-icons/", | ||||
|  | ||||
| @ -29,6 +29,7 @@ class TestApplicationsAPI(APITestCase): | ||||
|             name="allowed", | ||||
|             slug="allowed", | ||||
|             meta_launch_url="https://goauthentik.io/%(username)s", | ||||
|             open_in_new_tab=True, | ||||
|             provider=self.provider, | ||||
|         ) | ||||
|         self.denied = Application.objects.create(name="denied", slug="denied") | ||||
| @ -100,6 +101,7 @@ class TestApplicationsAPI(APITestCase): | ||||
|                         }, | ||||
|                         "launch_url": f"https://goauthentik.io/{self.user.username}", | ||||
|                         "meta_launch_url": "https://goauthentik.io/%(username)s", | ||||
|                         "open_in_new_tab": True, | ||||
|                         "meta_icon": None, | ||||
|                         "meta_description": "", | ||||
|                         "meta_publisher": "", | ||||
| @ -148,6 +150,7 @@ class TestApplicationsAPI(APITestCase): | ||||
|                         }, | ||||
|                         "launch_url": f"https://goauthentik.io/{self.user.username}", | ||||
|                         "meta_launch_url": "https://goauthentik.io/%(username)s", | ||||
|                         "open_in_new_tab": True, | ||||
|                         "meta_icon": None, | ||||
|                         "meta_description": "", | ||||
|                         "meta_publisher": "", | ||||
| @ -158,6 +161,7 @@ class TestApplicationsAPI(APITestCase): | ||||
|                         "meta_description": "", | ||||
|                         "meta_icon": None, | ||||
|                         "meta_launch_url": "", | ||||
|                         "open_in_new_tab": False, | ||||
|                         "meta_publisher": "", | ||||
|                         "group": "", | ||||
|                         "name": "denied", | ||||
|  | ||||
		Reference in New Issue
	
	Block a user