tirkarthi opened a new issue, #61817:
URL: https://github.com/apache/airflow/issues/61817

   ### Description
   
   HITL operator provides an option where `assigned_users` could be set and 
only the users selected can update the HITL action. The assigned_users should 
be a list of id and name. The username is visible in sidebar but in the auth 
manager it just looks for the current_user.id to be one of `id` values in 
assigned users. Since `id` is not visible in the UI and it's mandatory in the 
datamodel it becomes harder for the users to use this feature.
   
   The `http://localhost:8000/ui/auth/me` endpoints the id info in the response 
`{"id":"1","username":"admin"}`. This can be displayed along with the signed in 
username in the sidebar. This can help user in letting others know their id to 
be used in the dags. A workaround would be fetching id stored in jwt token but 
it would involve user copying the token and decrypting it which is not user 
friendly.
   
   
   ```python
   from __future__ import annotations
   
   import pendulum
   
   from airflow.providers.standard.operators.hitl import (
       HITLOperator,
   )
   from airflow.sdk import DAG
   
   with DAG(
       dag_id="example_hitl_operator_with_assignee",
       start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
       catchup=False,
       tags=["example", "HITL"],
   ):
       wait_for_default_option = HITLOperator(
           task_id="wait_for_default_option",
           subject="Please choose option to proceed: ",
           options=["option 7", "option 8", "option 9"],
           defaults=["option 7"],
           assigned_users=[{"id": "1", "name": "airflow"}, {"id": "admin", 
"name": "admin"}],
       )
   ```
   
   ### Use case/motivation
   
   user.id being visible in the UI helps in using the id value in 
assigned_users.
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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