Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UiB Feide userinfo modification
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
IT-division Public
Drupal
Modules
UiB Feide userinfo modification
Merge requests
!5
WP110 Refactor uib_feide_openid_connect_pre_authorize
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
WP110 Refactor uib_feide_openid_connect_pre_authorize
refactor-uib-feide-openid-connect-pre-authorize
into
master
Overview
1
Commits
1
Pipelines
5
Changes
1
Closed
Are Johannessen
requested to merge
refactor-uib-feide-openid-connect-pre-authorize
into
master
4 months ago
Overview
1
Commits
1
Pipelines
5
Changes
1
Expand
A refactoring of a hook in uib_feide to make the code easier to read.
0
0
Merge request reports
Compare
version 1
version 4
c17edb94
3 months ago
version 3
961eddce
3 months ago
version 2
2717dbf6
4 months ago
version 1
7ef386e3
4 months ago
master (base)
and
version 2
latest version
2c1808e5
1 commit,
3 months ago
version 4
c17edb94
1 commit,
3 months ago
version 3
961eddce
1 commit,
3 months ago
version 2
2717dbf6
1 commit,
4 months ago
version 1
7ef386e3
1 commit,
4 months ago
Show latest version
1 file
+
0
−
157
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/Plugin/OpenIDConnectClient/OpenIDConnectFeideClient.php deleted
100644 → 0
+
0
−
157
Options
<?php
namespace
Drupal\uib_feide\Plugin\OpenIDConnectClient
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\GeneratedUrl
;
use
Drupal\Core\Site\Settings
;
use
Drupal\openid_connect
\Plugin\OpenIDConnectClientBase
;
/**
* Feide OpenID Connect client.
*
* @OpenIDConnectClient(
* id = "feide",
* label = @Translation("Feide")
* )
*/
class
OpenIDConnectFeideClient
extends
OpenIDConnectClientBase
{
/**
* {@inheritdoc}
*/
public
function
defaultConfiguration
():
array
{
return
[
'issuer_url'
=>
''
,
'authorization_endpoint'
=>
'https://auth.dataporten.no/oauth/authorization'
,
'token_endpoint'
=>
'https://auth.dataporten.no/oauth/token'
,
'userinfo_endpoint'
=>
'https://auth.dataporten.no/openid/userinfo'
,
'end_session_endpoint'
=>
''
,
'scopes'
=>
[
'openid'
,
'email'
,
'userid-feide'
],
]
+
parent
::
defaultConfiguration
();
}
/**
* {@inheritdoc}
*/
public
function
buildConfigurationForm
(
array
$form
,
FormStateInterface
$form_state
):
array
{
$form
=
parent
::
buildConfigurationForm
(
$form
,
$form_state
);
$form
[
'authorization_endpoint'
]
=
[
'#title'
=>
$this
->
t
(
'Authorization endpoint'
),
'#default_value'
=>
$this
->
configuration
[
'authorization_endpoint'
],
'#disabled'
=>
TRUE
,
'#type'
=>
'url'
,
];
$form
[
'token_endpoint'
]
=
[
'#title'
=>
$this
->
t
(
'Token endpoint'
),
'#default_value'
=>
$this
->
configuration
[
'token_endpoint'
],
'#disabled'
=>
TRUE
,
'#type'
=>
'url'
,
];
$form
[
'userinfo_endpoint'
]
=
[
'#title'
=>
$this
->
t
(
'UserInfo endpoint'
),
'#default_value'
=>
$this
->
configuration
[
'userinfo_endpoint'
],
'#disabled'
=>
TRUE
,
'#type'
=>
'url'
,
];
$form
[
'scopes'
]
=
[
'#title'
=>
$this
->
t
(
'Scopes'
),
'#type'
=>
'textfield'
,
'#default_value'
=>
implode
(
' '
,
$this
->
configuration
[
'scopes'
]),
'#disabled'
=>
TRUE
,
];
$form
[
'client_id'
]
=
[
'#title'
=>
$this
->
t
(
'Client ID'
),
'#type'
=>
'textfield'
,
'#default_value'
=>
'Client ID coming from .env file'
,
'#disabled'
=>
TRUE
,
];
$form
[
'client_secret'
]
=
[
'#title'
=>
$this
->
t
(
'Client secret'
),
'#type'
=>
'textfield'
,
'#default_value'
=>
'Client Secret coming from .env file'
,
'#disabled'
=>
TRUE
,
];
return
$form
;
}
/**
* {@inheritdoc}
*/
public
function
submitConfigurationForm
(
array
&
$form
,
FormStateInterface
$form_state
):
void
{
$configuration
=
$form_state
->
getValues
();
if
(
!
empty
(
$configuration
[
'scopes'
]))
{
$this
->
setConfiguration
([
'scopes'
=>
explode
(
' '
,
$configuration
[
'scopes'
])]);
}
parent
::
submitConfigurationForm
(
$form
,
$form_state
);
}
/**
* {@inheritdoc}
*/
public
function
getClientScopes
():
?array
{
return
$this
->
configuration
[
'scopes'
];
}
/**
* {@inheritdoc}
*/
public
function
getEndpoints
()
:
array
{
return
[
'authorization'
=>
$this
->
configuration
[
'authorization_endpoint'
],
'token'
=>
$this
->
configuration
[
'token_endpoint'
],
'userinfo'
=>
$this
->
configuration
[
'userinfo_endpoint'
],
'end_session'
=>
$this
->
configuration
[
'end_session_endpoint'
],
];
}
/**
* {@inheritdoc}
*/
protected
function
getRequestOptions
(
string
$authorization_code
,
string
$redirect_uri
):
array
{
$client_id
=
Settings
::
get
(
'feide_client_id'
);
$client_secret
=
Settings
::
get
(
'feide_client_secret'
);
if
(
empty
(
$client_id
)
||
empty
(
$client_secret
))
{
throw
new
\RuntimeException
(
'Client ID or Client Secret is not set in the .env file'
);
}
return
[
'form_params'
=>
[
'code'
=>
$authorization_code
,
'client_id'
=>
$client_id
,
'client_secret'
=>
$client_secret
,
'redirect_uri'
=>
$redirect_uri
,
'grant_type'
=>
'authorization_code'
,
],
'headers'
=>
[
'Accept'
=>
'application/json'
,
],
];
}
/**
* {@inheritdoc}
*/
protected
function
getUrlOptions
(
string
$scope
,
GeneratedUrl
$redirect_uri
):
array
{
$client_id
=
Settings
::
get
(
'feide_client_id'
);
if
(
empty
(
$client_id
))
{
throw
new
\RuntimeException
(
'Client ID is not set in the .env file'
);
}
return
[
'query'
=>
[
'client_id'
=>
$client_id
,
'response_type'
=>
'code'
,
'scope'
=>
$scope
,
'redirect_uri'
=>
$redirect_uri
->
getGeneratedUrl
(),
'state'
=>
$this
->
stateToken
->
generateToken
(),
],
];
}
}
Loading