forked from FSD-Christian-ADM/MantisOIDC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MantisOIDC.php
118 lines (92 loc) · 3.66 KB
/
MantisOIDC.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
class MantisOIDCPlugin extends MantisPlugin {
var $cmv_pages;
var $current_page;
function register() {
$this->name = 'Mantis OpenID-Connect';
$this->description = 'Add OpenID-Connect authentication to MantisBT. Fork of GoogleOauth plugin by Alleen Wang wchwch@gmail.com';
$this->page = 'config';
$this->version = '0.9';
$this->requires = array(
'MantisCore' => '2.0.0',
);
$this->author = 'FSD-Christian-ADM';
$this->contact = '13xisw13yl2@fsd-web.de';
$this->url = 'https://github.com/FSD-Christian-ADM/MantisOIDC';
}
function init() {
$this->cmv_pages = array(
'login_page.php',
'login_password_page.php'
);
$this->current_page = basename( $_SERVER['PHP_SELF'] );
}
function hooks() {
return array(
'EVENT_LAYOUT_RESOURCES' => 'resources'
);
}
function config() {
return array(
'clientId' => '',
'clientSecret' => '',
'redirect_uri' => '', # is set once the config page is saved
);
}
function resources() {
if (!in_array($this->current_page, $this->cmv_pages)) {
return '';
}
if ("true" == plugin_config_get('auto_login', FALSE)) {
print_header_redirect(plugin_page('oidcStart'));
} else {
$injected_code = '
<meta name="oidcStart" content="'.plugin_page('oidcStart').'" />
<style>
#plugin_mantisoidc_separator {
display: flex;
align-items: center;
text-align: center;
margin-block: 1rem;;
color: #889;
}
#plugin_mantisoidc_separator::before,
#plugin_mantisoidc_separator::after {
content: "";
flex: 1;
border-bottom: 1px solid #889;
}
#plugin_mantisoidc_separator:not(:empty)::before {
margin-right: .25em;
}
#plugin_mantisoidc_separator:not(:empty)::after {
margin-left: .25em;
}
#plugin_mantisoidc_login_button {
background-color: #008aaa;
color: white;
display:grid;
padding: 1rem;
padding-left: 2rem;
border-radius: 5rem;
place-items: center;
font-size: 110%;
}
#plugin_mantisoidc_login_button::before {
content:"'.plugin_config_get('login_button_text', plugin_lang_get('login_button_default')).'";
}
#plugin_mantisoidc_login_button:hover {
text-decoration: none;
background-color: #006888;
}
</style>
<script type="text/javascript">
var plugin_MantisOIDC_seperator_text = "'.plugin_lang_get('seperator_text').'"
var hide_credentials_login = '.plugin_config_get('hide_credentials_login', 'false').';
</script>
<script type="text/javascript" src="'.plugin_file("plugin.js").'"></script>
';
return $injected_code;
}
}
}