generated from ddev/ddev-addon-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from rfay/20220605_auto_login
- Loading branch information
Showing
8 changed files
with
144 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#ddev-generated | ||
FROM adminer:standalone | ||
ADD ddev-login.php /var/www/html/plugins-enabled/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
// #ddev-generated | ||
class DDEVLogin { | ||
function loginForm() { | ||
?> | ||
<script type="text/javascript" <?php echo nonce(); ?>> | ||
addEventListener('load', function () { | ||
// Prevent infinite reload loop when auto login failed. | ||
if (document.querySelector('.error')) { | ||
return | ||
} | ||
let dbimage = '<?php echo $_ENV["DDEV_DBIMAGE"] ?>' | ||
// Default driver is mysql ("server"). We don't want to set it if that's the case.dbimage | ||
// The only other currently supported driver is pgsql | ||
if (!dbimage.includes('mariadb') && !dbimage.includes('mysql')) { | ||
document.querySelector('[name="auth[driver]"]').value = "pgsql" | ||
} | ||
document.querySelector('[name="auth[db]"]').value = '<?php echo $_ENV['DDEV_DB_NAME']; ?>' | ||
document.querySelector('[name="auth[username]"]').value = '<?php echo $_ENV['DDEV_DB_USER']; ?>' | ||
document.querySelector('[name="auth[password]"]').value = '<?php echo $_ENV['DDEV_DB_PASS']; ?>' | ||
document.querySelector('[name="auth[permanent]"]:not(:checked)')?.click() | ||
document.querySelector('[type=submit][value=Login]').click() | ||
}); | ||
</script> | ||
<?php | ||
} | ||
} | ||
return new DDEVLogin(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/bash | ||
|
||
#ddev-generated | ||
## Description: Launch a browser with the current site | ||
## Usage: launcha [path] [-a|--adminer] [-p|--phpmyadmin] [-m|--mailhog] | ||
## Example: "ddev launcha" or "ddev launcha /admin/reports/status/php" or "ddev launcha phpinfo.php", for Adminer "ddev launcha -a", MailHog "ddev launch -m" | ||
|
||
FULLURL=${DDEV_PRIMARY_URL} | ||
HTTPS="" | ||
if [ ${DDEV_PRIMARY_URL%://*} = "https" ]; then HTTPS=true; fi | ||
|
||
while :; do | ||
case ${1:-} in | ||
-h|-\?|--help) | ||
show_help | ||
exit | ||
;; | ||
-a|--adminer) | ||
if [ "${HTTPS}" = "" ]; then | ||
FULLURL="${FULLURL%:[0-9]*}:9100" | ||
else | ||
FULLURL="${FULLURL%:[0-9]*}:9101" | ||
fi | ||
;; | ||
-p|--phpmyadmin) | ||
if [ "${HTTPS}" = "" ]; then | ||
FULLURL="${FULLURL%:[0-9]*}:${DDEV_PHPMYADMIN_PORT}" | ||
else | ||
FULLURL="${FULLURL%:[0-9]*}:${DDEV_PHPMYADMIN_HTTPS_PORT}" | ||
fi | ||
;; | ||
-m|--mailhog) | ||
if [ "${HTTPS}" = "" ]; then | ||
FULLURL="${FULLURL%:[0-9]*}:${DDEV_MAILHOG_PORT}" | ||
else | ||
FULLURL="${FULLURL%:[0-9]*}:${DDEV_MAILHOG_HTTPS_PORT}" | ||
fi | ||
;; | ||
|
||
--) # End of all options. | ||
shift | ||
break | ||
;; | ||
-?*) | ||
printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2 | ||
;; | ||
*) # Default case: No more options, so break out of the loop. | ||
break | ||
esac | ||
|
||
shift | ||
done | ||
|
||
if [ -n "${1:-}" ] ; then | ||
if [[ ${1::1} != "/" ]] ; then | ||
FULLURL="${FULLURL}/"; | ||
fi | ||
|
||
FULLURL="${FULLURL}${1}"; | ||
fi | ||
|
||
if [ ! -z ${DDEV_DEBUG:-} ]; then | ||
printf "FULLURL $FULLURL\n" && exit 0 | ||
fi | ||
|
||
case $OSTYPE in | ||
linux-gnu) | ||
xdg-open ${FULLURL} | ||
;; | ||
"darwin"*) | ||
open ${FULLURL} | ||
;; | ||
"win*"* | "msys"*) | ||
start ${FULLURL} | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,28 @@ | ||
#ddev-generated | ||
version: '3.6' | ||
services: | ||
adminer: | ||
container_name: ddev-${DDEV_SITENAME}-adminer | ||
image: adminer:standalone | ||
build: | ||
context: './adminer' | ||
environment: | ||
# Use the line below to change the adminer theme. | ||
# - ADMINER_DESIGN=nette | ||
- ADMINER_DEFAULT_SERVER=ddev-${DDEV_SITENAME}-db | ||
- ADMINER_DEFAULT_SERVER=db | ||
- ADMINER_PLUGINS=tables-filter | ||
- VIRTUAL_HOST=$DDEV_HOSTNAME | ||
- HTTP_EXPOSE=8080:8080 | ||
- HTTP_EXPOSE=9100:8080 | ||
- HTTPS_EXPOSE=9101:8080 | ||
- DDEV_DBIMAGE | ||
- DDEV_DB_NAME=db | ||
- DDEV_DB_USER=db | ||
- DDEV_DB_PASS=db | ||
labels: | ||
com.ddev.site-name: ${DDEV_SITENAME} | ||
com.ddev.approot: $DDEV_APPROOT | ||
depends_on: | ||
- db | ||
|
||
# We do not ship any plugin configuration at the moment, | ||
# but keep this here for future reference. | ||
#volumes: | ||
# - "./adminer:/var/www/html/plugins-enabled" | ||
web: | ||
links: | ||
- adminer:adminer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters