Completed
Push — master ( d2b147...d8f226 )
by Terrence
12:00
created

index-functions.php ➔ redirectToTestIdP()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 4
nop 1
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file contains functions called by index.php. The index.php
5
 * file should include this file with the following statement at the top:
6
 *
7
 * require_once __DIR__ . '/index-functions.php';
8
 */
9
10
use CILogon\Service\Util;
11
use CILogon\Service\Content;
12
13
/**
14
 * printLogonPage
15
 *
16
 * This function prints out the HTML for the IdP Selector page.
17
 * Explanatory text is shown as well as a button to log in to an IdP
18
 * and get rerouted to the Shibboleth protected testidp script.
19
 *
20
 * @param bool $clearcookies True if the Shibboleth cookies and session
21
 *        variables  should be cleared out before displaying the page.
22
 *        Defaults to false.
23
 */
24
function printLogonPage($clearcookies = false)
0 ignored issues
show
Best Practice introduced by
The function printLogonPage() has been defined more than once; this definition is ignored, only the first definition in authorize/index-functions.php (L22-118) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
25
{
26
    Util::setSessionVar('cilogon_skin', 'orcidfirst');
27
    Util::getSkin();
28
    if ($clearcookies) {
29
        Util::removeShibCookies();
30
        Util::unsetAllUserSessionVars();
31
    }
32
33
    Util::setSessionVar('stage', 'logon'); // For Show/Hide Help button clicks
34
35
    Content::printHeader('Test Your Identity Provider With CILogon');
36
37
    echo '
38
    <div class="boxed">
39
    ';
40
41
    Content::printHelpButton();
42
43
    echo '
44
      <br />
45
      <p>
46
      To test that your identity provider works with CILogon, please select
47
      it from the list below and Log On.
48
      </p>
49
    ';
50
51
    Content::printWAYF(false);
52
53
    echo '
54
    </div> <!-- End boxed -->
55
    ';
56
    Content::printFooter();
57
}
58
59
/**
60
 * printMainPage
61
 *
62
 * This function prints the user attributes and IdP metadata after the user 
63
 * has logged on.
64
 */
65
function printMainPage()
0 ignored issues
show
Best Practice introduced by
The function printMainPage() has been defined more than once; this definition is ignored, only the first definition in authorize/index-functions.php (L189-286) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
66
{
67
    // If the 'idp' PHP session variable isn't set, then force the user to 
68
    // start over by logging in again.
69
    $idp = Util::getSessionVar('idp');
70
    if (empty($idp)) {
71
        printLogonPage(true);
0 ignored issues
show
Unused Code introduced by
The call to printLogonPage() has too many arguments starting with true.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
72
        exit; // No further processing necessary
73
    }
74
75
    Util::setSessionVar('stage', 'main'); // For Show/Hide Help button clicks
76
77
    Content::printHeader('Test Identity Provider');
78
    Content::printPageHeader('Test Your Organization\'s Identity Provider');
79
80
    // CIL-626 Allow browser 'reload page' by adding CSRF to the PHP session
81
    Util::setSessionVar('submit', 'Proceed');
82
    Util::getCsrf()->setTheSession();
83
84
    echo '
85
    <div class="boxed">
86
    ';
87
88
    echo '
89
    <div class="boxed">
90
      <div class="boxheader">
91
        Verify SAML Attribute Release Policy
92
      </div>
93
94
    <p>
95
    Thank you for your interest in the CILogon Service. This page allows
96
    the administrator of an Identity Provider (<acronym
97
    title="Identity Provider">IdP</acronym>) to verify that all necessary
98
    SAML attributes have been released to the CILogon Service Provider
99
    (<acronym title="Service Provider">SP</acronym>). Below you will see
100
    the various attributes required by the CILogon Service and their values
101
    as released by your IdP.
102
    </p>
103
104
    <div class="summary">
105
    <h2>Summary</h2>
106
    ';
107
108
    $gotattrs = Util::gotUserAttributes();
0 ignored issues
show
Bug introduced by
The method gotUserAttributes() does not seem to exist on object<CILogon\Service\Util>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
109
110
    if ($gotattrs) {
111
        echo '<div class="icon">';
112
        Content::printIcon('okay');
113
        echo '
114
        </div>
115
        <div class="summarytext">
116
        <p>
117
        All required attributes have been released by your <acronym
118
        title="Identity Provider">IdP</acronym>. For details of the various
119
        attributes utilized by the CILogon Service and their current values,
120
        see the sections below.
121
        </p>
122
        <p class="addsubmit">
123
        <a href="/">Proceed to the CILogon Service</a>
124
        </p>
125
        <p class="addsubmit">
126
        <a href="/logout">Logout</a>
127
        </p>
128
        </div>
129
        ';
130
    } else {
131
        echo '<div class="icon">';
132
        Content::printIcon('error', 'Missing one or more attributes.');
133
        echo '
134
        </div>
135
        <div class="summarytext">
136
        <p>
137
        One or more of the attributes required by the CILogon Service are
138
        not available. Please see the sections below for details. Contact
139
        <a href="mailto:[email protected]">help&nbsp;@&nbsp;cilogon.org</a>
140
        for additional information and assistance.
141
        </p>
142
        </div>
143
        ';
144
    }
145
146
    echo '
147
    </div> <!-- summary -->
148
149
    <noscript>
150
    <div class="nojs">
151
    Javascript is disabled. In order to expand or collapse the sections
152
    below, please enable Javascript in your browser.
153
    </div>
154
    </noscript>
155
    ';
156
157
    Content::printUserAttributes();
0 ignored issues
show
Bug introduced by
The method printUserAttributes() does not seem to exist on object<CILogon\Service\Content>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
158
    Content::printIdPMetadata();
0 ignored issues
show
Bug introduced by
The method printIdPMetadata() does not seem to exist on object<CILogon\Service\Content>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
159
160
    echo '
161
    </div> <!-- End boxed -->
162
    ';
163
    Content::printFooter();
164
}
165