componentk/shopware6-admin-auto-login 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

componentk/shopware6-admin-auto-login

最新稳定版本:1.0.1

Composer 安装命令:

composer require componentk/shopware6-admin-auto-login

包简介

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

README 文档

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.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-30