Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D10 main #267

Draft
wants to merge 117 commits into
base: master
Choose a base branch
from
Draft

D10 main #267

wants to merge 117 commits into from

Conversation

burnout87
Copy link
Collaborator

No description provided.

@burnout87
Copy link
Collaborator Author

With the work of the last days, the API token form is now working (the email sending needs to be tested):

image

The module jwt_link is currently not available for Druapl 10, we use this in Drupal 7 to se the fields we want to include in the token. So, for now, these are set directly in the code of the mmoda module:

case 'jwt-token':
if (\Drupal::currentUser()->isAuthenticated()) {
$jwt_auth_service = \Drupal::service('jwt.authentication.jwt');
$jwt_encoded_token = $jwt_auth_service->generateToken();
\Drupal::logger('mmoda_module')->log(RfcLogLevel::INFO, 'jwt_encoded_token: @jwt_encoded_token', ['@jwt_encoded_token' => print_r($jwt_encoded_token, TRUE)]);
$jwt_transcoder_service = \Drupal::service('jwt.transcoder');
$jwt_decoded_token = $jwt_transcoder_service->decode($jwt_encoded_token);
$jwt_decoded_token -> setClaim('sub', $user->get('mail')->value);
$jwt_decoded_token -> setClaim('email', $user->get('mail')->value);
$jwt_decoded_token -> setClaim('name', $user->get('name')->value);
$jwt_decoded_token -> setClaim('roles', $user->getRoles());
if($is_mxroomid_empty)
unset($jwt_decoded_token -> mxroomid);
else
$jwt_decoded_token -> setClaim('field_matrix_room_id', $maxroomid_field->getValue()[0]['value']);
\Drupal::logger('mmoda_module')->log(RfcLogLevel::INFO, 'jwt_decoded_token: @jwt_decoded_token', ['@jwt_decoded_token' => print_r($jwt_decoded_token->getPayload(), TRUE)]);
$jwt_encoded_token_updated = $jwt_transcoder_service->encode($jwt_decoded_token);
$replacements[$original . '_updated'] = $jwt_encoded_token_updated;

Hopefully the module will be soon available also for Drupal 10, making our life easier.

Finally, the token structure is also slightly different:

eg

{
  "iat": 1725447485,
  "exp": 1725451085,
  "drupal": {
    "uid": "1"
  },
  "sub": "admin@example.com",
  "email": "admin@example.com",
  "name": "sitamin",
  "roles": [
    "authenticated",
    "administrator",
    "integral_private_qla",
    "unige_hpc_full"
  ],
  "field_matrix_room_id": "asd"
}

But afetr some test, it seems like it is still compatible with the dispatcher

@burnout87
Copy link
Collaborator Author

Something to keep in mind when the Drupal 10 instance will be deployed, the current key is not compatible:

image

burnout87 and others added 30 commits November 28, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant