PHP code example of icedevelop / authentication-bundle

1. Go to this page and download the library: Download icedevelop/authentication-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

icedevelop / authentication-bundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new retItalia\AuthenticationBundle\retItaliaAuthenticationBundle(),
            new KnpU\OAuth2ClientBundle\KnpUOAuth2ClientBundle(),
        );

        // ...
    }

    // ...
}

	main:
            anonymous: ~
            logout:
              path:   /logout
              target: /
            guard:
              authenticators:
                - authenticator

	providers:
		dbal:
		  entity:
		      class: retItaliaAuthenticationBundle:SaUtente
		      property: idUtente

	providers:
		dbal:
		  entity:
		      class: retItaliaAuthenticationBundle:SaUtente
		      property: idUtente

        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/authentication, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/non-autorizzato, roles: IS_AUTHENTICATED_ANONYMOUSLY }

        role_hierarchy:
            ROLE_ADMIN:       ROLE_USER
            ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

	ret_italia_authentication:
	    resource: "@retItaliaAuthenticationBundle/Controller/"
	    type:     annotation
	    prefix:   /


//..
twig:
    debug: '%kernel.debug%'
    strict_variables: '%kernel.debug%'
    globals:
        # the value is the service's id
//..
        userAuthorizedFunctions: "@userAuthorizedFunctions"
//..
//..
# Doctrine Configuration
doctrine:
    dbal:
        connections:
            bdc:
                driver: '%bdc_driver%'
                host: '%bdc_host%'
                port: '%bdc_port%'
                dbname: '%bdc_name%'
                user: '%bdc_user%'
                password: '%bdc_password%'
                charset: UTF8
//..	
knpu_oauth2_client:
    clients:
      # will create service: "knpu.oauth2.client.google"
      # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\GoogleClient
      # composer 

parameters:
    bdc_host: <bdc server>
    bdc_port: <bdc port>
    bdc_name: <bdc name>
    bdc_user: <bdc user>
    bdc_password: <bdc password>
    bdc_driver: oci8
//..
    google_client_id: '<google_client_id>'
    google_client_secret: '<google_client_secret>'
    google_redirect_url: '<google_redirect_url>'
    application_id: <application_id>

scope_auth: ['<application-1>','<application-2>']

scope_auth: []

if ($this->get('userAuthorizedFunctions')->isFunctionAuthorized(<functionId>)
{
}
else
{
}

if ($this->get('userAuthorizedFunctions')->hasRole(<roleId>)
{
}
else
{
}