Giter VIP home page Giter VIP logo

sonata-oauth2-login-bundle's Introduction

silasjoisten/sonata-oauth2-login-bundle

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: 
        [email protected]: ["ROLE_SUPER_ADMIN"]
        [email protected]: ["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

sonata-oauth2-login-bundle's People

Contributors

dependabot[bot] avatar kurt-junker avatar oskarstark avatar silasjoisten avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

sonata-oauth2-login-bundle's Issues

Symfony 5.1 compatibility

Hi,

I tried to update my project from Symfony 4.4 to 5.1 and got the following composer error:

Restricting packages listed in "symfony/symfony" to "5.1.*"
Your requirements could not be resolved to an installable set of packages.

Problem 1
- hwi/oauth-bundle 0.6.3 requires symfony/framework-bundle ^2.8|^3.0|^4.0 -> no matching package found.
- hwi/oauth-bundle 0.6.2 requires symfony/framework-bundle ^2.8|^3.0|^4.0 -> no matching package found.
- hwi/oauth-bundle 0.6.1 requires symfony/framework-bundle ^2.8|^3.0|^4.0 -> no matching package found.
- silasjoisten/sonata-oauth2-login-bundle 4.0.0 requires hwi/oauth-bundle ^0.6.1 -> satisfiable by hwi/oauth-bundle[0.6.1, 0.6.2, 0.6.3].
- Installation request for silasjoisten/sonata-oauth2-login-bundle ^4.0 -> satisfiable by silasjoisten/sonata-oauth2-login-bundle[4.0.0].

Can you please update the hwi/oauth-bundle to a newer version?

Thanks a lot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.