Skip to content

feat(add): init Guided provider setup #7

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

Merged
merged 11 commits into from
Jun 14, 2024
Merged

feat(add): init Guided provider setup #7

merged 11 commits into from
Jun 14, 2024

Conversation

joshnuss
Copy link
Collaborator

Adds a command called add to provide a guided setup for auth providers.

Requirements

  1. If [provider] is invalid or not provider, ask "What provider do you want to set up?"
  2. what's the hostname (default could be to detect the frameworks default localhost:port, + the basepath for the redirect url, eg. /api/auth for NextAuth.js, and /auth for all others)
  3. show the OAuth Registration URL (or maybe even open in the browser automatically?)
  4. copy the callback url to the clipboard and ask the user to paste it into the OAuth registration form
  5. ask for pasting the client id
  6. ask for pasting the client secret
  7. write to the framework's preferred .env
  8. inform to add the provider import in the correct file. (we can make it automatic in a follow-up PR)

☕️ Reasoning

Setting up providers can be a jarring experience, because all UIs and instructions are different. It would be nice to have a guided setup to reduce friction.

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

None

📌 Resources

@joshnuss
Copy link
Collaborator Author

joshnuss commented Jun 10, 2024

Notes

  1. Currently supporting Google, Apple, and GitHub
  2. It's not yet printing out code instructions, ie "add an import, update providers:"
  3. I've added a requireFramework() function that bails if the framework cannot be determined. Since auth secret was doing the same thing, figured logic could be shared.
  4. Clipboard code is not working on my machine (Linux Mint). The command ends up erroring. I debugged it and found it was using this command:
$> DISPLAY=:0 LC_CTYPE=UTF-8 /bin/xclip -i "http:/localhost:5173/auth/callbacks/google"
/bin/xclip: http:/localhost:5173/auth/callbacks/google: No such file or directory

Questions

  • Should non-oauth setups be supported too? For example, passwords, passwordless, sso/saml
  • Should there be tests?
  • Should instructions be in lib/meta.js? Right now providers is a mapping of key -> string, but we could change it to map to object that has the "instructions" data & name.
  • Should env vars be written to top of file or bottom (right now, it's placed at the top)

@balazsorban44 balazsorban44 changed the title Guided provider setup feat(add): init Guided provider setup Jun 14, 2024
@balazsorban44 balazsorban44 merged commit d0cfd07 into main Jun 14, 2024
@@ -36,7 +36,10 @@
"dependencies": {
"@inkeep/ai-api": "^0.7.2",
"@inquirer/prompts": "3.3.2",
"clipboardy": "^4.0.0",
"next": "0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@balazsorban44 Is this imported anywhere?

@balazsorban44 balazsorban44 deleted the add-provider branch July 3, 2024 15:15
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.

2 participants