Skip to content

Ability to close a WebOAuthServer without a successful login #2197

@gabriel-keith

Description

@gabriel-keith

When authorizing a org with WebOAuthServer it's creates a http server on the local machine. Currently the only way to close this server is a successful org authentication or to close the entire application. If the user then decides that they do not wish to add an org this prevents them from entirely stopping the authentication process without closing the application.

If WebOAuthServer had a method such as

public stop(): void {
  this.webServer.close();
}

then this would provide the ability to programmatically shut down the server.

Also the promise for authorizeAndSave should be rejected if the server is prematurely closed without authentication with an error indicating it was programmatically closed.

The only alternative I've considered is to leave the server running if the user decided to stop authenticating but this prevents them from authenticating with a different url in the future without restarting the application.

This problem is in the context of an electron app to manage sfdx orgs but may have other applications. I'm currently using a fork of sfdx to provide this functionality and would be happy to create a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:authAuthorization Experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions