定制 silasjoisten/sonata-oauth2-login-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

silasjoisten/sonata-oauth2-login-bundle

最新稳定版本:6.1.0

Composer 安装命令:

composer require silasjoisten/sonata-oauth2-login-bundle

包简介

Login via Google with Email Validation in a Sonata Project

README 文档

README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Installation

composer require silasjoisten/sonata-oauth2-login-bundle

Register the Bundle in app/AppKernel.php:

 class AppKernel extends Kernel { public function registerBundles() { // .. new Http\HttplugBundle\HttplugBundle(), new HWI\Bundle\OAuthBundle\HWIOAuthBundle(), new SilasJoisten\Sonata\Oauth2LoginBundle\SonataOauth2LoginBundle(), // .. } // .. }

Configuration

Include the Routing:

SonataOauth2LoginBundle: resource: "@SonataOauth2LoginBundle/Resources/config/routing.xml"

Configure the Bundle:

sonata_oauth2_login: valid_email_domains: ["@your-domain.com"] default_user_roles: ["ROLE_SONATA_ADMIN"] #optional value custom_emails: test@example.com: ["ROLE_SUPER_ADMIN"] test2@example.de: ["ROLE_SONATA_ADMIN"]

You can add as much valid domains as you want

Configure the HWIOauthBundle:

# app/config/security.yml security: providers: hwi: id: sonata_oauth2_login.user.provider #... firewalls: YOUR_FIREWALL: #pattern: /admin(.*) REMOVE THIS LINE IF YOU ARE USING SONATA ADMIN oauth: resource_owners: google: "/login/check-google" login_path: /admin/login # For Sonata Admin use_forward: false default_target_path: /admin/dashboard # For Sonata Admin failure_path: /admin/login # For Sonata Admin oauth_user_provider: service: sonata_oauth2_login.user.provider
# app/config/config.yml hwi_oauth: firewall_names: [YOUR_FIREWALL] resource_owners: google: type: "google" client_id: "YOUR_CLIENT_ID" client_secret: "YOUR_CLIENT_SECRET" scope: "email profile" options: csrf: true access_type: offline

Usage

To use the OAuth2 login you just need to call the Twig function to render the button in your login template like this:

{{ render_login_button() }}

Optional: You can pass an array inside to to set custom class and value

Look and Feel

Look and Feel

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固