Skip to content

ssl enabled by default #54

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

Merged
merged 2 commits into from
Feb 7, 2025
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})

* Changed builder to enable ssl for proxy urls by default

## v1.4.2 - [February 7, 2025](https://github.com/lando/phpmyadmin/releases/tag/v1.4.2)

* Changed builder to always use latest patch version of `phpmyadmin`
Expand Down
31 changes: 21 additions & 10 deletions builders/phpmyadmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Modules
const _ = require('lodash');
const semver = require('semver');
const setConfigOptions = require('../utils/setConfigOptions');

// Builder
module.exports = {
Expand All @@ -17,17 +18,22 @@ module.exports = {
remoteFiles: {
config: '/etc/phpmyadmin/config.user.inc.php',
},
ssl: true,
sslExpose: false,
},
parent: '_lando',
builder: (parent, config) => class LandoPma extends parent {
constructor(id, options = {}) {
options = _.merge({}, config, options);
parent: '_service',
builder: (parent, optionDefaults) => class LandoPma extends parent {
constructor(id, userConfig = {}) {
// Merge the user config onto the default config
const options = _.merge({}, optionDefaults, userConfig);

// Arrayify the hosts if needed
if (!_.isArray(options.hosts)) options.hosts = [options.hosts];
// Switch to legacy command if needed
if (semver.lt(`${options.version}.0`, '5.0.0')) options.command = '/run.sh phpmyadmin';
// Build the default stuff here
const pma = {

// Assemble the service config
const pmaService = {
image: `phpmyadmin/phpmyadmin:${options.version}`,
environment: {
MYSQL_ROOT_PASSWORD: '',
Expand All @@ -42,10 +48,15 @@ module.exports = {
};
// Add some info
options.info = {backends: options.hosts};
options.ssl = true;
options.sslExpose = false;
// Send it downstream
super(id, options, {services: _.set({}, options.name, pma)});

// Set configuration options for the upstream Lando service
setConfigOptions({
ssl: options.ssl,
sslExpose: options.sslExpose,
}, options._app, options.name);

// Add in the service and push it downstream
super(id, options, {services: _.set({}, options.name, pmaService)});
};
},
};
15 changes: 15 additions & 0 deletions utils/setConfigOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

const _ = require('lodash');

/**
* Sets configuration options for a service
* @param {object} options - The configuration options to set
* @param {object} app - The Lando app object
* @param {string} name - The name of the service
*/
module.exports = (options, app, name) => {
Object.entries(options).forEach(([key, value]) => {
_.set(app, `config.services.${name}.${key}`, value);
});
};
Loading