Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eduGAIN Technical Site
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
edugain
eduGAIN OT
eduGAIN Technical Site
Commits
1978886b
Commit
1978886b
authored
1 year ago
by
Maja Górecka-Wolniewicz
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into 'master'
Validator-dockerized See merge request
!4
parents
4711c41b
05c760e2
No related branches found
No related tags found
1 merge request
!4
Validator-dockerized
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/config-template.php
+1
-2
1 addition, 2 deletions
lib/config-template.php
lib/validatorClass.php
+17
-68
17 additions, 68 deletions
lib/validatorClass.php
with
18 additions
and
70 deletions
lib/config-template.php
+
1
−
2
View file @
1978886b
...
...
@@ -17,8 +17,7 @@ define('DB_HOST','localhost');
define
(
'DB_DATABASE'
,
'edugain'
);
// Validator locations
define
(
'VALIDATOR_SCRIPTS'
,
'/srv/edugain.config/validator_scripts'
);
define
(
'VALIDATOR_SCHEMAS_LOG'
,
'/srv/edugain.config/validator_scripts/logs'
);
define
(
'VALIDATOR_REQ'
,
'http://localhost:5000/validate?r='
);
define
(
'VALIDATOR_TMP'
,
'/srv/edugain.config/mds/tmp'
);
// details of simpleSAMLphp for management login
...
...
This diff is collapsed.
Click to expand it.
lib/validatorClass.php
+
17
−
68
View file @
1978886b
<?php
class
Validator
{
public
$params
;
private
$validatordir
;
private
$edugain
;
private
$logger
;
public
function
__construct
(
$params
=
array
())
{
$this
->
validatordir
=
VALIDATOR_SCRIPTS
;
if
(
empty
(
$params
))
{
$this
->
params
=
array
(
'url'
=>
''
,
...
...
@@ -280,84 +278,35 @@ class Validator {
public
function
checkmetadata
()
{
$params
=
$this
->
params
;
$schres
=
0
;
$certidx
=
-
1
;
$certidx
=
0
;
if
(
(
$params
[
'validate'
]
||
$params
[
'entities'
])
&&
(
$params
[
'url'
]
!=
""
)
)
{
$ret
=
$this
->
get_data
();
if
(
$ret
[
0
]
==
304
)
{
$result
=
array
();
$result
[
'global'
][
'required'
][
'passed'
]
=
array
();
$result
[
'global'
][
'required'
][
'failed'
]
=
array
();
$result
[
'global'
][
'required'
][
'code'
][]
=
304
;
$result
[
'global'
][
'recommended'
][
'passed'
]
=
array
();
$result
[
'global'
][
'recommended'
][
'failed'
]
=
array
();
$result
[
'entities'
]
=
array
();
$result
[
'sources'
]
=
$params
[
'url'
];
$f
=
fopen
(
$this
->
params
[
'filename'
],
'w'
);
fputs
(
$f
,
json_encode
(
$result
));
fclose
(
$f
);
$res
=
$schres
=
304
;
$printres
=
"<div class='noticeerr'>URL fetching failed<br></div>"
;
}
elseif
(
$ret
[
0
]
>
0
)
{
$result
=
array
();
$result
[
'global'
][
'required'
][
'passed'
]
=
array
();
$result
[
'global'
][
'required'
][
'failed'
][]
=
$ret
[
1
];
$result
[
'global'
][
'required'
][
'code'
][]
=
14
;
$result
[
'global'
][
'recommended'
][
'passed'
]
=
array
();
$result
[
'global'
][
'recommended'
][
'failed'
]
=
array
();
$result
[
'entities'
]
=
array
();
$result
[
'sources'
]
=
$url
;
$f
=
fopen
(
$params
[
'filename'
],
'w'
);
fputs
(
$f
,
json_encode
(
$result
));
fclose
(
$f
);
$res
=
$schres
=
14
;
$aggres
=
0
;
$pyffres
=
0
;
$printres
=
"<div class='noticeerr'>URL fetching failed<br>"
.
$ret
[
1
]
.
'</div>'
;
}
elseif
(
$ret
[
0
]
==
0
)
{
$f
=
fopen
(
$params
[
'filename'
]
.
'-metadata.xml'
,
'w'
);
fputs
(
$f
,
$ret
[
1
]);
fclose
(
$f
);
$aggres
=
0
;
$pyffres
=
0
;
$args
=
"
\"
"
.
$params
[
'url'
]
.
"
\"
\"
"
.
$params
[
'regauth'
]
.
"
\"
"
.
$params
[
'filename'
]
.
"
\"
"
.
$params
[
'langsetting'
]
.
"
\"
"
.
$params
[
'validate'
]
.
" "
.
$params
[
'onlyone'
]
.
" "
.
$params
[
'weakkeys'
]
.
" "
.
$params
[
'xmlout'
]
.
" "
.
$params
[
'edugain'
]
.
" "
.
base64_encode
(
$params
[
'fedname'
]);
system
(
$this
->
validatordir
.
"/schemas.py
$args
"
,
$schres
);
if
(
$params
[
'onlyone'
]
&&
!
$schres
)
{
$params
[
'onlyone'
]
=
0
;
unset
(
$_REQUEST
[
'oneentity'
]);
$this
->
params
[
'feed'
]
=
substr
(
$this
->
params
[
'filename'
],
strrpos
(
$this
->
params
[
'filename'
],
'/'
)
+
1
);
$this
->
params
[
'fedname'
]
=
base64_encode
(
$this
->
params
[
'fedname'
]);
$f
=
fopen
(
$this
->
params
[
'filename'
]
.
'-params.json'
,
'w'
);
fputs
(
$f
,
json_encode
(
$this
->
params
));
fclose
(
$f
);
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
VALIDATOR_REQ
.
$this
->
params
[
'feed'
]);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
$response
=
curl_exec
(
$ch
);
if
(
file_exists
(
$params
[
'filename'
]
.
'-result'
))
{
$printres
=
file_get_contents
(
$params
[
'filename'
]
.
'-result'
);
}
else
{
$printres
=
'<b>A problem occured.</b><p>Please let us know: <a href="mailto:edugain-ot@lists.geant.org">edugain-ot@lists.geant.org</a>'
;
$printres
=
'<p>'
.
$params
[
'filename'
]
.
'-result'
;
}
if
(
$params
[
'validate'
]
&&
!
$params
[
'onlyone'
]
&&
(
$schres
<
2
))
{
if
(
$params
[
'edugain'
]
||
$params
[
'gobetween'
])
$fromdb
=
1
;
else
$fromdb
=
0
;
system
(
$this
->
validatordir
.
"/aggregator.py "
.
$params
[
'filename'
]
.
"
$schres
$fromdb
>"
.
$params
[
'filename'
]
.
"-aggregator.log 2>&1"
,
$aggres
);
$certidx
=
trim
(
file_get_contents
(
$params
[
'filename'
]
.
"-aggregator.log"
));
if
(
$certidx
==
''
)
{
$certidx
=
0
;
}
system
(
$this
->
validatordir
.
"/mda.sh --verbose "
.
$params
[
'filename'
]
.
".xml main > "
.
$params
[
'filename'
]
.
"-mda.log 2>&1"
,
$res
);
$searchfor
=
"Unable to validate signature"
;
$matches
=
array
();
$handle
=
@
fopen
(
$params
[
'filename'
]
.
"-mda.log"
,
"r"
);
if
(
$handle
)
{
while
(
!
feof
(
$handle
))
{
$buffer
=
fgets
(
$handle
);
if
(
strpos
(
$buffer
,
$searchfor
)
!==
FALSE
)
{
$matches
[]
=
$buffer
;
break
;
}
}
fclose
(
$handle
);
}
if
(
count
(
$matches
))
{
system
(
$this
->
validatordir
.
"/aggregator.py "
.
$params
[
'filename'
]
.
"
$schres
$fromdb
1 >"
.
$params
[
'filename'
]
.
"-aggregator2.log 2>&1"
,
$aggres
);
system
(
$this
->
validatordir
.
"/mda.sh --verbose "
.
$params
[
'filename'
]
.
"_1.xml main > "
.
$params
[
'filename'
]
.
"-mda.log 2>&1"
,
$res
);
$certidx
=
trim
(
file_get_contents
(
$params
[
'filename'
]
.
"-aggregator2.log"
));
if
(
$certidx
==
''
)
{
$certidx
=
1
;
}
}
system
(
$this
->
validatordir
.
"/pyff.sh "
.
$params
[
'filename'
]
.
'>'
.
$params
[
'filename'
]
.
"-pyff.log 2>&1"
,
$pyffres
);
}
else
$res
=
$schres
;
}
$args
=
$params
[
'filename'
]
.
"
\"
"
.
$params
[
'langsetting'
]
.
"
\"
"
.
$params
[
'validate'
]
.
" "
.
$params
[
'onlyone'
]
.
" "
.
$params
[
'xmlout'
]
.
" "
.
$params
[
'gobetween'
]
.
" "
.
$params
[
'edugain'
];
$printres
=
shell_exec
(
$this
->
validatordir
.
"/printresults.py
$args
$res
$schres
$aggres
$pyffres
$certidx
"
);
}
else
$printres
=
"<span class='noticeerr'>URL fetching failed "
.
$ret
[
1
]
.
"</span>"
;
if
(
!
$params
[
'gobetween'
])
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment