Skip to content
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

Wanted to extend UserAgentBuilder class to pass custom user-agent value #60

Open
PranithaReddyAedla opened this issue Mar 7, 2021 · 13 comments

Comments

@PranithaReddyAedla
Copy link

PranithaReddyAedla commented Mar 7, 2021

I wanted to pass custom user-agent value for all factor authn requests

For that, I wanted to extend UserAgentBuilder class of Okta.Sdk.Abstractions and modify Generate() method to achieve what I wanted exactly. Since, UserAgentBuilder class is being a sealed type class that is not being possible now.

Currently, UserAgentBuilder generates user-agent value as "custom/{sdk-version} runtime/{runtime-info} os/{os-info}"

But, the following is how I need generate to user-agent value.
User-Agent = "machineName/{machine-name-here} machineIp/{ip-address-here} os/{os-info-here} runtime/{runtime-info-here}

private string Generate()
        {
            var machineName = $"machineName/{Environment.MachineName}";

            var machineIP = $"machineIP/{this.GetLocalIPAddress()}";

            var runtimeToken = $"runtime/{UserAgentHelper.GetRuntimeVersion()}";

            var operatingSystemToken = $"os/{Sanitize(RuntimeInformation.OSDescription)}";

            return string.Join(
                " ",
                machineName,
                machineIP,
                operatingSystemToken,
                runtimeToken)
            .Trim();
        }

Could you please me help with this? Is it possible to modify access-specifier of UserAgentBuilder? Or Is there any possible way that you can propose to solve my issue?

@bryanapellanes-okta
Copy link
Contributor

@PranithaReddyAedla,
Thank you for reaching out! The UserAgentBuilder class is sealed because it is used to define a user agent string that identifies clients to the Okta api for analytics and reporting purposes. It is not possible to modify because the user agent values are used internally by Okta. Please let me know if I have misinterpreted your question.

Thanks for using Okta!

@laura-rodriguez
Copy link
Collaborator

laura-rodriguez commented Mar 8, 2021

Hi @PranithaReddyAedla,

There are certain methods that allow you to provide your own user-agent. Have checked this section in our readme? Does it cover your use case?

@PranithaReddyAedla
Copy link
Author

@PranithaReddyAedla,
Thank you for reaching out! The UserAgentBuilder class is sealed because it is used to define a user agent string that identifies clients to the Okta api for analytics and reporting purposes. It is not possible to modify because the user agent values are used internally by Okta. Please let me know if I have misinterpreted your question.

Thanks for using Okta!

Thank you for responding. @bryanapellanes-okta

@PranithaReddyAedla
Copy link
Author

Hi @PranithaReddyAedla,

There are certain methods that allow you to provide your own user-agent. Have checked this section in our readme? Does it cover your use case?

Hey @laura-rodriguez, Thank you for responding.
But I could not access the link you provided. It is asking to authenticate via dotnet-sdk.okta tenant. Could you please share snippet of readme!?

@laura-rodriguez
Copy link
Collaborator

Hi @PranithaReddyAedla,

I've updated the link with the right URL this time 😅 ! Sorry about that.

https://github.com/okta/okta-auth-dotnet/#send-information-via-requests-headers

@PranithaReddyAedla
Copy link
Author

PranithaReddyAedla commented Mar 8, 2021

@laura-rodriguez Thank you.

Yeah, for primary authentication, we could pass custom user-agent. But, for factor authentications we don't have that option right. For futher proccedings after primary authentications I need to pass custom user-agent through out for all the calls.

@laura-rodriguez
Copy link
Collaborator

Thanks for your feedback @PranithaReddyAedla. You're right, that's not supported at the moment.

Would you mind sharing why you need to send this info? Do you need this info to satisfy some sort of policy or just for tracking purposes?

I'd like to understand your use case better to see how we can help.

@PranithaReddyAedla
Copy link
Author

@laura-rodriguez Wanted it for tracking purposes. Need that custom user agent to reflect in okta sys logs. We want to track, which machine (machine name and IP address) of the organization is accessing.

@laura-rodriguez
Copy link
Collaborator

Thanks for sharing @PranithaReddyAedla!

I put a ticket in our backlog to be prioritized.

In the meantime, your best option is to fork the project and customize it with your implementation.

@PranithaReddyAedla
Copy link
Author

Thanks a ton @laura-rodriguez for adding it to the backlog and responding.

@PranithaReddyAedla
Copy link
Author

Hi @laura-rodriguez @bryanapellanes-okta
Any update on this issue please?

@bryanapellanes-okta
Copy link
Contributor

bryanapellanes-okta commented Jul 8, 2022

@PranithaReddyAedla Thanks for checking in and sorry for the delay. I've started an internal thread on this topic with PM. We'll update here when there's more.

Internal Link: https://oktainc.atlassian.net/browse/OKTA-377094?focusedCommentId=2732757

cc @bretterer @laura-rodriguez

@PranithaReddyAedla
Copy link
Author

@bryanapellanes-okta Thanks for your response and for opening an internal thread.

cc @bryanapellanes-okta @laura-rodriguez @bretterer
Along with this, Could you also consider to give an option to pass Browser, OS and RawUserAgent values seperately?

As of now user-agent is of string type. Due to that, the value being passed is only assigned to RawUserAgent directly and browser is UNKNOWN always.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants