aaron-wolmutt commented on PR #58292:
URL: https://github.com/apache/airflow/pull/58292#issuecomment-3572148367

   > What is the goal of such endpoint? If the goal is the UI can use it to 
enable/disable some UI elements, then I think we should go with this 
[approach](https://github.com/apache/airflow/issues/57966#issuecomment-3571803446).
   
   Yeah the goal would be to enable/disable buttons. I think we could have 
hooks on the front end to access whether the component is disabled or enabled. 
It's just hard to do without violating the design. 
   
   We use Okta at work, so you can access the authenticated users 
permissions/role with the useOktaAuth hook like this.  It looks user role is 
accessed from claims in okta, so you could put the users role in claims 
(viewer, user, admin, op). 
   
   ```javascript
   import React, { useEffect, useState } from 'react';
   import { useOktaAuth } from '@okta/okta-react';
   
   function UserRoles() {
     const { authState, oktaAuth } = useOktaAuth();
     const [userRoles, setUserRoles] = useState([]);
   
     useEffect(() => {
       if (authState && authState.isAuthenticated) {
         // Assuming roles are included as a custom claim, e.g., "roles"
         const roles = authState.idToken?.claims.roles || []; 
         setUserRoles(roles);
       }
     }, [authState]);
   
     if (!authState || !authState.isAuthenticated) {
       return <div>Not authenticated</div>;
     }
   
     return (
       <div>
         <h2>Your Roles:</h2>
         {userRoles.length > 0 ? (
           <ul>
             {userRoles.map((role, index) => (
               <li key={index}>{role}</li>
             ))}
           </ul>
         ) : (
           <p>No roles found.</p>
         )}
       </div>
     );
   }
   
   export default UserRoles;
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to