Clem-Fern/rtabby-web-api

[Feature Request] Allow user create token by themself

Closed this issue · 3 comments

EkkoG commented

As #6 (comment) say, for now user can not create a token by themself

Add route /login, return a simple a tag page, click the a tag will open a GitHub auth URL with client_id https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#redirect-urls
Add route /loigin_redirect to receive the callback of URL from GitHub with code, after server receive the request, it can get a GitHub access token with the code https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#2-users-are-redirected-back-to-your-site-by-github

Get GitHub user id with the access token, create a user and return the user token.

I try to add a route at user.rs, it will protect by the auth system, I'm not familiar with Rust and Actix-Web, so for now I need to learn many things to imp the idea.

I was thinking about this too! It was my next step in my todo list.

Adding this feature would need to store users in database instead of in memory. Do you think local users and external users should coexist ?

I think a good way to implement this would be to add an env var like RTABBY_USERS_PROVIDER and then let admin decides between local and oauth.

EkkoG commented

I have created a PR implement both of the two auth method. Please review my pull request when you have time.

Hey @EkkoG,

I finally got the time to merge this feature. I reworked it a bit to only publish login endpoint when oauth provider is configured.

Thank's again for your work ;)