Skip to content

Conversation

@mjkkirschner
Copy link
Member

@mjkkirschner mjkkirschner commented Feb 28, 2025

Purpose

https://jira.autodesk.com/browse/DYN-7925

As we have more and more packages requiring authentication and authorization it makes sense to make it simpler for package authors to retrieve the current access token.

Currently, to retrieve the current access token, a package author needs to implement an extension, get the authprovider, then introduce a static api to retrieve the token from the extension in their nodes.

Let's just skip all that - this PR adds a method to DynamoServices: AuthServicesEvents.OnRequestAuthProvider() which DynamoModel handles by returning to the current auth provider if one exists.

It's implemented this way to avoid needing to add new references to DynamoServices and to enable ZT authors to avoid referencing DynamoCore.dll etc.

This should cover more use cases than the initial implementation.

This PR also starts multi targeting DynamoServices ( starts targeting net8 as well as netstd2) and adds this new target to the DynamoServices nuget package. This change was made so that we could use the Experimental attribute to guard the new API until we are satisfied with its design. For netstd2 builds we fallback to using the obsolete attribute which is less fitting and is ignorable by clients. Experimental attribute requires opt in.

image

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB

Release Notes

Adds a static API for accessing current auth provider.

Reviewers

@github-actions github-actions bot changed the title make access token accessible to all package authors using executesession DYN-7925: make access token accessible to all package authors using executesession Feb 28, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-7925

@pinzart90
Copy link
Contributor

@mjkkirschner I am still not sure how the access token is going to be used by authors. At the node implementation level ?
ExecutionSession is a static, but is it accessible from all the Node code paths an author might write code in ?
I would hope we can alter this later without having jumping through all the "breaking public APIs" hoops

@mjkkirschner
Copy link
Member Author

mjkkirschner commented Feb 28, 2025

@pinzart90 - yes, any node author can access an execute session, from ZT, python, or NodeModels.

Unfortunately @saintentropy showed me an example of the DX nodes where this implementation will not work - it's a UI node that requires auth before the graph is executed - so I will change this implementation to support that use case as well.

@zeusongit
Copy link
Contributor

@pinzart90 - yes, any node author can access an execute session, from ZT, python, or NodeModels.

Unfortunately @saintentropy showed me an example of the DX nodes where this implementation will not work - it's a UI node that requires auth before the graph is executed - so I will change this implementation to support that use case as well.

So just to confirm, the token will be available to authors pre-graph execution, as opposed to what the PR description says (that you may implement that later)?

@mjkkirschner
Copy link
Member Author

@pinzart90 - yes, any node author can access an execute session, from ZT, python, or NodeModels.
Unfortunately @saintentropy showed me an example of the DX nodes where this implementation will not work - it's a UI node that requires auth before the graph is executed - so I will change this implementation to support that use case as well.

So just to confirm, the token will be available to authors pre-graph execution, as opposed to what the PR description says (that you may implement that later)?

yes, that's correct @zeusongit - I will update the PR description when this is ready for another look.

@mjkkirschner
Copy link
Member Author

@pinzart90 if you are concerned that this API may change or need some more iteration cycles we can leverage the experimental attrbiute:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-12.0/experimental-attribute

this will require package authors to opt-in explicitly to using this experimental feature or they will get a compile error. I personally would like to see this approach taken more often to avoid the buildup of WIP APIs we cannot remove.

@mjkkirschner mjkkirschner removed the WIP label Mar 1, 2025
@mjkkirschner mjkkirschner changed the title DYN-7925: make access token accessible to all package authors using executesession DYN-7925: make access token accessible to all package authors using static method Mar 3, 2025
@mjkkirschner
Copy link
Member Author

mjkkirschner commented Mar 3, 2025

@pinzart90 if you are concerned that this API may change or need some more iteration cycles we can leverage the experimental attrbiute: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-12.0/experimental-attribute

this will require package authors to opt-in explicitly to using this experimental feature or they will get a compile error. I personally would like to see this approach taken more often to avoid the buildup of WIP APIs we cannot remove.

@pinzart90 @aparajit-pratap 😢 - so because the DynamoServices dll targets netstd2 and not net8 we cannot easily use the [experimental] attribute - Is there still a good reason that DynamoServices does not target net8? Something to do with LibG or package authors still targeting net48? Can we move everything up to net8 now?

@pinzart90
Copy link
Contributor

e targets netstd2 and not net8 we cannot easily use the [experimental] attribute - Is there still a good reason that DynamoServices does not target net std 2? Something to do with

The only reason for netstd2 was to be compatible with net48 at the same time. If we no longer want to do releases of LibG for net48 or if we want to do multi targeting (which complicates the CICD process) then we can move it on up.

@pinzart90
Copy link
Contributor

@mjkkirschner what version of DynamoServices (net8 or std) will be used by nuget restore when consumed in a net8 csproj?
Hopefully nuget knows to restore exact matches with the highest priority

@mjkkirschner
Copy link
Member Author

@mjkkirschner what version of DynamoServices (net8 or std) will be used by nuget restore when consumed in a net8 csproj? Hopefully nuget knows to restore exact matches with the highest priority

I can verify, but it should be the highest matching framework target IIRC.

@mjkkirschner
Copy link
Member Author

@mjkkirschner what version of DynamoServices (net8 or std) will be used by nuget restore when consumed in a net8 csproj? Hopefully nuget knows to restore exact matches with the highest priority

I can verify, but it should be the highest matching framework target IIRC.

confirmed @pinzart90 - it picks the right one based on the target of the referencing project.

@mjkkirschner mjkkirschner merged commit 62fc583 into DynamoDS:master Mar 4, 2025
22 of 23 checks passed
@mjkkirschner mjkkirschner deleted the authprovider_static branch March 4, 2025 01:11
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.

5 participants