[#1960] - Add SunbirdRC (KBI) authentication provider#1973
[#1960] - Add SunbirdRC (KBI) authentication provider#1973nandhu-kumar wants to merge 5 commits into
Conversation
|
Warning Review limit reached
More reviews will be available in 20 minutes and 3 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (13)
WalkthroughAdds SunbirdRC (KBI) authentication: environment-driven configuration and defaults, README and .env.example updates, declarative flow and application YAML, a new Sunbird AuthnProvider that validates credentials via HTTP registry search and optionally fetches entity attributes, and factory/tests wiring. ChangesSunbirdRC Authentication Provider
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
6fa7e9b to
8f88f42
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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
`@esignet-service/data/repository/resources/applications/app-declarative-sunbird.yaml`:
- Line 19: app-declarative-sunbird.yaml references an OAuth client_id
"decl-sunbird-client-1" but there is no corresponding OAuth client resource in
the repository; either add a new OAuth client resource named
decl-sunbird-client-1 under the resources layout (create the appropriate
directory and resource YAML describing the client credentials/inbound config) or
change the client_id in app-declarative-sunbird.yaml to match an existing OAuth
client resource; look for functions/entries referencing client_id
"decl-sunbird-client-1" and ensure the new resource uses that exact identifier
so the application inbound auth resolves correctly.
In
`@esignet-service/data/repository/resources/flows/flow-declarative-sunbird-1.yaml`:
- Around line 34-45: The executor input types are inconsistent with the PROMPT:
change the inputs referenced in BasicAuthExecutor so that fullName and dob (and
individualId if intended) use type TEXT_INPUT instead of PASSWORD_INPUT to match
the PROMPT node; update the input definitions in the BasicAuthExecutor block
that reference identifiers fullName, dob, and individualId to TEXT_INPUT so KBI
fields remain non-password fields (only use PASSWORD_INPUT where values must be
masked).
In `@esignet-service/internal/config/sunbird_test.go`:
- Around line 48-54: Add a negative timeout test to
TestLoadSunbirdAuthn_invalidTimeoutFallsBackToDefault to assert
LoadSunbirdAuthn() falls back to the default when envSunbirdTimeout is set to a
negative value; set the environment variable envSunbirdTimeout to "-5" (or any
negative number), call LoadSunbirdAuthn(), and require that TimeoutSecs equals
the default (10) to cover the secs <= 0 branch in sunbird.go.
In `@esignet-service/README.md`:
- Around line 113-114: Add concrete example default JSON for
MOSIP_ESIGNET_AUTHENTICATOR_SUNBIRD_RC_AUTH_FACTOR_KBI_FIELD_DETAILS and
MOSIP_ESIGNET_AUTHENTICATOR_SUNBIRD_RC_IDENTITY_OPENID_CLAIMS_MAPPING in the
README: show a code block with a representative JSON list for the KBI fields and
a JSON map for the OIDC→registry claims mapping (use the exact env var names in
the heading), or add a clear reference/link to the project's .env.example that
contains those values; ensure the examples reflect the insurance defaults and
match the expected keys/structure used by the code that reads these env vars.
🪄 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: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 02afb834-eafb-4b8a-8dae-f6a27c01803e
📒 Files selected for processing (13)
esignet-service/.env.exampleesignet-service/Makefileesignet-service/README.mdesignet-service/data/repository/resources/applications/app-declarative-sunbird.yamlesignet-service/data/repository/resources/flows/flow-declarative-sunbird-1.yamlesignet-service/internal/config/authn.goesignet-service/internal/config/authn_test.goesignet-service/internal/config/sunbird.goesignet-service/internal/config/sunbird_test.goesignet-service/internal/host/authn_factory.goesignet-service/internal/host/authn_factory_test.goesignet-service/internal/host/sunbird_authn.goesignet-service/internal/host/sunbird_authn_test.go
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@esignet-service/internal/host/sunbird_authn_test.go`:
- Around line 147-151: Add a regression test to ensure buildSunbirdMappedClaims
fails-closed on malformed SUNBIRD_CLAIMS_MAPPING: create a new test (e.g.,
TestBuildSunbirdMappedClaims_invalidMappingFailsClosed) that calls
buildSunbirdMappedClaims with a valid entity map and a deliberately malformed
mapping string (non-JSON or invalid mapping schema) and assert the result does
NOT equal the original entity and instead returns an empty/safe map (e.g.,
map[string]interface{}{}), enforcing that no raw-entity leakage occurs when
parsing fails.
In `@esignet-service/internal/host/sunbird_authn.go`:
- Around line 229-234: The current error branch in parseSunbirdClaimsMapping
handling (when parseSunbirdClaimsMapping(claimsMappingJSON) returns err)
incorrectly returns raw entityData, risking over-disclosure; change the branch
in the function that calls parseSunbirdClaimsMapping to fail-closed by logging
the parse error with applog.GetLogger().Warn or Error and returning an empty map
(or propagate the error instead of returning entityData) so no registry fields
are passed through—update the error handling around claimsMapping,
claimsMappingJSON, and the return value to ensure an empty map is returned on
parse failure (or surface the error) rather than entityData.
🪄 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: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1d1332f5-60c7-47d0-90d1-14c9165ad115
📒 Files selected for processing (13)
esignet-service/.env.exampleesignet-service/Makefileesignet-service/README.mdesignet-service/data/repository/resources/applications/app-declarative-sunbird.yamlesignet-service/data/repository/resources/flows/flow-declarative-sunbird-1.yamlesignet-service/internal/config/authn.goesignet-service/internal/config/authn_test.goesignet-service/internal/config/sunbird.goesignet-service/internal/config/sunbird_test.goesignet-service/internal/host/authn_factory.goesignet-service/internal/host/authn_factory_test.goesignet-service/internal/host/sunbird_authn.goesignet-service/internal/host/sunbird_authn_test.go
ed0b9f8 to
8c7d984
Compare
Add AUTHN_PROVIDER=sunbird, a knowledge-based-identity provider that authenticates against a SunbirdRC registry (search endpoint) and maps registry fields to OIDC claims (get endpoint). Mirrors the MOSIP provider wiring and reuses the built-in BasicAuthExecutor (no custom executor). Includes config + factory wiring, a demo flow and app, unit tests (config, factory, httptest provider), and docs/.env.example updates. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Nandhukumar <nandhukumare@gmail.com>
Prefix openssl with MSYS_NO_PATHCONV=1 and MSYS2_ARG_CONV_EXCL=* so MSYS does not rewrite the -subj '/CN=esignet' argument into a Windows path. No-op on Linux/macOS (openssl ignores the unknown env vars). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Nandhukumar <nandhukumare@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Nandhukumar <nandhukumare@gmail.com>
When SUNBIRD_CLAIMS_MAPPING is invalid JSON, buildSunbirdMappedClaims now returns an empty map instead of the raw registry entity, so unmapped fields are never disclosed as OIDC attributes. Adds a regression test. Signed-off-by: Nandhukumar <nandhukumare@gmail.com>
…rsing Address PR review: remove all references to the Java eSignet Sunbird plugin from sunbird.go, .env.example, and README.md, and move the timeout env-var parsing into LoadSunbirdAuthn instead of a standalone helper. Signed-off-by: Nandhukumar <nandhukumare@gmail.com>
8c7d984 to
0d49800
Compare
Resolves #1960
What
Adds a new authentication provider
AUTHN_PROVIDER=sunbirdthat authenticatesusers via Knowledge-Based Identity (KBI) against a SunbirdRC registry, alongside
the existing
catalogandmosipproviders.Why
To support SunbirdRC registry-based login in the Go eSignet service, mirroring
the existing Java eSignet Sunbird plugin (
io.mosip.esignet.plugin.sunbirdrc).How it works
individualId+ KBI fields (defaultfullName,dob).its entity id (default
osid) becomes the user id.OIDC claims via configurable claim mapping.
BasicAuthExecutor(no custom executor needed).Changes
internal/config/sunbird.go– config + env vars (mirrors the Java property keys)internal/host/sunbird_authn.go– the provider (search + attribute fetch + claims mapping)config/authn.goandhost/authn_factory.goflow-declarative-sunbird-1.yaml+ appapp-declarative-sunbird.yamlREADME.md+.env.examplemake keysnow works on Windows Git Bash (MSYS path handling)Testing
go build ./...andgo test ./...pass.flowStatus: COMPLETEand a valid assertion/access token.Configuration
Set
AUTHN_PROVIDER=sunbirdand theMOSIP_ESIGNET_AUTHENTICATOR_SUNBIRD_RC_*env vars (registry search/get URLs are required). See
.env.example.Summary by CodeRabbit
New Features
Documentation