Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
switch-wayf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GIP RENATER
switch-wayf
Commits
dc2d3f78
Commit
dc2d3f78
authored
Jul 03, 2018
by
Lukas Haemmerle
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'master'
Master See merge request
aai/SWITCHwayf!7
parents
f0b84613
ee9f796a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
18 deletions
+28
-18
bin/update-metadata.php
bin/update-metadata.php
+28
-18
No files found.
bin/update-metadata.php
View file @
dc2d3f78
...
@@ -18,22 +18,24 @@ Usage
...
@@ -18,22 +18,24 @@ Usage
php update-metadata.php -help|-h
php update-metadata.php -help|-h
php update-metadata.php --metadata-file <file> \
php update-metadata.php --metadata-file <file> \
--metadata-idp-file <file> --metadata-sp-file <file> \
--metadata-idp-file <file> --metadata-sp-file <file> \
[--verbose | -v] [--min-sp-count <count>] [--min-idp-count <count>]
[--verbose | -v] [--min-sp-count <count>] [--min-idp-count <count>] \
[--language <locale>] [--syslog] [--syslog-id <id>]
php update-metadata.php --metadata-url <url> \
php update-metadata.php --metadata-url <url> \
--metadata-idp-file <file> --metadata-sp-file <file> \
--metadata-idp-file <file> --metadata-sp-file <file> \
[--verbose | -v] [--min-sp-count <count>] [--min-idp-count <count>]
[--verbose | -v] [--min-sp-count <count>] [--min-idp-count <count>] \
[--language <locale>] [--syslog] [--syslog-id <id>]
Argument Description
Argument Description
--------------------
--------------------
--metadata-url <url> SAML2 metadata URL
--metadata-url <url> SAML2 metadata URL
--metadata-file <file> SAML2 metadata file
--metadata-file <file> SAML2 metadata file
--metadata-idp-file <file> File containing
Service P
roviders
--metadata-idp-file <file> File containing
service p
roviders
--metadata-sp-file <file> File containing
Identity P
roviders
--metadata-sp-file <file> File containing
identity p
roviders
--min-idp-count <count> Minimum expected number of IdPs in metadata
--min-idp-count <count> Minimum expected number of IdPs in metadata
--min-sp-count <count> Minimum expected number of SPs in metadata
--min-sp-count <count> Minimum expected number of SPs in metadata
--language <locale> Language locale, e.g. 'en', 'jp', ...
--language <locale> Language locale, e.g. 'en', 'jp', ...
--syslog Use syslog for reporting
--syslog Use syslog for reporting
--syslog-
prefix <prefix> Prefix
for syslog messages
--syslog-
id <id> Process identity
for syslog messages
--verbose | -v Verbose mode
--verbose | -v Verbose mode
--help | -h Print this man page
--help | -h Print this man page
...
@@ -56,7 +58,7 @@ $longopts = array(
...
@@ -56,7 +58,7 @@ $longopts = array(
"language:"
,
"language:"
,
"verbose"
,
"verbose"
,
"syslog"
,
"syslog"
,
"syslog-
prefix
:"
,
"syslog-
id
:"
,
"help"
,
"help"
,
);
);
...
@@ -70,7 +72,11 @@ if (isset($options['help']) || isset($options['h'])) {
...
@@ -70,7 +72,11 @@ if (isset($options['help']) || isset($options['h'])) {
$language
=
isset
(
$options
[
'language'
])
?
$options
[
'language'
]
:
'en'
;
$language
=
isset
(
$options
[
'language'
])
?
$options
[
'language'
]
:
'en'
;
$verbose
=
isset
(
$options
[
'verbose'
])
||
isset
(
$options
[
'v'
])
?
true
:
false
;
$verbose
=
isset
(
$options
[
'verbose'
])
||
isset
(
$options
[
'v'
])
?
true
:
false
;
$syslog
=
isset
(
$options
[
'syslog'
])
?
true
:
false
;
$syslog
=
isset
(
$options
[
'syslog'
])
?
true
:
false
;
$prefix
=
isset
(
$options
[
'syslog-prefix'
])
?
$options
[
'syslog-prefix'
]
:
'switchwayf'
;
$syslogId
=
isset
(
$options
[
'syslog-id'
])
?
$options
[
'syslog-id'
]
:
'SWITCHwayf'
;
if
(
$syslog
)
{
openlog
(
$syslogId
,
LOG_NDELAY
,
LOG_USER
);
}
if
(
isset
(
$options
[
'metadata-url'
]))
{
if
(
isset
(
$options
[
'metadata-url'
]))
{
$metadataURL
=
$options
[
'metadata-url'
];
$metadataURL
=
$options
[
'metadata-url'
];
...
@@ -109,7 +115,8 @@ if (isset($options['min-sp-count'])) {
...
@@ -109,7 +115,8 @@ if (isset($options['min-sp-count'])) {
}
elseif
(
preg_match
(
'/^\d+$/'
,
$options
[
'min-sp-count'
]))
{
}
elseif
(
preg_match
(
'/^\d+$/'
,
$options
[
'min-sp-count'
]))
{
$minSPCount
=
$options
[
'min-sp-count'
];
$minSPCount
=
$options
[
'min-sp-count'
];
}
else
{
}
else
{
exit
(
"Exiting: invalid value for --min-sp-count parameter
\n
"
);
reportError
(
"Exiting: invalid value for --min-sp-count parameter
\n
"
);
exit
(
1
);
}
}
}
else
{
}
else
{
$minSPCount
=
0
;
$minSPCount
=
0
;
...
@@ -127,7 +134,8 @@ if (isset($options['min-idp-count'])) {
...
@@ -127,7 +134,8 @@ if (isset($options['min-idp-count'])) {
}
elseif
(
preg_match
(
'/^\d+$/'
,
$options
[
'min-idp-count'
]))
{
}
elseif
(
preg_match
(
'/^\d+$/'
,
$options
[
'min-idp-count'
]))
{
$minIDPCount
=
$options
[
'min-idp-count'
];
$minIDPCount
=
$options
[
'min-idp-count'
];
}
else
{
}
else
{
exit
(
"Exiting: invalid value for --min-idp-count parameter
\n
"
);
reportError
(
"Exiting: invalid value for --min-idp-count parameter
\n
"
);
exit
(
1
);
}
}
}
else
{
}
else
{
$minIDPCount
=
0
;
$minIDPCount
=
0
;
...
@@ -141,7 +149,7 @@ if ($metadataURL) {
...
@@ -141,7 +149,7 @@ if ($metadataURL) {
exit
(
1
);
exit
(
1
);
}
}
if
(
$verbose
)
{
if
(
$verbose
)
{
reportInfo
(
"Downloading metadata f
rom
$metadataURL
to
$metadataFile
\n
"
);
reportInfo
(
"Downloading metadata f
ile from
$metadataURL
\n
"
);
}
}
$result
=
@
copy
(
$metadataURL
,
$metadataFile
);
$result
=
@
copy
(
$metadataURL
,
$metadataFile
);
if
(
!
$result
)
{
if
(
!
$result
)
{
...
@@ -176,12 +184,12 @@ list($metadataIDProviders, $metadataSProviders) = parseMetadata($metadataFile, $
...
@@ -176,12 +184,12 @@ list($metadataIDProviders, $metadataSProviders) = parseMetadata($metadataFile, $
if
(
is_array
(
$metadataIDProviders
)){
if
(
is_array
(
$metadataIDProviders
)){
$IDPCount
=
count
(
$metadataIDProviders
);
$IDPCount
=
count
(
$metadataIDProviders
);
if
(
$IDPCount
<
$minIDPCount
)
{
if
(
$IDPCount
<
$minIDPCount
)
{
reportError
(
"Exiting: number of
Identity P
roviders found (
$IDPCount
) lower than expected (
$minIDPCount
)
\n
"
);
reportError
(
"Exiting: number of
identity p
roviders found (
$IDPCount
) lower than expected (
$minIDPCount
)
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
if
(
$verbose
)
{
if
(
$verbose
)
{
reportInfo
(
"Dumping
$IDPCount
extracted
Identity P
roviders to file
$metadataIDPFile
\n
"
);
reportInfo
(
"Dumping
$IDPCount
extracted
identity p
roviders to file
$metadataIDPFile
\n
"
);
}
}
dumpFile
(
$metadataTempIDPFile
,
$metadataIDProviders
,
'metadataIDProviders'
);
dumpFile
(
$metadataTempIDPFile
,
$metadataIDProviders
,
'metadataIDProviders'
);
...
@@ -195,12 +203,12 @@ if (is_array($metadataIDProviders)){
...
@@ -195,12 +203,12 @@ if (is_array($metadataIDProviders)){
if
(
is_array
(
$metadataSProviders
)){
if
(
is_array
(
$metadataSProviders
)){
$SPCount
=
count
(
$metadataSProviders
);
$SPCount
=
count
(
$metadataSProviders
);
if
(
$SPCount
<
$minSPCount
)
{
if
(
$SPCount
<
$minSPCount
)
{
reportError
(
"Exiting: number of
Service P
roviders found (
$SPCount
) lower than expected (
$minSPCount
)
\n
"
);
reportError
(
"Exiting: number of
service p
roviders found (
$SPCount
) lower than expected (
$minSPCount
)
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
if
(
$verbose
)
{
if
(
$verbose
)
{
reportInfo
(
"Dumping
$SPCount
extracted
Service P
roviders to file
$metadataSPFile
\n
"
);
reportInfo
(
"Dumping
$SPCount
extracted
service p
roviders to file
$metadataSPFile
\n
"
);
}
}
dumpFile
(
$metadataTempSPFile
,
$metadataSProviders
,
'metadataSProviders'
);
dumpFile
(
$metadataTempSPFile
,
$metadataSProviders
,
'metadataSProviders'
);
...
@@ -221,11 +229,14 @@ if ($metadataURL) {
...
@@ -221,11 +229,14 @@ if ($metadataURL) {
}
}
}
}
if
(
$syslog
)
{
closelog
();
}
function
reportError
(
$message
)
{
function
reportError
(
$message
)
{
global
$syslog
,
$prefix
;
global
$syslog
;
if
(
$syslog
)
{
if
(
$syslog
)
{
openlog
(
$prefix
,
LOG_NDELAY
,
LOG_USER
);
syslog
(
LOG_ERR
,
$message
);
syslog
(
LOG_ERR
,
$message
);
}
else
{
}
else
{
fwrite
(
STDERR
,
$message
);
fwrite
(
STDERR
,
$message
);
...
@@ -233,10 +244,9 @@ function reportError($message) {
...
@@ -233,10 +244,9 @@ function reportError($message) {
}
}
function
reportInfo
(
$message
)
{
function
reportInfo
(
$message
)
{
global
$syslog
,
$prefix
;
global
$syslog
;
if
(
$syslog
)
{
if
(
$syslog
)
{
openlog
(
$prefix
,
LOG_NDELAY
,
LOG_USER
);
syslog
(
LOG_INFO
,
$message
);
syslog
(
LOG_INFO
,
$message
);
}
else
{
}
else
{
fwrite
(
STDOUT
,
$message
);
fwrite
(
STDOUT
,
$message
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment