OAuth2EntryPoint   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 21
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A start() 0 8 1
1
<?php
2
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace TH\OAuth2;
13
14
use Symfony\Component\Security\Core\Exception\AuthenticationException;
15
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
16
use Symfony\Component\HttpFoundation\Response;
17
use Symfony\Component\HttpFoundation\Request;
18
19
class OAuth2EntryPoint implements AuthenticationEntryPointInterface
20
{
21
    private $realm;
22
23
    public function __construct($realm)
24
    {
25
        $this->realm = $realm;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function start(Request $request, AuthenticationException $authException = null)
32
    {
33
        $response = new Response();
34
        $response->setStatusCode(401);
35
        $response->headers->set('WWW-Authenticate', 'Bearer realm="'.$this->realm.'"');
36
37
        return $response;
38
    }
39
}
40