componentk/shopware6-admin-auto-login

Designed for developer environment Shopware 6 only. Just auto logs in using the default admin user/pass

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:shopware-platform-plugin

pkg:composer/componentk/shopware6-admin-auto-login

1.0.1 2025-11-03 17:39 UTC

This package is auto-updated.

Last update: 2025-12-03 17:46:40 UTC


README

Auto‑login override for the Shopware 6 Administration login page, intended for local development only.

What It Does

  • On GET to the admin path (e.g. /admin), requests an OAuth token using the default credentials admin / shopware.
  • Writes a bearerAuth cookie (root path and admin path) and redirects to the Administration dashboard.
  • If a valid bearerAuth cookie already exists, it does nothing.
  • Provides an API endpoint /api/_action/ckou-auto-login for manual authentication (useful with admin watcher).

Requirements

  • Shopware >= 6.7.0.
  • An admin user with username admin and password shopware in your dev environment.
  • APP_URL environment variable set to your base URL (defaults to http://localhost:8000).

Install & Activate

  • Copy this plugin to custom/plugins/CKOUAdminAutoLogin.
  • Run: bin/console plugin:refresh
  • Activate: bin/console plugin:install --activate CKOUAdminAutoLogin

Usage

The plugin provides seamless auto-login for both standard admin access and the admin watcher (Vite dev server).

Recommended Workflow (Admin Watcher)

The plugin automatically handles everything! Just use port 8000 URLs:

Simple access:

http://localhost:8000/admin
→ Auto-login
→ Detects watcher running
→ Redirects to http://localhost:5173/#/sw/dashboard/index

Deep links (hash/path preserved):

http://localhost:8000/admin#/sw/customer/detail/019a24bdea5d71158ac12e3f9ef465be/documents?edit=false
→ Auto-login + cookies set
→ Redirects to http://localhost:5173/#/sw/customer/detail/019a24bdea5d71158ac12e3f9ef465be/documents?edit=false
→ Exact page loaded with authentication

Pro tip: Bookmark your favorite admin URLs as localhost:8000/admin#/path and they'll automatically redirect to the watcher!

Direct Watcher Access (After First Visit)

Once you've visited localhost:8000/admin once in your browser session, you can use watcher URLs directly:

  • http://localhost:5173/#/sw/customer/... works immediately
  • Cookies persist across both ports
  • No need to go through localhost:8000 again until cookies expire

Standard Admin (No Watcher)

If the admin watcher is not running, the plugin works as a simple auto-login:

  • Navigate to http://localhost:8000/admin
  • Automatically logged in and redirected to dashboard

How It Works

Simple and clean pure PHP backend approach:

  1. Intercepts /admin Requests:

    • Listens for GET requests to /admin path
    • Issues OAuth tokens using admin / shopware credentials
    • Sets bearerAuth cookies for localhost domain (works on all ports)
  2. Admin Watcher Detection:

    • Reads ADMIN_PORT environment variable (defaults to 5173)
    • Tests if admin watcher is running by checking port accessibility
    • If detected, generates HTML redirect; otherwise, standard HTTP redirect
  3. Hash Preservation:

    • Uses client-side JavaScript to read window.location.hash
    • Redirects to watcher URL with hash intact
    • Deep links work perfectly: localhost:8000/admin#/sw/customer/...localhost:5173/#/sw/customer/...
  4. Cookie Compatibility:

    • SameSite=LAX allows cookies across different ports
    • Once set, cookies persist for both :8000 and :5173
    • No additional API calls or user action required

Safety Note

  • This plugin is for development only. Do not use in production.

Uninstall

  • bin/console plugin:uninstall CKOUAdminAutoLogin

License

  • MIT. See LICENSE file.
  • generated with AI assistance.