Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

OctopusClient and SPNEGO #885

Open
gfody opened this issue Oct 23, 2024 · 0 comments
Open

OctopusClient and SPNEGO #885

gfody opened this issue Oct 23, 2024 · 0 comments

Comments

@gfody
Copy link

gfody commented Oct 23, 2024

OctopusClient.SignIn throws if no password or api token is provided. As a workaround I can do this:

var client = new OctopusClient(new OctopusServerEndpoint(my_server_that_uses_negotiate_auth_scheme));
var state = JsonConvert.SerializeObject(new { RedirectAfterLoginTo = "/app#", UsingSecureConnection = true });
//client.SignIn(new LoginCommand()); <-- error: missing username & password
client.GetContent($"integrated-challenge?state={Uri.EscapeDataString(state)}");

Readonly stuff then works but any writes throw:
OctopusSecurityException: A required anti-forgery token was not supplied or was invalid.

As a workaround, I hacked the SignIn method (see below) but is there a supported way to do this already?

index aa33e29b..3e94820c 100644
--- a/source/Octopus.Server.Client/OctopusClient.cs
+++ b/source/Octopus.Server.Client/OctopusClient.cs
@@ -108,7 +108,11 @@ public void SignIn(LoginCommand loginCommand)
             {
                 loginCommand.State = new LoginState { UsingSecureConnection = IsUsingSecureConnection };
             }
-            Post(Repository.LoadRootDocument().Links["SignIn"], loginCommand);
+
+            if (loginCommand.Password == null)
+                GetContent($"integrated-challenge?state={Uri.EscapeDataString(JsonConvert.SerializeObject(new { RedirectAfterLoginTo = "/app#", UsingSecureConnection = true }))}");
+            else
+                Post(Repository.LoadRootDocument().Links["SignIn"], loginCommand);

             antiforgeryCookieName = cookieContainer.GetCookies(cookieOriginUri)
                 .Cast<Cookie>()
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant