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
f7954199
Commit
f7954199
authored
3 years ago
by
Tim van Dijen
Browse files
Options
Downloads
Patches
Plain Diff
Fix session
parent
cfc9c8e8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/exampleauth/lib/Auth/Source/External.php
+13
-17
13 additions, 17 deletions
modules/exampleauth/lib/Auth/Source/External.php
with
13 additions
and
17 deletions
modules/exampleauth/lib/Auth/Source/External.php
+
13
−
17
View file @
f7954199
...
...
@@ -9,6 +9,7 @@ use SimpleSAML\Auth;
use
SimpleSAML\Error
;
use
SimpleSAML\Module
;
use
SimpleSAML\Utils
;
use
Symfony\Component\HttpFoundation\Session\Session
as
SymfonySession
;
/**
* Example external authentication source.
...
...
@@ -64,13 +65,12 @@ class External extends Auth\Source
* stored in the users PHP session, but this could be replaced
* with anything.
*/
if
(
!
session_id
())
{
// session_start not called before. Do it here
session_start
();
$session
=
new
SymfonySession
();
if
(
!
$session
->
getId
())
{
$session
->
start
();
}
if
(
!
isset
(
$_SESSION
[
'uid'
]
))
{
if
(
!
$session
->
has
(
'uid'
))
{
// The user isn't authenticated
return
null
;
}
...
...
@@ -80,16 +80,15 @@ class External extends Auth\Source
* Note that all attributes in SimpleSAMLphp are multivalued, so we need
* to store them as arrays.
*/
$attributes
=
[
'uid'
=>
[
$
_SESSION
[
'uid'
]
],
'displayName'
=>
[
$
_SESSION
[
'name'
]
],
'mail'
=>
[
$
_SESSION
[
'mail'
]
],
'uid'
=>
[
$
session
->
get
(
'uid'
)
],
'displayName'
=>
[
$
session
->
get
(
'name'
)
],
'mail'
=>
[
$
session
->
get
(
'mail'
)
],
];
// Here we generate a multivalued attribute based on the account type
$attributes
[
'eduPersonAffiliation'
]
=
[
$
_SESSION
[
'type'
]
,
/* In this example, either 'student' or 'employee'. */
$
session
->
get
(
'type'
)
,
/* In this example, either 'student' or 'employee'. */
'member'
,
];
...
...
@@ -265,15 +264,12 @@ class External extends Auth\Source
*/
public
function
logout
(
array
&
$state
):
void
{
if
(
!
session
_id
())
{
// session_start not called before. Do it here
session
_
start
();
$
session
=
new
SymfonySession
();
if
(
!
$session
->
getId
())
{
$
session
->
start
();
}
/*
* In this example we simply remove the 'uid' from the session.
*/
unset
(
$_SESSION
[
'uid'
]);
$session
->
clear
();
/*
* If we need to do a redirect to a different page, we could do this
...
...
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