After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 783781 - [Negotiate] Authentication should success in some cases when gss_init_sec_context() returns error
[Negotiate] Authentication should success in some cases when gss_init_sec_con...
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: Misc
2.58.x
Other Linux
: Normal normal
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks: 783780
 
 
Reported: 2017-06-14 10:20 UTC by Tomas Popela
Modified: 2017-06-22 13:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (1.71 KB, patch)
2017-06-14 10:22 UTC, Tomas Popela
accepted-commit_now Details | Review
Proposed patch 2 (3.72 KB, patch)
2017-06-19 14:05 UTC, Tomas Popela
reviewed Details | Review
Proposed patch 3 (2.44 KB, patch)
2017-06-19 14:43 UTC, Tomas Popela
none Details | Review
Proposed patch 4 (9.63 KB, patch)
2017-06-19 16:04 UTC, Tomas Popela
none Details | Review
Proposed patch 5 (2.05 KB, patch)
2017-06-19 16:09 UTC, Tomas Popela
accepted-commit_now Details | Review

Description Tomas Popela 2017-06-14 10:20:56 UTC
Unfortunately, so many programs (curl, Firefox) ignore the return token that is included in the response, so it is possible that there are servers that send back broken stuff.  Try to behave in the right way (pass the token to gss_init_sec_context()), show a warning, but don't fail if the server returned 200.

There is an internal Red Hat site that triggers the described situation and the "Invalid token was supplied: Unknown error" is being printed to the console.

This change was suggested by Simo Sorce.
Comment 1 Tomas Popela 2017-06-14 10:22:58 UTC
Created attachment 353737 [details] [review]
Proposed patch
Comment 2 Dan Winship 2017-06-19 13:39:04 UTC
Comment on attachment 353737 [details] [review]
Proposed patch

ok (but maybe reorganize everything between soup_gss_client_step() and "out:" into a "switch (ret) { ..." ?)
Comment 3 Tomas Popela 2017-06-19 14:04:44 UTC
(In reply to Dan Winship from comment #2)
> ok (but maybe reorganize everything between soup_gss_client_step() and
> "out:" into a "switch (ret) { ..." ?)

Thank you for the review Dan. I'm attaching an updated patch that I will commit once the blocked bug will be committed.
Comment 4 Tomas Popela 2017-06-19 14:05:52 UTC
Created attachment 354043 [details] [review]
Proposed patch 2
Comment 5 Dan Winship 2017-06-19 14:25:06 UTC
Comment on attachment 354043 [details] [review]
Proposed patch 2

>+		if (!soup_gss_build_response (conn, SOUP_AUTH (auth), &err)) {
>+			/* FIXME: report further upward via

(this patch currently has the other bug's patch in it too but I assume that will get fixed)


>+	switch (ret) {
>+	case AUTH_GSS_COMPLETE:
>+		priv->is_authenticated = ret == AUTH_GSS_COMPLETE;

aka: priv->is_authenticated = TRUE

>+	case AUTH_GSS_CONTINUE:
> 		conn->state = SOUP_NEGOTIATE_RECEIVED_CHALLENGE;
>+		break;

do you need to set priv->is_authenticated to FALSE in any of these other cases?
Comment 6 Tomas Popela 2017-06-19 14:40:36 UTC
(In reply to Dan Winship from comment #5)
> Comment on attachment 354043 [details] [review] [review]
> Proposed patch 2
> 
> >+		if (!soup_gss_build_response (conn, SOUP_AUTH (auth), &err)) {
> >+			/* FIXME: report further upward via
> 
> (this patch currently has the other bug's patch in it too but I assume that
> will get fixed)

Yes, it got mixed up. I will attach an updated version.

> >+	switch (ret) {
> >+	case AUTH_GSS_COMPLETE:
> >+		priv->is_authenticated = ret == AUTH_GSS_COMPLETE;
> 
> aka: priv->is_authenticated = TRUE

Obviously.

> >+	case AUTH_GSS_CONTINUE:
> > 		conn->state = SOUP_NEGOTIATE_RECEIVED_CHALLENGE;
> >+		break;
> 
> do you need to set priv->is_authenticated to FALSE in any of these other
> cases?

Yes. I will initialize priv->is_authenticated to FALSE.
Comment 7 Tomas Popela 2017-06-19 14:43:32 UTC
Created attachment 354046 [details] [review]
Proposed patch 3
Comment 8 Dan Winship 2017-06-19 15:50:22 UTC
Comment on attachment 354046 [details] [review]
Proposed patch 3

oh, you don't have to set it at init time. priv will always be initialized to all-bits-0, so is_authenticated will start out as FALSE. I was just wondering if there were situations where it would get set TRUE in one round but then need to get set back to FALSE later
Comment 9 Tomas Popela 2017-06-19 16:01:12 UTC
(In reply to Dan Winship from comment #8)
> Comment on attachment 354046 [details] [review] [review]
> Proposed patch 3
> 
> oh, you don't have to set it at init time. priv will always be initialized
> to all-bits-0, so is_authenticated will start out as FALSE. I was just
> wondering if there were situations where it would get set TRUE in one round
> but then need to get set back to FALSE later

I don't think that there will be situations like that. Once it will be set to TRUE, then this code won't be called again as there are checks in SoupAuth whether the auth is already authenticated.
Comment 10 Tomas Popela 2017-06-19 16:04:13 UTC
Created attachment 354050 [details] [review]
Proposed patch 4

Remove unnecessary initialization of is_authenticated.
Comment 11 Tomas Popela 2017-06-19 16:05:10 UTC
(In reply to Tomas Popela from comment #10)
> Created attachment 354050 [details] [review] [review]
> Proposed patch 4
> 
> Remove unnecessary initialization of is_authenticated.

Wrong patch attached..
Comment 12 Tomas Popela 2017-06-19 16:09:31 UTC
Created attachment 354051 [details] [review]
Proposed patch 5
Comment 13 Tomas Popela 2017-06-22 13:55:58 UTC
Fixed with commit aefe8eac in the master branch.