supertokens / supertokens-core

Open source alternative to Auth0 / Firebase Auth / AWS Cognito
https://supertokens.com
Other
12.88k stars 503 forks source link

Make SuperTokens an OAuth and Open ID provider #582

Open rishabhpoddar opened 1 year ago

rishabhpoddar commented 1 year ago

Opened this in favour of: https://github.com/supertokens/for-zenhub/issues/108

We want to support:

Google doc discussion here:

Test case TODOs

TODO

TODOs with hydra:

ykdojo commented 1 year ago

Thank you for sending this to me. Neither of the documents is publicly visible, though.

rishabhpoddar commented 1 year ago

@ykdojo those docs are internal at the moment. You can follow this issue to be notified when we release this feature.

rishabhpoddar commented 1 year ago

Cronjobs

TODO

rishabhpoddar commented 1 year ago

New core configs

rishabhpoddar commented 5 months ago

Screenshot 2024-04-30 at 12 23 47

tamassoltesz commented 2 months ago

Hydra /admin/clients endpoint behaviours: GET /admin/clients/{clientId}

  1. existing ClientID: returns 200 and the client json in body
  2. not existing clientID: returns 404, and the following json:
    {
    ""error"": ""Unable to locate the resource"",
    ""error_description"": """"
    }

    Expected core response:

  3. in case of found client return 200 and the client info in json body.
  4. in case of not found client: return 200 with something like {status: OAUTH2_CLIENT_NOT_FOUND_ERROR}

DELETE /admin/clients/{clientId}

  1. in case of existing client id: 204 with empty body
  2. in case of not existing client id: 404 - previously mentioned "Unable to locates the resource" json body.

Expected core response:

  1. in case of successful delete: 200 - {status: OK}
  2. in case of not found client: 200 - {status: OAUTH2_CLIENT_NOT_FOUND_ERROR}

POST /admin/clients with json body

  1. valid json body in every aspect: 201 - created client as json body

  2. trying to create a client with already existing client id: 409 and the following json body:

    "{
    ""error"": ""Unable to insert or update resource because a resource with that value exists already"",
    ""error_description"": """"
    }"
  3. invalid json body: 400 - and a json in the {error:..., error_description:...} format. Invalid json body here means that some field contained a not allowed value or some field was missing from the input json.

Expected core behaviour:

  1. succesful create, core returns: 200 - {status: OK, client: {created_client_json}}
  2. already existing id: core silently generates a new id and retries until success or other type of error happens
  3. invalid json: core returns: BadRequestException(error - errorDescription)

PATCH /admin/clients/{clientId} with jsonBody

  1. empty json as body: 500, jsonBody: {error: "error", error_description: "The error is unrecognizable"}
  2. no body: see 1.
  3. missing required fields from body: see 1.
  4. valid json body: 200, updated client info
  5. valid json format, operation with invalid value: see 1.
  6. invalid {clientId}: 404 jsonBody {error: "Unable to locate resource", error_description: ""}
  7. invalid content as value (for example * as allowed_cors_origins: 400, {error: errorMsg, error_description: errorDescriptionMsg}
  8. Using the wrong method (for example replace for an empty list instead of add: see 1.

expected core behaviour:

  1. in case of 500 response from hydra: return 500, "Internal Error"
  2. in case of 400 response from hydra: return BadRequestException(error - errorDescription)
  3. in case of 404 response from hydra: return 200, {status: OAUTH2_CLIENT_NOT_FOUND_ERROR}
  4. in case of 200 response from hydra: return 200, {status: OK, client: <updated_client_from_hydra>}
tamassoltesz commented 2 months ago

Hydra /oauth2/auth endpoint behaviour: GET Only GET is supported. Input params are passed as query params. Response is sent with headers. Location and Set-Cookies are the interesting ones for us.

  1. valid auth query: 302 - Location header set to: {configured hydra login uri}/login..., Set-Cookie header with ory_hydra_login_csrf_....=...
  2. missing required param: 302 - Location header set to {hydra_instance}/{error_fallback} with query params of error and error_description
  3. invalid value in required param: 303 - Location header set to {clients_redirect_uri} with error and error_description query params
  4. not existing client: 302 - Location header set to {hydra_instance}/{error_fallback} with query params of error and error_description

Expected core behaviour:

  1. replace the {configured hydra login uri} address with the string {apiDomain}. Response in the format of {status: OK, redirectTo: {apiDomain}..., cookies: [set-cookies]}
  2. return 200 - {status: OAUTH2_AUTH_ERROR, error: <error_from_hydra>, errorDescription: <error_description_from_hydra>}
  3. return 200 - Response in the format of {status: OK, redirectTo: returned_redirectTo, cookies: [set-cookies]}
  4. like case 2: 200 - {status: OAUTH2_AUTH_ERROR, error: <error_from_hydra>, errorDescription: <error_description_from_hydra>}