Skip to content

1️⃣ Add user source related auth providers

Jérémie Pardou requested to merge 2062-04-add-ab-auth-providers into develop

What is in this MR

This MR adds the auth providers for user source. It's heavily relying on the existing auth provider stuff. For now only one auth provider exists it's the "login/password" one for Local baserow user sources.

This MR also introduce the PolymorphicSerializer class that should simplify the handling of polymorphic models especially if they are nested.

What is not in this MR

  • The field type used as password field is not validated yet. We can associate any field even if it doesn't make sense.
  • Still not used for authentication

How to test this MR

The frontend is not yet there so it's more about checking the test files. However you can create a user source with auth_providers this way using curl:

$ export JWT_TOKEN="your_jwt_token"
$ export APP_ID="the_app_id"

# Mind to change the integration id and the password field id in the payload if necessary. You have to create it first

$ curl "http://localhost:8000/api/application/$APP_ID/user_sources/" -X POST -H 'Content-Type: application/json' -H "Authorization: JWT $JWT_TOKEN" --data-raw '{"type":"local_baserow","name":"Baserow table authentication","integration_id":42,"auth_providers": [{"type":"local_baserow_password","domain":"domain","enabled":true,"password_field_id":42}]}'

Then you can call this endpoint to list the content and check the presence for auth providers:

curl "http://localhost:8000/api/application/$APP_ID/user_sources/" -H 'Content-Type: application/json' -H "Authorization: JWT $JWT_TOKEN"

Or you can update the user_source auth providers:

export US_ID="the_id_of_just_created_user_source"
# Mind to change any value you want in the payload.
curl "http://localhost:8000/api/user_source/$US_ID/" -X PATCH -H 'Content-Type: application/json' -H "Authorization: JWT $JWT_TOKEN" --data-raw '{"auth_providers": [{"type":"local_baserow_password","domain":"new domain","enabled":true,"password_field_id":24}]}'

You can check:

  • That auth providers are created correctly
  • You can't have multiple password auth providers

Merge Request Checklist

  • changelog.md has been updated if required.
  • New/updated Premium/Enterprise features are separated correctly in the premium or enterprise folder
  • The latest Chrome and Firefox have been used to test any new frontend features
  • Documentation has been updated
  • Quality Standards are met
  • Performance: tables are still fast with 100k+ rows, 100+ field tables
  • The redoc API pages have been updated for any REST API changes
  • Our custom API docs are updated for changes to endpoints accessed via api tokens
  • The UI/UX has been updated following UI Style Guide

Related to #2062 (closed)

Edited by Jérémie Pardou

Merge request reports