Giter Club home page Giter Club logo

Comments (9)

emersion avatar emersion commented on June 10, 2024 1

Like this:

T2 OK [CAPABILITY IMAP4rev1 CHILDREN UNSELECT LITERAL+ NAMESPACE XLIST UIDPLUS ENABLE ID IDLE MOVE] LOGIN Completed.

from go-imap.

emersion avatar emersion commented on June 10, 2024 1

Section 7.1 describes these.

from go-imap.

emersion avatar emersion commented on June 10, 2024

This is v2 right?

v2 already tries to avoid requesting CAPABILITY if unnecessary, the issue is when something requires capabilities before the server sends them on its own. For instance, if a fresh client is created and then Authenticate is used. Authenticate checks whether the server supports SASL-IR, however a fresh client hasn't waited for the greeting, and we have no guarantee that the server will send the capabilities in its greeting. If we don't request capabilities at this point, then we'll potentially incur a cost of two roundtrips before sending the AUTHENTICATE command.

Which specific commands are you using that trigger the CAPABILITIES request? AFAIU LOGIN shouldn't trigger it.

from go-imap.

Rikkuru avatar Rikkuru commented on June 10, 2024

This is v2.

I think capabilities in response are parsed and then invalideted in the next line from server (when auth/login command ends )
At least i don't see what would prevent it from happening

T2 LOGIN "[email protected]" "password"
* CAPABILITY IMAP4rev1 CHILDREN UNSELECT LITERAL+ NAMESPACE XLIST UIDPLUS ENABLE ID IDLE MOVE # here handleCapability from readResponseData
T2 OK LOGIN Completed. // here invalidate the capabilities from readResponseTagged
T3 CAPABILITY
* CAPABILITY IMAP4rev1 CHILDREN UNSELECT LITERAL+ NAMESPACE XLIST UIDPLUS ENABLE ID IDLE MOVE

Here is what i was doing on login , later i call Caps to deside on options for List call

	if client.Caps().Has(goimap.CapStartTLS) {
		// good servers dont allow login and other plain auth methods without tls
		err = client.StartTLS(tlsConfig())
		if err != nil {
			return fmt.Errorf("StartTLS: %w", err)
		}
	}

	err = client.WaitGreeting()
	if err != nil {
		return fmt.Errorf("WaitGreeting: %w", err)
	}

	if client.Caps().Has(goimap.CapLoginDisabled) {
		return ErrLoginDisabled
        return client.Login(b.connSettings.Login, b.connSettings.Secret).Wait()

from go-imap.

emersion avatar emersion commented on June 10, 2024

You need to WaitGreeting before the STARTTLS stuff. That should help, I think?

from go-imap.

Rikkuru avatar Rikkuru commented on June 10, 2024

oh sorry this was a tls conn so starttls branch should not be here

updated flow is just create client , waitgreeting, check logindisabled (this code is common for tls and plain conn ) , login

LOGINDISABLED capability check is what initiated T1 capability command
then we login
T3 is initiated by next capability check after login wait

		client, err = dialTLS(
			host, port,
			timeout,
			tlsConfig(),
		)
		if err != nil {
			return fmt.Errorf("dialTLS: %w", err)
		}
		err = client.WaitGreeting()
		if err != nil {
			return fmt.Errorf("WaitGreeting: %w", err)
		}
	
		if client.Caps().Has(goimap.CapLoginDisabled) { // T1
			return ErrLoginDisabled
		return client.Login(b.connSettings.Login, b.connSettings.Secret).Wait() // T2

next list calls Caps

	if client.Caps().Has(goimap.CapSpecialUse) { // T3
		listOptions.ReturnSpecialUse = true
	}

I can write a complite example that reproduces the problem later ( gmail returns capabilities in login for example )

from go-imap.

emersion avatar emersion commented on June 10, 2024

Ah, OK, so the problem is not the CapLoginDisabled check. GMail doesn't return the capabilities in its greeting.

The problem is that the capabilities are sent in a response separate from the OK from LOGIN.

Section 7.2.2 says:

A server MAY send capabilities automatically, by using the CAPABILITY response code in the initial PREAUTH or OK responses and by sending an updated CAPABILITY response code in the tagged OK response as part of a successful authentication.

However GMail doesn't comply with this.

from go-imap.

Rikkuru avatar Rikkuru commented on June 10, 2024

so they mean server should send CAPABILITY response code in LOGIN response ?
like so ?

C: T1 LOGIN foo bar
S: T1 OK CAPABILITY IMAP4rev2 IDLE

seems wrong

from go-imap.

Rikkuru avatar Rikkuru commented on June 10, 2024

I found an example of this

1 LOGIN user pass
1 OK [CAPABILITY IMAP4REV1 UIDPLUS] Logged in.

Ok this seems like what they mean by this
If you know where in rfc they explain those square brackets pls let me know too )

from go-imap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.