Module provides a HarID plugin for OpenID Connect module.

https://www.drupal.org/project/openid_connect_harid

Git instructions

git clone --branch '8.x-1.x' https://git.drupalcode.org/project/openid_connect_harid.git

PAReview

https://pareview.net/r/394

Comments

pjotr.savitski created an issue. See original summary.

pjotr.savitski’s picture

Issue summary: View changes
pjotr.savitski’s picture

Issue summary: View changes
pjotr.savitski’s picture

Issue summary: View changes
avpaderno’s picture

Issue summary: View changes
marijan gudelj’s picture

in your composer.json please also add the drupal core dependency

{
  "name": "drupal/openid_connect_harid",
  "type": "drupal-module",
  "description": "OpenID Connect HarID Client",
  "keywords": ["Drupal", "OpenID Connect", "HarID", "Client"],
  "license": "MIT",
  "homepage": "https://github.com/sisuloome/openid_connect_harid",
  "minimum-stability": "dev",
  "support": {
    "issues": "https://github.com/sisuloome/openid_connect_harid/issues",
    "source": "https://github.com/sisuloome/openid_connect_harid"
  },
  "require": {
    "drupal/core": "^8.8 || ^9",
    "drupal/openid_connect" : "^1.1"
  }
marijan gudelj’s picture

Status: Needs review » Needs work
pjotr.savitski’s picture

Status: Needs work » Needs review

I've updated the composer.json to include the Drupal Core dependency.

marijan gudelj’s picture

Automated test

Passed

Manual test

Individual user account:Yes
No duplication:Yes
Master Branch:Yes
Licensing:Yes
3rd party assets/code:Yes
README.txt/README.md:Yes
Code long/complex enough for review:Yes
Secure code: Yes
Coding style & Drupal API usage:
- Recommendation: in the .module

  function openid_connect_harid_openid_connect_post_authorize(UserInterface $account, array $context) {
  if ($context['plugin_id'] === 'harid') {
    if (isset($context['userinfo']['ui_locales'])) {
      // TODO See if there should be a check for allowed values of en, et, ru.
      $account->set('langcode', $context['userinfo']['ui_locales']);
      $account->set('preferred_langcode', $context['userinfo']['ui_locales']);
      $account->save();
    }
  }

can go under one if statement.

- Recommendation in the .module and .install
Replace \Drupal::
By adding on top
use Drupal
It is used more that 1 time so this implementation will have a faster execution time.

openid_connect_harid.info.yml
Consider placing the min php version to 7.2 as it is the min recommended version of Drupal 8.8

OpenIDConnectHarIDClient.php
In this part of the code

public function getEndpoints() {
    $base_url = $this->getBaseUrl();

    return [
      'authorization' => $base_url . '/authorizations/new',
      'token' => $base_url . '/access_tokens',
      'userinfo' => $base_url . '/user_info',
    ];
  }

use Url::fromUri
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Url.php/f...

pjotr.savitski’s picture

@marijan-gudelj I've applied most of the suggested coding style and Drupal API usage changes. There is one thing I didn't understand though. This is in relation to OpenIDConnectHarIDClient::getEndpoints() method. I'm not sure what would be the win from using a Url::fromUri() approach. The expected result would still have to be an array with URL strings. Example:

public function getEndpoints() {
    $base_url = $this->getBaseUrl();

    return [
      'authorization' => Url::fromUrl($base_url . '/authorizations/new')->toString(FALSE),
      'token' => Url::fromUrl($base_url . '/access_tokens')->toString(FALSE),
      'userinfo' => Url::fromUrl($base_url . '/user_info')->toString(FALSE),
    ];
  }

I've checked the code behind the URL::fromUri()and it does seem to apply some checks and possible fixes to the resulting URL, though the result of a call to getBaseUrl() will return the contents of one of the predefined class constants that will already be a correctly formed base URL. I can rewrite the code with ease and just want to know what is the main difference and benefit?

It also seems that both .module and .install files already are in the Drupal namespace, which makes use Drupal unneeded, and even problematic for running tests.

marijan gudelj’s picture

As for the Url::fromUrl
This is from the documentation:

Same name and namespace in other branches
Creates a new Url object from a URI.

This method is for generating URLs for URIs that:
do not have Drupal routes: both external URLs and unrouted local URIs like base:robots.txt

Replacing \Drupal with use Drupal.
Each time you use a \Drupal you are trying to access the Class or call it.
When you have it one time in the code it makes sense that it is only in that method/function.
When it is repeating it is better to "use Drupal"
Basically it is like you are setting an variable and just reusing it vs. reinitializing the variable.
Hope that this makes sense.

marijan gudelj’s picture

Status: Needs review » Needs work
pjotr.savitski’s picture

I've added the Url::fromUri() to the plugin code.

The use Drupal; is a bit complicated as IDE is reporting that The 'use' statement with non-compound name 'Drupal' has no effect for both .module and .install files. Running tests also fails with the same message. It seems that those files are already running in the Drupal namespace and class has already been made available.

Importing and reusing something makes a lot of sense.

pjotr.savitski’s picture

Status: Needs work » Needs review
marijan gudelj’s picture

That was more of an advice than an error. It was returned because of the Url Class.

I have rechecked both automated test and redid a manual checkup. I see no other problems here.Unless someone else finds someting.

marijan gudelj’s picture

Status: Needs review » Reviewed & tested by the community
avpaderno’s picture

Assigned: Unassigned » avpaderno
Status: Reviewed & tested by the community » Fixed

Thank you for your contribution! I am going to update your account.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.