Skip to content

Authentication UI is not showing Sessions restored from State #13599

@tsmaeder

Description

@tsmaeder

Bug Description:

When an AuthenticationProvider restores sessions from stored state (e.g. secrets storage), no changed even may be sent. In this case, the front end is never notified. We should notify the front end of any initial sessions when a authentication provider is registered.

Steps to Reproduce:

  1. Log in with some authentication provider
  2. Restart Theia
  3. Observe the session is active, but you cannot see ti when you click on the little manikin icon at the bottom of the left sidebar: when you click it, it says "You are not logged into any accounts".

Unfortunately, I have no ready scenario to reproduce this: I noticed it with my github login, which you cannot reproduce with the current github-autentication extension (#12821)

Additional Information

Fix in authentication-ext.ts would look like this:

    registerAuthenticationProvider(id: string, label: string, provider: theia.AuthenticationProvider, options?: theia.AuthenticationProviderOptions): theia.Disposable {
        if (this.authenticationProviders.get(id)) {
            throw new Error(`An authentication provider with id '${id}' is already registered.`);
        }

        this.authenticationProviders.set(id, provider);
        provider.getSessions().then(sessions => {
            if (sessions.length > 0) {
                this.proxy.$onDidChangeSessions(id, {
                    added: sessions,
                    removed: [],
                    changed: []
                });
            }
        });
        const listener = provider.onDidChangeSessions(e => {
            this.proxy.$onDidChangeSessions(id, e);
        });

        this.proxy.$registerAuthenticationProvider(id, label, !!options?.supportsMultipleAccounts);

        return new Disposable(() => {
            listener.dispose();
            this.authenticationProviders.delete(id);
            this.proxy.$unregisterAuthenticationProvider(id);
        });
    }
  • Operating System:
  • Theia Version:

Metadata

Metadata

Assignees

No one assigned

    Labels

    authenticationissues related to authentication (ex: authentication api)vscodeissues related to VSCode compatibility

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions