Skip to content

Conversation

@stuntguy3000
Copy link
Contributor

Fixes: #12870

This change allows the TokenProvision API to accept all values applicable to the Token field, providing more user flexibility and use cases.

Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

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

We should avoid using two different serializers for the same data. Instead, TokenProvisionSerializer should be extended to support the necessary fields.

@stuntguy3000
Copy link
Contributor Author

stuntguy3000 commented Jun 15, 2023

We should avoid using two different serializers for the same data. Instead, TokenProvisionSerializer should be extended to support the necessary fields.

My concern here is that if we were to duplicate this serializer, we're introducing two different serializers (with the same non-default constraints) (as shown below), to functionally decode the same conceptual object. This feels like we're duplicating things and making things messy and unclear.

image

One idea which I think is suitable in this case, is to move away from the TokenProvisionSerializer and replace it with a UserSerializer.

So yes, we're using two serializations, but they're for fundamentally different objects (one for the User, and one for the Token) and we're not doubling up on anything.

Plus, we can't properly validate the Token without the User being valid first anyway.

I've tested this and it works - what do you reckon?

image

@abhi1693 abhi1693 closed this Sep 1, 2023
@stuntguy3000 stuntguy3000 deleted the 12870-expand-tokenprovision-api branch September 1, 2023 21:48
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for setting expiration time when using the API token provisioning endpoint (/api/users/tokens/provision/)

3 participants