Skip to content

Added new classifier methods on jweService - #4495

Merged
ThaminduDilshan merged 1 commit into
thunder-id:releasefrom
anushasunkada:local_main
Aug 4, 2026
Merged

Added new classifier methods on jweService#4495
ThaminduDilshan merged 1 commit into
thunder-id:releasefrom
anushasunkada:local_main

Conversation

@anushasunkada

@anushasunkada anushasunkada commented Aug 2, 2026

Copy link
Copy Markdown
Member

Purpose

  1. Renamed key and encryption config.
  2. Added new classifier methods on jweService
  3. Updated backend/AGENTS.md's Conventions section with two new rules

Approach

Related Issues

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
    • Ran Vale and fixed all errors and warnings
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Summary by CodeRabbit

  • New Features

    • Added support for AES-GCM encryption algorithm.
  • Tests

    • Updated test coverage for encryption algorithm support and validation.
  • Chores

    • Improved security architecture for cryptographic operations and algorithm validation throughout the system.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6e2419e2-e5d4-45de-b241-c6f105513329

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change exposes JWE algorithm capabilities through JWEServiceInterface, injects the service into inbound-client and discovery flows, and adds AES-GCM to runtime encryption support.

Changes

Crypto capability reporting and provider support

Layer / File(s) Summary
JWE capability methods
backend/AGENTS.md, backend/internal/system/jose/jwe/*, backend/internal/system/kmprovider/defaultkm/*
The JWE service reports supported key-encryption and content-encryption algorithms. Key-encryption results filter unknown provider algorithms. Runtime encryption support now includes AES-GCM.
Inbound-client validation wiring
backend/cmd/server/servicemanager.go, backend/internal/inboundclient/*
Inbound-client services receive JWEServiceInterface. UserInfo and ID-token encryption validation uses service capability methods. Tests update constructors and validation coverage.
Discovery metadata wiring
backend/internal/oauth/*
Discovery services receive JWEServiceInterface and use it to generate OIDC encryption metadata. Discovery tests initialize and pass the service.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: rajithacharith, thamindudilshan, thiva-k, hwupathum

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.76% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the addition of classifier methods, which is a central change in the pull request.
Description check ✅ Passed The description includes the required sections and summarizes the main changes, but the Approach section is empty and checklist items remain unchecked.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/pkg/thunderidengine/config/config.go`:
- Around line 83-85: Update the SDK documentation under docs/content/sdks/ to
document the renamed DefaultRuntimeCryptoProviderConfig and
DefaultConfigCryptoProviderConfig types, the
WithDefaultRuntimeCryptoProviderConfigs and
WithDefaultConfigCryptoProviderConfig options, and migration guidance. Cover the
affected declarations in backend/pkg/thunderidengine/config/config.go at lines
83-85 and 149-151 and the option usage in backend/pkg/thunderidengine/engine.go
at lines 359-366; no code changes are required at these sites.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 55fe0277-3af6-45fc-9b4c-9d5993b78b2f

📥 Commits

Reviewing files that changed from the base of the PR and between dd1dcfc and 7b56a26.

⛔ Files ignored due to path filters (1)
  • backend/tests/mocks/jose/jwemock/JWEServiceInterface_mock.go is excluded by !**/*_mock.go
