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

Added create, update and delete for auth for subdomains #41

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Added create, update and delete for auth for subdomains #41

wants to merge 1 commit into from

Conversation

geekodour
Copy link

See : https://github.com/rtCamp/sys/issues/176#issuecomment-509517284

This PR attempts to add basic auth add, update and delete support when we create a site with --mu=subdom with ee4.

  • uses the naming convention of *.sitename.tld when app_sub_type is subdom
  • Passes the $site_type variable to generate_site_auth_files for it to use it when deleteing and updating the file.

I am not sure if we still need to have the sitename.tld file in /opt/easyengine/services/nginx-proxy/htpasswd when we already have *.sitename.tld

Additionally, should we do the same for the IP whitelisting?

cc @mrrobot47

Signed-off-by: Hrishikesh Barman [email protected]

* uses the naming convention of '*.sitename.tld' when `app_sub_type` is subdom
* Passes the $site_type variable to `generate_site_auth_files` for it to use it when deleteing and updating the file.

Signed-off-by: Hrishikesh Barman <[email protected]>
@mrrobot47 mrrobot47 self-requested a review July 11, 2019 11:34
$global = $this->populate_info( $args, __FUNCTION__ );
$ips = \EE\Utils\get_flag_value( $assoc_args, 'ip' );
$site_url = $global ? 'default' : $this->site_data->site_url;
$site_type = $global ? 'wp' : $this->site_data->app_sub_type;
Copy link
Member

Choose a reason for hiding this comment

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

Need to consider other site types. html and PHP site types have blank $this->site_data->app_sub_type.
So, only check for app_sub_type when 'wp' === $this->site_data->site_type.


$auth_file_name = '';
switch ( $site_type ) {
case 'wp':
Copy link
Member

Choose a reason for hiding this comment

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

All the same cases can go in one. No need to create a seprate block of subdir, just declare all blocks as in sugesstion. Or better yet, as there is a change in only one type of site, i.e., subdom, you can also convert this to single if-else.

Suggested change
case 'wp':
case 'wp':
case 'subdir':
case 'html':
case 'php':

$auth_file_name = $site_url;
break;
case 'subdom':
$auth_file_name = '*.' . $site_url;
Copy link
Member

@mrrobot47 mrrobot47 Jul 12, 2019

Choose a reason for hiding this comment

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

I am not sure if we still need to have the sitename.tld file in /opt/easyengine/services/nginx-proxy/htpasswd when we already have *.sitename.tld

It is necessary to have both the files.

@mrrobot47
Copy link
Member

Additionally, should we do the same for the IP whitelisting?

Yes, in case of subdom site, create two files:

  1. /opt/easyengine/services/nginx-proxy/vhost.d/sitename.tld_acl
  2. /opt/easyengine/services/nginx-proxy/vhost.d/*.sitename.tld_acl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants