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
e09b62f0
Commit
e09b62f0
authored
5 years ago
by
Tim van Dijen
Browse files
Options
Downloads
Patches
Plain Diff
Add ExceptionController to the core-module
parent
5ace1db2
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
+9
-0
9 additions, 0 deletions
modules/core/config/routes/routes.yaml
modules/core/lib/Controller/ExceptionController.php
+157
-0
157 additions, 0 deletions
modules/core/lib/Controller/ExceptionController.php
with
166 additions
and
0 deletions
modules/core/config/routes/routes.yaml
+
9
−
0
View file @
e09b62f0
...
...
@@ -7,3 +7,12 @@ core-account:
core-logout
:
path
:
/logout/{as}
defaults
:
{
_controller
:
'
SimpleSAML\Module\core\Controller\LoginController:logout'
}
core-error-nocookie
:
path
:
/error/nocookie
defaults
:
{
_controller
:
'
SimpleSAML\Module\core\Controller\ExceptionController:nocookie'
}
core-cardinality
:
path
:
/error/cardinality
defaults
:
{
_controller
:
'
SimpleSAML\Module\core\Controller\ExceptionController:cardinality'
}
core-warning-shortssointerval
:
path
:
/warning/short_sso_interval
defaults
:
{
_controller
:
'
SimpleSAML\Module\core\Controller\ExceptionController:shortSsoInterval'
}
This diff is collapsed.
Click to expand it.
modules/core/lib/Controller/ExceptionController.php
0 → 100644
+
157
−
0
View file @
e09b62f0
<?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
ExceptionController
{
/** @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
;
}
/**
* Show cardinality error.
*
* @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
cardinality
(
Request
$request
)
{
$stateId
=
$request
->
get
(
'StateId'
,
false
);
if
(
$stateId
===
false
)
{
throw
new
Error\BadRequest
(
'Missing required StateId query parameter.'
);
}
/** @var array $state */
$state
=
Auth\State
::
loadState
(
$stateId
,
'core:cardinality'
);
Logger
::
stats
(
'core:cardinality:error '
.
$state
[
'Destination'
][
'entityid'
]
.
' '
.
$state
[
'saml:sp:IdP'
]
.
' '
.
implode
(
','
,
array_keys
(
$state
[
'core:cardinality:errorAttributes'
]))
);
$t
=
new
Template
(
$this
->
config
,
'core:cardinality_error.tpl.php'
);
$t
->
data
[
'cardinalityErrorAttributes'
]
=
$state
[
'core:cardinality:errorAttributes'
];
if
(
isset
(
$state
[
'Source'
][
'auth'
]))
{
$t
->
data
[
'LogoutURL'
]
=
Module
::
getModuleURL
(
'core/authenticate.php'
,
[
'as'
=>
$state
[
'Source'
][
'auth'
]]
)
.
"&logout"
;
}
$t
->
setStatusCode
(
403
);
return
$t
;
}
/**
* Show missing cookie error.
*
* @param Request $request The request that lead to this login operation.
* @return \SimpleSAML\XHTML\Template|\Symfony\Component\HttpFoundation\RedirectResponse
* An HTML template or a redirection if we are not authenticated.
*/
public
function
nocookie
(
Request
$request
)
{
$retryURL
=
$request
->
get
(
'retryURL'
,
null
);
if
(
$retryURL
!==
null
)
{
$retryURL
=
Utils\HTTP
::
checkURLAllowed
(
strval
(
$retryURL
));
}
$t
=
new
Template
(
$this
->
config
,
'core:no_cookie.tpl.php'
);
$translator
=
$t
->
getTranslator
();
/** @var string $header */
$header
=
$translator
->
t
(
'{core:no_cookie:header}'
);
/** @var string $desc */
$desc
=
$translator
->
t
(
'{core:no_cookie:description}'
);
/** @var string $retry */
$retry
=
$translator
->
t
(
'{core:no_cookie:retry}'
);
$t
->
data
[
'header'
]
=
htmlspecialchars
(
$header
);
$t
->
data
[
'description'
]
=
htmlspecialchars
(
$desc
);
$t
->
data
[
'retry'
]
=
htmlspecialchars
(
$retry
);
$t
->
data
[
'retryURL'
]
=
$retryURL
;
return
$t
;
}
/**
* Show a warning to an user about the SP requesting SSO a short time after
* doing it previously.
*
* @param Request $request The request that lead to this login operation.
*
* @return \SimpleSAML\XHTML\Template|\SimpleSAML\HTTP\RunnableResponse|\Symfony\Component\HttpFoundation\RedirectResponse
* An HTML template, a redirect or a "runnable" response.
*
* @throws \SimpleSAML\Error\BadRequest
*/
public
function
shortSsoInterval
(
Request
$request
)
{
$stateId
=
$request
->
get
(
'StateId'
,
false
);
if
(
$stateId
===
false
)
{
throw
new
Error\BadRequest
(
'Missing required StateId query parameter.'
);
}
/** @var array $state */
$state
=
Auth\State
::
loadState
(
$stateId
,
'core:short_sso_interval'
);
$continue
=
$request
->
get
(
'continue'
,
false
);
if
(
$continue
!==
false
)
{
// The user has pressed the continue/retry-button
Auth\ProcessingChain
::
resumeProcessing
(
$state
);
}
$t
=
new
Template
(
$this
->
config
,
'core:short_sso_interval.tpl.php'
);
$translator
=
$t
->
getTranslator
();
$t
->
data
[
'target'
]
=
Module
::
getModuleURL
(
'core/short_sso_interval.php'
);
$t
->
data
[
'params'
]
=
[
'StateId'
=>
$stateId
];
$t
->
data
[
'trackId'
]
=
$this
->
session
->
getTrackID
();
$t
->
data
[
'header'
]
=
$translator
->
t
(
'{core:short_sso_interval:warning_header}'
);
$t
->
data
[
'autofocus'
]
=
'contbutton'
;
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