Skip to content

Add role checking to identity context#1790

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-is-in-role-method
Draft

Add role checking to identity context#1790
Copilot wants to merge 4 commits intomainfrom
copilot/add-is-in-role-method

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

Summary

Adds role-based access control primitives to the identity system, enabling frontend components to check user roles.

Added

  • roles property on IdentityProviderResult (backend) and IIdentity interface (frontend) containing array of role names
  • isInRole(role: string) method on IIdentity for role membership checks
  • Backend role extraction from ClaimTypes.Role claims in IdentityProviderResultHandler
  • Documentation examples for both React and core identity providers

Usage:

import { useIdentity } from '@cratis/arc.react/identity';

export const AdminPanel = () => {
    const identity = useIdentity();
    
    if (!identity.isInRole('Admin')) {
        return <div>Access denied</div>;
    }
    
    return <div>Admin content</div>;
};

Roles default to empty array when not present, maintaining backward compatibility.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • docs.fluentvalidation.net
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (dns block)
  • docs.microsoft.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (dns block)
  • example.com
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node /home/REDACTED/work/Arc/Arc/node_modules/vitest/vitest.mjs run (dns block)
  • http://nuget.org:80/packages/Cratis.Arc
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (http block)
  • img.shields.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (dns block)
  • learn.microsoft.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (dns block)
  • marketplace.visualstudio.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (dns block)
  • martinfowler.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (dns block)
  • mobx.js.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (dns block)
  • modheader.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (dns block)
  • primereact.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (dns block)
  • www.base64encode.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (dns block)
  • www.npmjs.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (dns block)
  • www.nuget.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/a07aeef48358ad48/node_modules/.bin/linkinator Documentation/**/*.md --markdown --recurse --verbosity error --status-code 403:ok (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add a way to check if a user / principal is in role for React frontend</issue_title>
<issue_description>useIdentity() returns an IIdentityContext it would be nice to have a isInRole() method on it.

This entails adding roles as an Innumerable on the IdentityProviderResult in both the backend and string array in the frontend version. On the Identity in the frontend we should then have isInRole() method that takes the role and returns true or false.
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 17, 2026 13:27
Co-authored-by: einari <134365+einari@users.noreply.github.com>
Co-authored-by: einari <134365+einari@users.noreply.github.com>
Co-authored-by: einari <134365+einari@users.noreply.github.com>
Copilot AI changed the title [WIP] Add isInRole method to identity context Add role checking to identity context Feb 17, 2026
Copilot AI requested a review from einari February 17, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a way to check if a user / principal is in role for React frontend

2 participants

Comments