Completed
Push — master ( 664783...554f9d )
by
unknown
15:59
created

HeaderFieldStrategy   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 36
ccs 3
cts 7
cp 0.4286
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A apply() 0 4 1
A getRoles() 0 4 1
1
<?php
2
/**
3
 * strategy for validating auth through the x-idp-username header
4
 */
5
6
namespace Graviton\SecurityBundle\Authentication\Strategies;
7
8
use Graviton\SecurityBundle\Entities\SecurityUser;
9
use Symfony\Component\HttpFoundation\Request;
10
use Symfony\Component\Security\Core\Role\Role;
11
12
/**
13
 * Class HeaderFieldStrategy
14
 *
15
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
16
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
17
 * @link     http://swisscom.ch
18
 */
19
class HeaderFieldStrategy extends AbstractHttpStrategy
20
{
21
    /** @var String */
22
    protected $field;
23
24
    /**
25
     * @param String $field field
26
     */
27 4
    public function __construct($field)
28
    {
29 4
        $this->field = $field;
30 4
    }
31
32
    /**
33
     * Applies the defined strategy on the provided request.
34
     * Value may contain a coma separated string values, we use first as identifier.
35
     *
36
     * @param Request $request request to handle
37
     *
38
     * @return string
39
     */
40
    public function apply(Request $request)
41
    {
42
        return $this->extractFieldInfo($request->headers, $this->field);
43
    }
44
45
    /**
46
     * Provides the list of registered roles.
47
     *
48
     * @return Role[]
49
     */
50
    public function getRoles()
51
    {
52
        return [SecurityUser::ROLE_USER];
53
    }
54
}
55