-
Notifications
You must be signed in to change notification settings - Fork 2
Statnett-255: OBO authentication against Cognite for the chat bot backend app #64
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
base: main
Are you sure you want to change the base?
Conversation
7ac18af to
61d30cd
Compare
ef6d19b to
32c576d
Compare
32c576d to
227509f
Compare
tonyKunchev
left a comment
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.
It looks good, at least from what I can understand 😅
When I get access to Cognite and test the access from Jupyter Notebook on RNDP and from my dev machine, I will proceed with merging and releasing a new RC, then we can deploy to RNDP and test. I doubt it will work, but I'm not sure what else to do :( |
d0d34ca to
bf1d7ef
Compare
bf1d7ef to
bd29240
Compare
|
@mihailradkov @tonyKunchev @boyan-tonchev I've tested this locally with the RNDP configurations from Misho https://github.com/statnett/Talk2PowerSystem_PM/pull/275/files#diff-5a2250121396dd1c2098dafce92a1744bcad0b71025b8eee28e2dcdd808fdfdbR76, and what I now understand is that currently, the frontend is sending to the backend the |
034bb1a to
18a3af7
Compare
18a3af7 to
254166f
Compare
Neli, how does the frontend receives these tokens? Is there a different authentication workflow for the backend and frontend or is it a matter of calling auth endpoints with specific tokens/secrets? |
The frontend is using the msal library to obtain the tokens, both tokens are obtained within the same call. Boyan already modified the frontend to send the access_token to the backend instead of the id_token (statnett/Talk2PowerSystem_UI#37). The backend auth flow is modified to use OBO for Cognite. So, currently the expected behavior is:
|
|
I see. Is it enough for the frontend to pass the other token as well or do we need something more specific as flow? My guess is that there will be no issue in providing all tokens to the backend, although I am not sure how we are going to handle token refreshes and expiration. Have to check what does this frontend library does. We may need to implement or find similar library for the backend in order to avoid the mentioned issues. |
There is no need to provide both tokens. As far as I understand the good practice is to pass the access token , not the id token. The id token basically says "this is user X", while the access token carries information such as "user X has access to Cognite, to GraphDB, but not to some service Y". For the backend we use msal and python-jose. python-jose is used to verify the access token (the refresh and expiration are handled by the frontend app, which keeps the sessions) https://github.com/statnett/Talk2PowerSystem_LLM/pull/64/changes#diff-adcdb97740de29ad481ff42377f6050ed75eeb813cdf111ea58e650789c1efbaR51 . msal is used to obtain tokens for Cognite and according to the documentation it handles the refresh and expiration - https://github.com/statnett/Talk2PowerSystem_LLM/pull/64/changes#diff-9826184a8a506f2abbd9363a3f3b5d84d3e1c5154708eeeac2725996f76f4896R440 |
| - `tools.cognite.tenant_id` - REQUIRED iff `tools.cognite.interactive_client_id` is present - Azure tenant ID. For example, `a8d61462-f252-44b2-bf6a-d7231960c041`. | ||
| - `tools.cognite.token_file_path` - OPTIONAL - Full path on the disk to the cognite token file. For example, `/var/run/secrets/microsoft.com/entra/cognite`. | ||
| - `tools.cognite.token_file_path` - OPTIONAL - Full path on the disk to the cognite token file (used when you run the Jupyter Notebook on RNDP). For example, `/var/run/secrets/microsoft.com/entra/cognite`. | ||
| * `tools.cognite.client_secret` - OPTIONAL - Client secret for the Cognite confidential application (used for the backend app running on RNDP). |
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.
@tonyKunchev Please, advise if we need to modify the helm chart. Here, we add a new configuration property, which we read from the agent.yaml file .
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.
Please, also check the two new configuration properties described in the file docs/FastAPI.md
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.
I'll review the request again, because I've lost some context and check if any updates to the chart are needed.
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.
I think the chart is flexible enough to allow passing these new configurations without the need of modification. However, I think this one tools.cognite.client_secret should be passed as environment variable, if it is a secret. Otherwise, we have to set it as plain text in the agent config or chart configuration section, which is a bad practice.
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.
The corresponding environment variable name is COGNITE_CLIENT_SECRET
230efaf to
5a5abdb
Compare
|
Regarding the |
This is done statnett/Talk2PowerSystem_UI#37 |
No description provided.