Budget-Web-App / OneBudget-api

1 stars 0 forks source link

[Feature Request] Implement OAuth flow #15

Open michaeldcanady opened 1 year ago

michaeldcanady commented 1 year ago

Is your feature request related to a problem?

N/A

Describe the solution you'd like A clear and concise description of what you want to happen.

  1. Have the user go to /authorize with the following query parameters:

    client_id: str
    response_type: str
    redirect_uri: str
    scopes: List[str] = .default
    response_mode: str = "code"
    state: Optional[str] = None
  2. Have a authorizationCodeDB class, with a get_code method that takes in the scopes and state parameters.

  3. The get_code method generates a code, checks if code is globally unique, if so it writes the code as an entry in the DB, with the expiration date, and the state code.

  4. The get_code method returns the state code and authorization code

  5. /authorize, redirects to the provided redirect url, with the following parameters:

    code: str
    state: Optional[str]
    session_state: str
  6. User posts to /token with the follow body:

    {
    "grant_type": str,
    "client_id": str,
    "client_secret": str,
    "code": str,
    "redirect_uri": str,
    "scope": str
    }
  7. Have authorizationCodeDB with a check_code method that takes code and scope. It checks the code against the database table, makes sure the code isn't expired and the scopes match.

  8. /token returns the following response:

{ "token_type": "Bearer", "scope": "user.read%20Fmail.read", "expires_in": 3600, "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...", "refresh_token": "AwABAAAAvPM1KaPlrEqdFSBzjqfTGAMxZGUTdM0t4B4..." }



Additional context
N/A