📒 Files selected for processing (36)
  • backend/AGENTS.md
  • backend/cmd/server/servicemanager.go
  • backend/internal/connection/init_test.go
  • backend/internal/entitytype/init_test.go
  • backend/internal/idp/init_test.go
  • backend/internal/idp/utils_test.go
  • backend/internal/inboundclient/init.go
  • backend/internal/inboundclient/service.go
  • backend/internal/inboundclient/service_test.go
  • backend/internal/notification/client/custom_client_test.go
  • backend/internal/notification/client/factory_test.go
  • backend/internal/notification/client/twilio_client_test.go
  • backend/internal/notification/client/vonage_client_test.go
  • backend/internal/notification/file_based_store_test.go
  • backend/internal/notification/init_test.go
  • backend/internal/notification/mgt_service_test.go
  • backend/internal/notification/notification_sender_service_test.go
  • backend/internal/notification/otp_service_test.go
  • backend/internal/notification/store_test.go
  • backend/internal/notification/utils_test.go
  • backend/internal/oauth/init.go
  • backend/internal/oauth/oauth2/discovery/discovery_test.go
  • backend/internal/oauth/oauth2/discovery/init.go
  • backend/internal/oauth/oauth2/discovery/service.go
  • backend/internal/system/config/config.go
  • backend/internal/system/export/init_test.go
  • backend/internal/system/export/service_test.go
  • backend/internal/system/importer/service_test.go
  • backend/internal/system/jose/init_test.go
  • backend/internal/system/jose/jwe/model.go
  • backend/internal/system/jose/jwe/service.go
  • backend/internal/system/jose/jwe/service_test.go
  • backend/internal/system/kmprovider/defaultkm/pki/service_test.go
  • backend/pkg/thunderidengine/config/config.go
  • backend/pkg/thunderidengine/engine.go
  • backend/pkg/thunderidengine/engine_test.go

Comment on lines +83 to +85
// DefaultRuntimeCryptoProviderConfig holds the key configuration details for the default
// runtime crypto provider.
type DefaultRuntimeCryptoProviderConfig struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift

🔴 Documentation Required

This PR introduces user-facing changes that are not covered by documentation updates under docs/.
Please update the relevant documentation before merging.

Missing documentation:

  • Embedded engine crypto configuration API: Document the renamed DefaultRuntimeCryptoProviderConfig and DefaultConfigCryptoProviderConfig types, plus the new WithDefaultRuntimeCryptoProviderConfigs and WithDefaultConfigCryptoProviderConfig options. Add migration guidance under docs/content/sdks/.

As per path instructions, SDK-impacting changes without matching documentation updates require one consolidated PR-level comment.

📍 Affects 2 files
  • backend/pkg/thunderidengine/config/config.go#L83-L85 (this comment)
  • backend/pkg/thunderidengine/config/config.go#L149-L151
  • backend/pkg/thunderidengine/engine.go#L359-L366
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/pkg/thunderidengine/config/config.go` around lines 83 - 85, Update
the SDK documentation under docs/content/sdks/ to document the renamed
DefaultRuntimeCryptoProviderConfig and DefaultConfigCryptoProviderConfig types,
the WithDefaultRuntimeCryptoProviderConfigs and
WithDefaultConfigCryptoProviderConfig options, and migration guidance. Cover the
affected declarations in backend/pkg/thunderidengine/config/config.go at lines
83-85 and 149-151 and the option usage in backend/pkg/thunderidengine/engine.go
at lines 359-366; no code changes are required at these sites.

Source: Path instructions

Comment on lines +141 to +143
Encryption engineconfig.DefaultConfigCryptoProviderConfig `yaml:"encryption" json:"encryption"`
PasswordHashing PasswordHashingConfig `yaml:"password_hashing" json:"password_hashing"`
Keys []engineconfig.DefaultRuntimeCryptoProviderConfig `yaml:"keys" json:"keys"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, better to rename the keys for this configuration too. Shall we take this as a separate PR

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In thunderID we always use only one key manager, so renaming it as default in config.go will not be correct.

Comment on lines +234 to +240
func (js *jweService) SupportedContentEncryptionAlgorithms() []string {
result := make([]string, len(supportedContentEncAlgorithms))
for i, enc := range supportedContentEncAlgorithms {
result[i] = string(enc)
}
return result
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should get the all the GetSupportedEncryptionAlgorithms from the cryptoProvider and filter out based on the knownKeyEncAlgorithms

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@anushasunkada
anushasunkada force-pushed the local_main branch 2 times, most recently from 45011dd to ba9595d Compare August 4, 2026 06:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/internal/system/kmprovider/defaultkm/runtime_crypto_provider.go`:
- Line 380: Update NewRuntimeCryptoService and GetSupportedEncryptionAlgorithms
so AES-GCM is advertised only when the runtime service has a non-nil cfgService,
matching the existing Encrypt and Decrypt checks; add the necessary nil-safe
construction behavior and coverage for NewRuntimeCryptoService(nil, ...) and its
advertised AES-GCM path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: badff87e-08ec-4e9e-a57f-71b88e9c7755

📥 Commits

Reviewing files that changed from the base of the PR and between 45011dd and ba9595d.

⛔ Files ignored due to path filters (1)
  • backend/tests/mocks/jose/jwemock/JWEServiceInterface_mock.go is excluded by !**/*_mock.go
📒 Files selected for processing (15)
  • backend/AGENTS.md
  • backend/cmd/server/servicemanager.go
  • backend/internal/inboundclient/init.go
  • backend/internal/inboundclient/service.go
  • backend/internal/inboundclient/service_test.go
  • backend/internal/oauth/init.go
  • backend/internal/oauth/oauth2/discovery/discovery_test.go
  • backend/internal/oauth/oauth2/discovery/init.go
  • backend/internal/oauth/oauth2/discovery/service.go
  • backend/internal/system/i18n/core/defaults.go
  • backend/internal/system/jose/jwe/model.go
  • backend/internal/system/jose/jwe/service.go
  • backend/internal/system/jose/jwe/service_test.go
  • backend/internal/system/kmprovider/defaultkm/runtime_crypto_provider.go
  • backend/internal/system/kmprovider/defaultkm/runtime_crypto_provider_test.go
🚧 Files skipped from review as they are similar to previous changes (12)
  • backend/internal/oauth/init.go
  • backend/cmd/server/servicemanager.go
  • backend/internal/oauth/oauth2/discovery/init.go
  • backend/internal/oauth/oauth2/discovery/service.go
  • backend/internal/system/jose/jwe/service_test.go
  • backend/internal/inboundclient/init.go
  • backend/AGENTS.md
  • backend/internal/system/jose/jwe/service.go
  • backend/internal/inboundclient/service.go
  • backend/internal/system/jose/jwe/model.go
  • backend/internal/oauth/oauth2/discovery/discovery_test.go
  • backend/internal/inboundclient/service_test.go

// GetSupportedEncryptionAlgorithms returns the list of algorithms supported by Encrypt and Decrypt.
func (s *runtimeCryptoService) GetSupportedEncryptionAlgorithms() []string {
return []string{
string(cryptolib.AlgorithmAESGCM),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 6 'runtimeCryptoService|cfgService|GetSupportedEncryptionAlgorithms' \
  backend/internal/system/kmprovider/defaultkm --glob '*.go'

Repository: thunder-id/thunderid

Length of output: 50376


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- NewRuntimeCryptoService usages ---\n'
rg -n 'NewRuntimeCryptoService\b' --glob '*.go' --glob '*.go' | head -n 200

printf '\n--- Test constructors / nil cfgService relevant cases ---\n'
rg -n -C 4 'NewRuntimeCryptoService\(.*nil|cfgSvc:|cfgService:.*nil|\&runtimeCryptoService\{|GetSupportedEncryptionAlgorithms|EncryptAESGCM|DecryptAESGCM|AlgorithmAESGCM' backend/internal/system/kmprovider/defaultkm --glob '*.go' | sed -n '1,260p'

printf '\n--- AES-GCM supported encryption test count ---\n'
rg -n 'Test[A-Za-z0-9_]*(.*[Aa]es[Gg][Cc][Mm]|[Aa]LGORITHM[Aa][Ee][Ss][Gg][Cc][Mm]|AESGCM)|AlgorithmAESGCM' backend/internal/system/kmprovider/defaultkm --glob '*_test.go'

Repository: thunder-id/thunderid

Length of output: 249


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- NewRuntimeCryptoService usages ---'
rg -n 'NewRuntimeCryptoService\b' --glob '*.go' | head -n 200

printf '%s\n' ''
printf '%s\n' '--- Constructor nil tests/cases and AES capability references ---'
rg -n -C 4 'NewRuntimeCryptoService\(.*nil|cfgService:.*nil|cfgSvc:.*nil|\&runtimeCryptoService\{|GetSupportedEncryptionAlgorithms|AESGCM|AlgorithmAESGCM' backend/internal/system/kmprovider/defaultkm --glob '*.go' | sed -n '1,260p'

printf '%s\n' ''
printf '%s\n' '--- AES-GCM test names ---'
rg -n 'Test[A-Za-z0-9_]*(.*AE?SG?G?CM|AESGCM|AlgorithmAESGCM).*\{|AESGCM|AlgorithmAESGCM' backend/internal/system/kmprovider/defaultkm --glob '*_test.go'

Repository: thunder-id/thunderid

Length of output: 431


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "--- NewRuntimeCryptoService usages ---"
rg -n 'NewRuntimeCryptoService\b' --glob '*.go' | head -n 200 || true

echo
echo "--- Constructor null/nil cases and supported AES-GCM references in defaultkm ---"
rg -n -C 4 'NewRuntimeCryptoService\(.*nil|cfgService:\s*nil|cfgSvc:\s*nil|\&runtimeCryptoService\s*\{|GetSupportedEncryptionAlgorithms|AESGCM|AlgorithmAESGCM' \
  backend/internal/system/kmprovider/defaultkm --glob '*.go' | sed -n '1,260p' || true

echo
echo "--- AES-GCM test names/references in tests ---"
rg -n 'Test[A-Za-z0-9_]*(.*AE?SG?G?CM|AESGCM|AlgorithmAESGCM).*\{|AESGCM|AlgorithmAESGCM' \
  backend/internal/system/kmprovider/defaultkm --glob '*_test.go' || true

Repository: thunder-id/thunderid

Length of output: 361


Keep AES-GCM capability in sync with construction state.

NewRuntimeCryptoService accepts cfgSvc without requiring a non-nil value, Encrypt/Decrypt reject AES-GCM when runtimeCryptoService.cfgService is nil, and GetSupportedEncryptionAlgorithms still advertises AES-GCM unconditionally. Add construction checks/null constructors and coverage for NewRuntimeCryptoService(nil, ...) with its advertised AES-GCM path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/internal/system/kmprovider/defaultkm/runtime_crypto_provider.go` at
line 380, Update NewRuntimeCryptoService and GetSupportedEncryptionAlgorithms so
AES-GCM is advertised only when the runtime service has a non-nil cfgService,
matching the existing Encrypt and Decrypt checks; add the necessary nil-safe
construction behavior and coverage for NewRuntimeCryptoService(nil, ...) and its
advertised AES-GCM path.

@anushasunkada anushasunkada changed the title Renamed key and encryption config, added new classifier methods on jweService Added new classifier methods on jweService Aug 4, 2026
Comment on lines +4 to +20
// Copyright 2025 The ThunderID Authors
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we revert this change, we have updated the license header

senthalan
senthalan previously approved these changes Aug 4, 2026
@senthalan senthalan added Type/Improvement trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes labels Aug 4, 2026
@anushasunkada
anushasunkada changed the base branch from main to release August 4, 2026 09:14
@anushasunkada
anushasunkada dismissed senthalan’s stale review August 4, 2026 09:14

The base branch was changed.

Signed-off-by: anushasunkada <anushasunkada@gmail.com>
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ThaminduDilshan
ThaminduDilshan merged commit 891e7f0 into thunder-id:release Aug 4, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes Type/Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants