Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
5d00abc4
Commit
5d00abc4
authored
5 years ago
by
Tim van Dijen
Browse files
Options
Downloads
Patches
Plain Diff
Add RedirectionController to core
parent
e09b62f0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/core/config/routes/routes.yaml
+3
-0
3 additions, 0 deletions
modules/core/config/routes/routes.yaml
modules/core/lib/Controller/RedirectionController.php
+108
-0
108 additions, 0 deletions
modules/core/lib/Controller/RedirectionController.php
with
111 additions
and
0 deletions
modules/core/config/routes/routes.yaml
+
3
−
0
View file @
5d00abc4
...
@@ -16,3 +16,6 @@ core-cardinality:
...
@@ -16,3 +16,6 @@ core-cardinality:
core-warning-shortssointerval
:
core-warning-shortssointerval
:
path
:
/warning/short_sso_interval
path
:
/warning/short_sso_interval
defaults
:
{
_controller
:
'
SimpleSAML\Module\core\Controller\ExceptionController:shortSsoInterval'
}
defaults
:
{
_controller
:
'
SimpleSAML\Module\core\Controller\ExceptionController:shortSsoInterval'
}
core-post-redirect
:
path
:
/postredirect
defaults
:
{
_controller
:
'
SimpleSAML\Module\core\Controller\RedirectionController:postredirect'
}
This diff is collapsed.
Click to expand it.
modules/core/lib/Controller/RedirectionController.php
0 → 100644
+
108
−
0
View file @
5d00abc4
<?php
namespace
SimpleSAML\Module\core\Controller
;
use
SimpleSAML\Auth
;
use
SimpleSAML\Configuration
;
use
SimpleSAML\Error
;
use
SimpleSAML\Logger
;
use
SimpleSAML\Module
;
use
SimpleSAML\Session
;
use
SimpleSAML\Utils
;
use
SimpleSAML\XHTML\Template
;
use
Symfony\Component\HttpFoundation\Request
;
/**
* Controller class for the core module.
*
* This class serves the different views available in the module.
*
* @package SimpleSAML\Module\core
*/
class
RedirectionController
{
/** @var \SimpleSAML\Configuration */
protected
$config
;
/** @var \SimpleSAML\Session */
protected
$session
;
/**
* Controller constructor.
*
* It initializes the global configuration and auth source configuration for the controllers implemented here.
*
* @param \SimpleSAML\Configuration $config The configuration to use by the controllers.
* @param \SimpleSAML\Session $session The session to use by the controllers.
*
* @throws \Exception
*/
public
function
__construct
(
Configuration
$config
,
Session
$session
)
{
$this
->
config
=
$config
;
$this
->
session
=
$session
;
}
/**
* This controller provides a way to create a redirect to a POST request
*
* @param Request $request The request that lead to this login operation.
* @throws \SimpleSAML\Error\BadRequest
* @return \SimpleSAML\XHTML\Template|\Symfony\Component\HttpFoundation\RedirectResponse
* An HTML template or a redirection if we are not authenticated.
*/
public
function
postredirect
(
Request
$request
)
{
$redirId
=
$request
->
get
(
'RedirId'
,
false
);
$redirInfo
=
$request
->
get
(
'RedirInfo'
,
false
);
if
(
$redirId
!==
false
)
{
$postId
=
$redirId
;
}
elseif
(
$redirInfo
!==
false
)
{
$encData
=
base64_decode
(
$redirInfo
);
if
(
empty
(
$encData
))
{
throw
new
Error\BadRequest
(
'Invalid RedirInfo data.'
);
}
list
(
$sessionId
,
$postId
)
=
explode
(
':'
,
\SimpleSAML\Utils\Crypto
::
aesDecrypt
(
$encData
));
if
(
empty
(
$sessionId
)
||
empty
(
$postId
))
{
throw
new
Error\BadRequest
(
'Invalid session info data.'
);
}
}
else
{
throw
new
Error\BadRequest
(
'Missing redirection info parameter.'
);
}
$session
=
$this
->
session
;
if
(
$session
===
null
)
{
throw
new
\Exception
(
'Unable to load session.'
);
}
$postData
=
$session
->
getData
(
'core_postdatalink'
,
$postId
);
if
(
$postData
===
null
)
{
// The post data is missing, probably because it timed out
throw
new
\Exception
(
'The POST data we should restore was lost.'
);
}
$session
->
deleteData
(
'core_postdatalink'
,
$postId
);
assert
(
is_array
(
$postData
));
assert
(
array_key_exists
(
'url'
,
$postData
));
assert
(
array_key_exists
(
'post'
,
$postData
));
if
(
!
Utils\HTTP
::
isValidURL
(
$postData
[
'url'
]))
{
throw
new
Error\Exception
(
'Invalid destination URL.'
);
}
$t
=
new
Template
(
$this
->
config
,
'post.php'
);
$t
->
data
[
'destination'
]
=
$postData
[
'url'
];
$t
->
data
[
'post'
]
=
$postData
[
'post'
];
return
$t
;
}
}
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