Completed
Pull Request — 0.3.x (#13)
by
unknown
17:33
created

SsoAuthenticationController::logoutUserAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php 
2
namespace Krtv\Bundle\SingleSignOnServiceProviderBundle\Controller;
3
4
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
5
use Symfony\Component\HttpFoundation\Request;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
7
use Symfony\Component\HttpFoundation\RedirectResponse;
8
9
class SsoAuthenticationController extends Controller
10
{
11
    /**
12
     * 
13
     * @param type $request
14
     * @return \Symfony\Component\HttpFoundation\JsonResponse
15
     * @throws type
16
     */
17
    public function authenticateUserAction(Request $request) {
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
18
        /*
19
         * Route called by ajax from other platforms to get user logged in on current platform
20
         */
21
        if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
22
            // if user is not authenticated AccessDeniedException will trigger authentication on IDP 
23
            throw $this->createAccessDeniedException();
24
        }
25
26
        return new \Symfony\Component\HttpFoundation\JsonResponse(['success'=>true]);
27
    }
28
    
29
    /**
30
     * 
31
     * @param Request $request
32
     * @param type $service
33
     * @return RedirectResponse
34
     */
35
    public function logoutUserAction(Request $request, $service) {
36
        /*
37
         * security.yml logut can't accept different domain (IDP) in new symfony so it points here
38
         */
39
        $this->get('security.token_storage')->setToken(null);
40
        $request->getSession()->invalidate();
41
        
42
        return new RedirectResponse($this->getParameter('idp_url') . '/sso/logout?service=' . $service);
43
                
44
    }
45
    
46
}
47