providers/app_gw: separate host field into external_ and internal_
This commit is contained in:
		@ -20,8 +20,10 @@ class ApplicationGatewayProviderForm(forms.ModelForm):
 | 
			
		||||
            "code"
 | 
			
		||||
        )
 | 
			
		||||
        self.instance.client.redirect_uris = [
 | 
			
		||||
            f"http://{self.instance.host}/oauth2/callback",
 | 
			
		||||
            f"https://{self.instance.host}/oauth2/callback",
 | 
			
		||||
            f"http://{self.instance.external_host}/oauth2/callback",
 | 
			
		||||
            f"https://{self.instance.external_host}/oauth2/callback",
 | 
			
		||||
            f"http://{self.instance.internal_host}/oauth2/callback",
 | 
			
		||||
            f"https://{self.instance.internal_host}/oauth2/callback",
 | 
			
		||||
        ]
 | 
			
		||||
        self.instance.client.scope = ["openid", "email"]
 | 
			
		||||
        self.instance.client.save()
 | 
			
		||||
@ -30,8 +32,9 @@ class ApplicationGatewayProviderForm(forms.ModelForm):
 | 
			
		||||
    class Meta:
 | 
			
		||||
 | 
			
		||||
        model = ApplicationGatewayProvider
 | 
			
		||||
        fields = ["name", "host"]
 | 
			
		||||
        fields = ["name", "internal_host", "external_host"]
 | 
			
		||||
        widgets = {
 | 
			
		||||
            "name": forms.TextInput(),
 | 
			
		||||
            "host": forms.TextInput(),
 | 
			
		||||
            "internal_host": forms.TextInput(),
 | 
			
		||||
            "external_host": forms.TextInput(),
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,24 @@
 | 
			
		||||
# Generated by Django 2.2.9 on 2020-01-02 15:05
 | 
			
		||||
 | 
			
		||||
from django.db import migrations, models
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ("passbook_providers_app_gw", "0003_applicationgatewayprovider"),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.RenameField(
 | 
			
		||||
            model_name="applicationgatewayprovider",
 | 
			
		||||
            old_name="host",
 | 
			
		||||
            new_name="external_host",
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name="applicationgatewayprovider",
 | 
			
		||||
            name="internal_host",
 | 
			
		||||
            field=models.TextField(default=""),
 | 
			
		||||
            preserve_default=False,
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
@ -14,7 +14,8 @@ class ApplicationGatewayProvider(Provider):
 | 
			
		||||
    """This provider uses oauth2_proxy with the OIDC Provider."""
 | 
			
		||||
 | 
			
		||||
    name = models.TextField()
 | 
			
		||||
    host = models.TextField()
 | 
			
		||||
    internal_host = models.TextField()
 | 
			
		||||
    external_host = models.TextField()
 | 
			
		||||
 | 
			
		||||
    client = models.ForeignKey(Client, on_delete=models.CASCADE)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -40,10 +40,10 @@ services:
 | 
			
		||||
    environment:
 | 
			
		||||
      OAUTH2_PROXY_CLIENT_ID: {{ provider.client.client_id }}
 | 
			
		||||
      OAUTH2_PROXY_CLIENT_SECRET: {{ provider.client.client_secret }}
 | 
			
		||||
      OAUTH2_PROXY_REDIRECT_URL: https://{{ provider.host }}/oauth2/callback
 | 
			
		||||
      OAUTH2_PROXY_OIDC_ISSUER_URL: https://{{ request.META.host }}/application/oidc
 | 
			
		||||
      OAUTH2_PROXY_REDIRECT_URL: https://{{ provider.external_host }}/oauth2/callback
 | 
			
		||||
      OAUTH2_PROXY_COOKIE_SECRET: {{ cookie_secret }}
 | 
			
		||||
      OAUTH2_PROXY_UPSTREAM: http://{{ provider.host }}</textarea>
 | 
			
		||||
      OAUTH2_PROXY_UPSTREAM: http://{{ provider.internal_host }}</textarea>
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="modal-footer">
 | 
			
		||||
        <button type="button" class="btn btn-primary" data-dismiss="modal">{% trans 'Close' %}</button>
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user