Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support for SSO basic-auth without dialogue. #1268

Conversation

lecler-i
Copy link
Contributor

Added two new config keys : ssoUser, ssoPasswordCommand that will be used instead of the regular login/password dialogue.

Authentication will be setup with the login with content of ssoUser key, and the password will be the stdout of the execution of the command in ssoPasswordCommand.

Example of config :

{
  "ssoUser": "Thomas",
  "ssoPasswordCommand": "gopass -o work/mycompany.com"
}

@lecler-i lecler-i mentioned this pull request May 24, 2024
if (ssoUser && ssoPasswordCommand) {
//TODO: Implement a timeout ?
console.log(`Retrieve password using command : ${ssoPasswordCommand}`);
exec(ssoPasswordCommand, (error, stdout, stderr) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fairly new to nodejs, maybe document if this is running in a shell or not (to be able to use pipes ect in the provided ssoPasswordCommand

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify this by using execSync. Something like:

Suggested change
exec(ssoPasswordCommand, (error, stdout, stderr) => {
try {
const ssoPassword = execSync(ssoPasswordCommand).toString();
callback(ssoUser, ssoPassword);
} catch (error) {
console.error(`Failed to execute ssoPasswordCommand. Status Code: ${error.status} with '${error.message}'`);
}

I haven't tried the code but that should execute it synchronously and I think that is ok in this case.

@lecler-i lecler-i changed the title Support for SSO autentication without dialogue. Support for SSO basic-auth without dialogue. May 24, 2024
Copy link
Owner

@IsmaelMartinez IsmaelMartinez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After applying the changes, if you can increase the number in the package.json (to 1.4.40) and add a line in the https://github.com/IsmaelMartinez/teams-for-linux/blob/develop/com.github.IsmaelMartinez.teams_for_linux.appdata.xml#L17 with what was added, then I can get it released soon (as a pre-release 1st)

describe: 'Command to execute to retrieve password for SSO auth.',
type: 'string'
},

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the empty lines in 145 and 156 (maybe is just the editor showing them to me)

@@ -142,6 +142,18 @@ function argv(configPath, appVersion) {
describe: 'Custom Client Certs password for corporate authentication (certificate must be in pkcs12 format)',
type: 'string'
},

ssoUser: {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the 'REAME.md' file in this folder with this two options? I try to put them in alphabetical order but people tend to ignore that 😄

if (ssoUser && ssoPasswordCommand) {
//TODO: Implement a timeout ?
console.log(`Retrieve password using command : ${ssoPasswordCommand}`);
exec(ssoPasswordCommand, (error, stdout, stderr) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify this by using execSync. Something like:

Suggested change
exec(ssoPasswordCommand, (error, stdout, stderr) => {
try {
const ssoPassword = execSync(ssoPasswordCommand).toString();
callback(ssoUser, ssoPassword);
} catch (error) {
console.error(`Failed to execute ssoPasswordCommand. Status Code: ${error.status} with '${error.message}'`);
}

I haven't tried the code but that should execute it synchronously and I think that is ok in this case.

@IsmaelMartinez
Copy link
Owner

Thanks for contributing!

@IsmaelMartinez IsmaelMartinez marked this pull request as ready for review May 24, 2024 12:53
@lecler-i
Copy link
Contributor Author

Oh yea sorry for the readme,config and version bump, was just a super-quick draft.
I will take your comments into consideration and do more test before a proper submit, but the change is quite simple so hopefully it won't have too much side-effects :D

@IsmaelMartinez
Copy link
Owner

sorry, wrong thumps . As it is under a feature flag (config option) I am less worried as it should not change the default use case, but I tend to release it under a pre-release so people can try it before it hits the large amount of users. Thanks again!

@lecler-i lecler-i force-pushed the feature/sso-login-exec-command-for-password branch from a90f9cb to 85a4453 Compare May 24, 2024 12:59
Added two new config keys : `ssoUser`, `ssoPasswordCommand` that will be used instead of the regular login/password
dialogue.

Authentication will be setup with the `login` with content of `ssoUser` key, and the password will be the stdout of the
execution of the command in `ssoPasswordCommand`.

Example of config :

```json
{
  "ssoUser": "Thomas",
  "ssoPasswordCommand": "gopass -o work/mycompany.com"
}
```
@lecler-i lecler-i force-pushed the feature/sso-login-exec-command-for-password branch from 85a4453 to cc99708 Compare May 24, 2024 13:11
@IsmaelMartinez
Copy link
Owner

let me know once you are finished and I can create the pre-release. Thanks again!

@lecler-i
Copy link
Contributor Author

Ok i've updated README, bumped the version and using execSync.
Codebeat is complaning about code styling tho, not sure what to do about it...

But it's good to me, tested and working.

@IsmaelMartinez IsmaelMartinez merged commit 0110cca into IsmaelMartinez:develop May 24, 2024
3 of 4 checks passed
@IsmaelMartinez
Copy link
Owner

aye, its fine to me also so merging. Thanks again! I will announce the release on the other issue.

@lecler-i
Copy link
Contributor Author

Might wanna rename the parameters to "basicAuthLogin" / Password or smthing before release ?

@IsmaelMartinez
Copy link
Owner

done it in the 1.5.0. Thanks again for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants