brokenhandsio / vapor-oauth-fluent

Fluent Implementations For Vapor OAuth
MIT License
15 stars 2 forks source link

Separation between primary key and client ID #1

Closed stefanomondino closed 7 years ago

stefanomondino commented 7 years ago

Hi guys,

while trying to implement a solution with Vapor, Fluent, Postgresql and OAuth, I've stumbled upon your library and a possible problem.

Basically, I'm trying to implement an API (POST) that allows an (entitled) user such as super user to create an OAuth client to share with third parties. I have a working controller and I am able to properly create OAuth apps. however, generated client ids are progressive Integers, and I would like to create something less predictable (16 bytes hex for example). I'm trying to change manually the client_id after init with a custom string, but since it's tied to the primary key, it has to be an Int

Wouldn't it make more sense to store the client_id in a separated (and unique) string db field?

0xTim commented 7 years ago

So I was undecided about this when I implemented it, but totally understand the point. I may be changing things around in the next week or so when I make the Fluent wrappers a bit nice (and more likely extensions instead) but have you tried manually setting the ID type to .uuid as a work around? Docs for that are here https://docs.vapor.codes/2.0/fluent/model/#id-type

stefanomondino commented 7 years ago

I've tried, works if the UUID is a pure number, but if it's a (hex) string I get an exception. I'll keep an eye on changes (right now I'm not developing a production product, I'm just learning vapor for personal knowledge), thanks for implementing this, I think it's a really clever OAuth implementation (I mean the full solution, not only the Fluent wrapper).

0xTim commented 7 years ago

@stefanomondino 0.1.1 should fix your issue for now, but things will change again in the future as I'm planning on removing the subclasses and moving to extensions

stefanomondino commented 7 years ago

thank you @0xTim I'll keep an eye on this!

0xTim commented 7 years ago

You can track it here https://github.com/brokenhandsio/vapor-oauth-fluent/pull/2

0xTim commented 7 years ago

@stefanomondino take a look at the latest release (https://github.com/brokenhandsio/vapor-oauth-fluent/releases/tag/0.2.0) - this provides the better integration with Fluent and uses extensions now instead!

stefanomondino commented 7 years ago

great job! I'll try it ASAP :) thanks for your work