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
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
91e17d3a
Unverified
Commit
91e17d3a
authored
6 years ago
by
Jaime Pérez Crespo
Browse files
Options
Downloads
Patches
Plain Diff
Add a controller for logout.
parent
09a31ace
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/lib/Controller.php
+44
-34
44 additions, 34 deletions
modules/core/lib/Controller.php
modules/core/routes.yaml
+3
-1
3 additions, 1 deletion
modules/core/routes.yaml
with
47 additions
and
35 deletions
modules/core/lib/Controller.php
+
44
−
34
View file @
91e17d3a
...
@@ -44,6 +44,44 @@ class Controller
...
@@ -44,6 +44,44 @@ class Controller
}
}
/**
* Show account information for a given authentication source.
*
* @param string $as The identifier of the authentication source.
*
* @return \SimpleSAML\XHTML\Template|RedirectResponse An HTML template or a redirection if we are not
* authenticated.
*
* @throws \SimpleSAML\Error\Exception An exception in case the auth source specified is invalid.
*/
public
function
account
(
$as
)
{
if
(
!
array_key_exists
(
$as
,
$this
->
sources
))
{
throw
new
Exception
(
'Invalid authentication source'
);
}
$auth
=
new
\SimpleSAML\Auth\Simple
(
$as
);
if
(
!
$auth
->
isAuthenticated
())
{
// not authenticated, start auth with specified source
return
new
RedirectResponse
(
\SimpleSAML\Module
::
getModuleURL
(
'core/login/'
.
urlencode
(
$as
)));
}
$attributes
=
$auth
->
getAttributes
();
$t
=
new
\SimpleSAML\XHTML\Template
(
$this
->
config
,
'auth_status.php'
,
'attributes'
);
$t
->
data
[
'header'
]
=
'{status:header_saml20_sp}'
;
$t
->
data
[
'attributes'
]
=
$attributes
;
$t
->
data
[
'nameid'
]
=
!
is_null
(
$auth
->
getAuthData
(
'saml:sp:NameID'
))
?
$auth
->
getAuthData
(
'saml:sp:NameID'
)
:
false
;
$t
->
data
[
'logouturl'
]
=
\SimpleSAML\Module
::
getModuleURL
(
'core/logout/'
.
urlencode
(
$as
));
$t
->
data
[
'remaining'
]
=
$this
->
session
->
getAuthData
(
$as
,
'Expire'
)
-
time
();
$t
->
setStatusCode
(
200
);
return
$t
;
}
/**
/**
* Perform a login operation.
* Perform a login operation.
*
*
...
@@ -85,10 +123,6 @@ class Controller
...
@@ -85,10 +123,6 @@ class Controller
$auth
=
new
\SimpleSAML\Auth\Simple
(
$as
);
$auth
=
new
\SimpleSAML\Auth\Simple
(
$as
);
$as
=
urlencode
(
$as
);
$as
=
urlencode
(
$as
);
if
(
$request
->
get
(
'logout'
,
false
)
!==
false
)
{
$auth
->
logout
(
$this
->
config
->
getBasePath
()
.
'logout.php'
);
}
if
(
$request
->
get
(
\SimpleSAML\Auth\State
::
EXCEPTION_PARAM
,
false
)
!==
false
)
{
if
(
$request
->
get
(
\SimpleSAML\Auth\State
::
EXCEPTION_PARAM
,
false
)
!==
false
)
{
// This is just a simple example of an error
// This is just a simple example of an error
...
@@ -114,39 +148,15 @@ class Controller
...
@@ -114,39 +148,15 @@ class Controller
/**
/**
*
Show acc
ou
n
t
information for
a given authentication source.
*
Log the user
out
of
a given authentication source.
*
*
* @param string $as The identifier of the authentication source.
* @param string $as The name of the auth source.
*
* @return \SimpleSAML\XHTML\Template|RedirectResponse An HTML template or a redirection if we are not
* authenticated.
*
*
* @throws \SimpleSAML\Error\
Exception An exception in case the auth source specified is invalid.
* @throws \SimpleSAML\Error\
CriticalConfigurationError
*/
*/
public
function
acc
ou
n
t
(
$as
)
public
function
log
out
(
$as
)
{
{
if
(
!
array_key_exists
(
$as
,
$this
->
sources
))
{
$as
=
new
\SimpleSAML\Auth\Simple
(
$as
);
throw
new
Exception
(
'Invalid authentication source'
);
$as
->
logout
(
$this
->
config
->
getBasePath
()
.
'logout.php'
);
}
$auth
=
new
\SimpleSAML\Auth\Simple
(
$as
);
if
(
!
$auth
->
isAuthenticated
())
{
// not authenticated, start auth with specified source
return
new
RedirectResponse
(
\SimpleSAML\Module
::
getModuleURL
(
'core/login/'
.
urlencode
(
$as
)));
}
$attributes
=
$auth
->
getAttributes
();
$t
=
new
\SimpleSAML\XHTML\Template
(
$this
->
config
,
'auth_status.php'
,
'attributes'
);
$t
->
data
[
'header'
]
=
'{status:header_saml20_sp}'
;
$t
->
data
[
'attributes'
]
=
$attributes
;
$t
->
data
[
'nameid'
]
=
!
is_null
(
$auth
->
getAuthData
(
'saml:sp:NameID'
))
?
$auth
->
getAuthData
(
'saml:sp:NameID'
)
:
false
;
$t
->
data
[
'logouturl'
]
=
\SimpleSAML\Module
::
getModuleURL
(
'core/logout/'
.
urlencode
(
$as
));
$t
->
data
[
'remaining'
]
=
$this
->
session
->
getAuthData
(
$as
,
'Expire'
)
-
time
();
$t
->
setStatusCode
(
200
);
return
$t
;
}
}
}
}
This diff is collapsed.
Click to expand it.
modules/core/routes.yaml
+
3
−
1
View file @
91e17d3a
...
@@ -4,4 +4,6 @@ core-login:
...
@@ -4,4 +4,6 @@ core-login:
core-account
:
core-account
:
path
:
/account/{as}
path
:
/account/{as}
defaults
:
{
_controller
:
'
SimpleSAML\Module\core\Controller::account'
}
defaults
:
{
_controller
:
'
SimpleSAML\Module\core\Controller::account'
}
core-logout
:
path
:
/logout/{as}
defaults
:
{
_controller
:
'
SimpleSAML\Module\core\Controller::logout'
}
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