Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openid_connect
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
openid_connect
Merge requests
!72
Draft: Resolve
#2923419
"Method to use 2.x"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Draft: Resolve
#2923419
"Method to use 2.x"
issue/openid_connect-2923419:2923419-method-to-use-2.x
into
2.x
Overview
0
Commits
3
Pipelines
0
Changes
2
Open
Dylan Donkersgoed
requested to merge
issue/openid_connect-2923419:2923419-method-to-use-2.x
into
2.x
2 years ago
Overview
0
Commits
3
Pipelines
0
Changes
2
Expand
Closes
#2923419
0
0
Merge request reports
Compare
2.x
version 1
f26035ca
2 years ago
2.x (HEAD)
and
latest version
latest version
6a255fc7
3 commits,
2 years ago
version 1
f26035ca
2 commits,
2 years ago
2 files
+
70
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
src/Plugin/OpenIDConnectClientBase.php
+
52
−
0
Options
@@ -191,6 +191,58 @@ abstract class OpenIDConnectClientBase extends PluginBase implements OpenIDConne
}
}
/**
* {@inheritdoc}
*/
public
function
refreshTokens
(
string
$refresh_token
):
?array
{
// Exchange a refresh token for new tokens.
$endpoints
=
$this
->
getEndpoints
();
$request_options
=
[
'form_params'
=>
[
'refresh_token'
=>
$refresh_token
,
'client_id'
=>
$this
->
configuration
[
'client_id'
],
'client_secret'
=>
$this
->
configuration
[
'client_secret'
],
'grant_type'
=>
'refresh_token'
,
],
'headers'
=>
[
'Accept'
=>
'application/json'
,
],
];
if
(
$scopes
=
implode
(
' '
,
$this
->
getClientScopes
()))
{
$request_options
[
'form_params'
][
'scope'
]
=
$scopes
;
}
/* @var \GuzzleHttp\ClientInterface $client */
$client
=
$this
->
httpClient
;
try
{
$response
=
$client
->
post
(
$endpoints
[
'token'
],
$request_options
);
$response_data
=
json_decode
((
string
)
$response
->
getBody
(),
TRUE
);
// Expected result.
$tokens
=
[
'id_token'
=>
isset
(
$response_data
[
'id_token'
])
?
$response_data
[
'id_token'
]
:
NULL
,
'access_token'
=>
isset
(
$response_data
[
'access_token'
])
?
$response_data
[
'access_token'
]
:
NULL
,
];
if
(
array_key_exists
(
'expires_in'
,
$response_data
))
{
$tokens
[
'expire'
]
=
REQUEST_TIME
+
$response_data
[
'expires_in'
];
}
if
(
array_key_exists
(
'refresh_token'
,
$response_data
))
{
$tokens
[
'refresh_token'
]
=
$response_data
[
'refresh_token'
];
}
return
$tokens
;
}
catch
(
Exception
$e
)
{
$variables
=
[
'@message'
=>
'Could not refresh tokens'
,
'@error_message'
=>
$e
->
getMessage
(),
];
$this
->
loggerFactory
->
get
(
'openid_connect_'
.
$this
->
pluginId
)
->
error
(
'@message. Details: @error_message'
,
$variables
);
return
FALSE
;
}
}
/**
* {@inheritdoc}
*/
Loading