-
Notifications
You must be signed in to change notification settings - Fork 67
feat: render a read-only profile for identity-provider-managed accounts #569
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
Merged
DonOmalVindula
merged 4 commits into
asgardeo:main
from
DonOmalVindula:feat/readonly-federated-profile
Sep 8, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9a156a9
feat(react, nextjs): render a read-only profile for identity-provider…
DonOmalVindula e5f7197
fix(react, nextjs): no edit-control flash, and apply the rule to the …
DonOmalVindula 3cf0f5d
feat(react): show a loading state while the profile resolves
DonOmalVindula d6cbd73
fix(react, nextjs): satisfy the key-ordering lint rules
DonOmalVindula File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| '@asgardeo/javascript': patch | ||
| '@asgardeo/i18n': patch | ||
| '@asgardeo/react': patch | ||
| '@asgardeo/nextjs': patch | ||
| --- | ||
|
|
||
| Render a read-only profile for users whose attributes are owned by an identity provider. | ||
|
|
||
| Asgardeo rejects attribute updates for accounts provisioned from a social or enterprise connection, so the profile used to offer edit controls that always failed with a raw SCIM error. | ||
|
|
||
| - `<UserProfile />` accepts `editable="auto"` in React and Next.js. On Asgardeo it looks up the signed-in user's federated associations and, when the account is linked to a connection, renders the profile read-only with a short note naming the provider. On WSO2 Identity Server, where the same updates succeed, the profile stays editable. | ||
| - `<UserDropdown />` forwards `editable` to the profile it opens from "Manage profile", so the modal follows the same rule as the page. | ||
| - `BaseUserProfile` accepts a predicate for `editable`, so applications can decide per user without any lookup, and a `readOnlyNote` to explain why editing is unavailable. | ||
| - A rejected update is now reported in plain words instead of the raw SCIM error, and switches the profile to read-only for the rest of the session. The Next.js `<UserProfile />` previously ignored update failures entirely. | ||
| - New API `getMeFederatedAssociations` in `@asgardeo/javascript` and `@asgardeo/react`, plus the `signup`-style texts `user.profile.readonly.federated` and `user.profile.update.not.allowed.error` in all i18n bundles. | ||
|
|
||
| While `auto` is resolving, the profile shows a loading state rather than edit controls it may have to take away; `BaseUserProfile` now renders that state whenever `isLoading` is set, in both inline and popup modes. In popup mode the lookup is deferred until the profile is actually opened. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
packages/javascript/src/api/getMeFederatedAssociations.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
|
|
||
| import AsgardeoAPIError from '../errors/AsgardeoAPIError'; | ||
| import {FederatedAssociation} from '../models/federated-association'; | ||
|
|
||
| /** | ||
| * Configuration for the `getMeFederatedAssociations` request. | ||
| */ | ||
| export interface GetMeFederatedAssociationsConfig extends Omit<RequestInit, 'method'> { | ||
| /** | ||
| * The base path of the API endpoint. | ||
| */ | ||
| baseUrl?: string; | ||
| /** | ||
| * Optional custom fetcher function. If not provided, native fetch will be used. | ||
| */ | ||
| fetcher?: (url: string, config: RequestInit) => Promise<Response>; | ||
| /** | ||
| * The absolute API endpoint. | ||
| */ | ||
| url?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves the identity provider accounts linked to the signed-in user. | ||
| * | ||
| * An account provisioned just-in-time from a social or enterprise connection has at least one | ||
| * association; a user who registered locally has none. | ||
| * | ||
| * @param config - Request configuration. | ||
| * @returns The list of associations, empty when the account is purely local. | ||
| * @example | ||
| * ```ts | ||
| * const associations = await getMeFederatedAssociations({baseUrl: 'https://api.asgardeo.io/t/<org>'}); | ||
| * const isFederated = associations.length > 0; | ||
| * ``` | ||
| */ | ||
| const getMeFederatedAssociations = async ({ | ||
| url, | ||
| baseUrl, | ||
| fetcher, | ||
| ...requestConfig | ||
| }: GetMeFederatedAssociationsConfig): Promise<FederatedAssociation[]> => { | ||
| try { | ||
| // eslint-disable-next-line no-new | ||
| new URL(url ?? baseUrl); | ||
| } catch (error) { | ||
| throw new AsgardeoAPIError( | ||
| `Invalid URL provided. ${error?.toString()}`, | ||
| 'getMeFederatedAssociations-ValidationError-001', | ||
| 'javascript', | ||
| 400, | ||
| 'The provided `url` or `baseUrl` path does not adhere to the URL schema.', | ||
| ); | ||
| } | ||
|
|
||
| const fetchFn: typeof fetch = fetcher || fetch; | ||
| const resolvedUrl: string = url ?? `${baseUrl}/api/users/v1/me/federated-associations`; | ||
|
|
||
| const response: Response = await fetchFn(resolvedUrl, { | ||
| ...requestConfig, | ||
| headers: { | ||
| Accept: 'application/json', | ||
| ...requestConfig.headers, | ||
| }, | ||
| method: 'GET', | ||
| }); | ||
|
|
||
| if (!response?.ok) { | ||
| const errorText: string = await response.text(); | ||
|
|
||
| throw new AsgardeoAPIError( | ||
| errorText, | ||
| 'getMeFederatedAssociations-ResponseError-001', | ||
| 'javascript', | ||
| response.status, | ||
| response.statusText, | ||
| ); | ||
| } | ||
|
|
||
| const associations: unknown = await response.json(); | ||
|
|
||
| return Array.isArray(associations) ? (associations as FederatedAssociation[]) : []; | ||
| }; | ||
|
|
||
| export default getMeFederatedAssociations; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
|
|
||
| /** | ||
| * A link between the local user account and an identity in an external identity provider, | ||
| * created when the user is provisioned just-in-time or when the account is linked. | ||
| */ | ||
| export interface FederatedAssociation { | ||
| /** | ||
| * The user's identifier at the identity provider. | ||
| */ | ||
| federatedUserId?: string; | ||
| /** | ||
| * Unique identifier of the association. | ||
| */ | ||
| id?: string; | ||
| /** | ||
| * The identity provider the account is linked to. | ||
| */ | ||
| idp?: { | ||
| displayName?: string; | ||
| id?: string; | ||
| imageUrl?: string; | ||
| name?: string; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🤖 get_repo_knowledge executed:
get_repo_knowledge asgardeo/javascript /tmp/coderabbit-repo-knowledge/asgardeo-javascript-93d97855Length of output: 453
🏁 Script executed:
Repository: asgardeo/javascript
Length of output: 48847
🏁 Script executed:
Repository: asgardeo/javascript
Length of output: 23933
🌐 Web query:
site:asgardeo.io federated-associations "204" API💡 Result:
There is no publicly available technical documentation or authoritative information regarding a specific federated-associations 204 API. The search results provided do not contain any references to this term or an API endpoint associated with it. The results instead point to generic login and authentication pages for platforms like WSO2 Identity Server/Asgardeo and IATI, which appear unrelated to the query.
Citations:
Preserve all valid
HeadersInitvalues.GetMeFederatedAssociationsConfigacceptsRequestInit, so callers can pass aHeadersinstance or a tuple array. SpreadingrequestConfig.headersinto an object losesHeadersentries and converts tuple arrays into numeric object keys. Caller-supplied headers can therefore be absent or malformed.Proposed fix
🤖 Prompt for AI Agents