{"action":"created","issue":{"url":"https://api.github.com/repos/danschultzer/ex_oauth2_provider/issues/20","repository_url":"https://api.github.com/repos/danschultzer/ex_oauth2_provider","labels_url":"https://api.github.com/repos/danschultzer/ex_oauth2_provider/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/danschultzer/ex_oauth2_provider/issues/20/comments","events_url":"https://api.github.com/repos/danschultzer/ex_oauth2_provider/issues/20/events","html_url":"https://github.com/danschultzer/ex_oauth2_provider/issues/20","id":308100001,"number":20,"title":"resource/app owner schema flexibility","user":{"login":"techgaun","id":1886670,"avatar_url":"https://avatars2.githubusercontent.com/u/1886670?v=4","gravatar_id":"","url":"https://api.github.com/users/techgaun","html_url":"https://github.com/techgaun","followers_url":"https://api.github.com/users/techgaun/followers","following_url":"https://api.github.com/users/techgaun/following{/other_user}","gists_url":"https://api.github.com/users/techgaun/gists{/gist_id}","starred_url":"https://api.github.com/users/techgaun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/techgaun/subscriptions","organizations_url":"https://api.github.com/users/techgaun/orgs","repos_url":"https://api.github.com/users/techgaun/repos","events_url":"https://api.github.com/users/techgaun/events{/privacy}","received_events_url":"https://api.github.com/users/techgaun/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-03-23T16:35:55Z","updated_at":"2018-03-25T06:14:02Z","closed_at":null,"author_association":"NONE","body":"right now, the owner schema is assumed to have an integer type and `id` as the default field(as per ecto belongs_to/3) and there are at least two parts where I can see we need the modification for the very least:\r\n\r\n- migration script (need to be able to specify `integer` vs `uuid` or even anything else for example)\r\n- `belongs_to` stuff where we might need to pass additional opts using `Ecto.Schema.belongs_to/3` so we can possibly specify custom state of our foreign key\r\n\r\nOne of the quick ideas I had was to add `resource_owner_opts` and `application_owner_opts` which I've in https://github.com/danschultzer/ex_oauth2_provider/compare/master...techgaun:owner-config and am using it right now for my purpose. It does not take care of migration of course but it was simple enough for me to modify generated migration script.\r\n\r\nThis works fine so far for my case (my resource owner table has `uuid` type with `user_id` as the field name). I have not looked yet at most of the code to have more clear idea but what do you recommend in this case? My solution might be fine as long as we advise users to update generated migration scripts to adjust with additional options passed to `belongs_to` in schema but longer term, this may feel like a hack. Thoughts?\r\n\r\nIt would be great if we can generalize for cases like this so we don't tie the resource owner to be of particular schema.\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/danschultzer/ex_oauth2_provider/issues/comments/375948225","html_url":"https://github.com/danschultzer/ex_oauth2_provider/issues/20#issuecomment-375948225","issue_url":"https://api.github.com/repos/danschultzer/ex_oauth2_provider/issues/20","id":375948225,"user":{"login":"techgaun","id":1886670,"avatar_url":"https://avatars2.githubusercontent.com/u/1886670?v=4","gravatar_id":"","url":"https://api.github.com/users/techgaun","html_url":"https://github.com/techgaun","followers_url":"https://api.github.com/users/techgaun/followers","following_url":"https://api.github.com/users/techgaun/following{/other_user}","gists_url":"https://api.github.com/users/techgaun/gists{/gist_id}","starred_url":"https://api.github.com/users/techgaun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/techgaun/subscriptions","organizations_url":"https://api.github.com/users/techgaun/orgs","repos_url":"https://api.github.com/users/techgaun/repos","events_url":"https://api.github.com/users/techgaun/events{/privacy}","received_events_url":"https://api.github.com/users/techgaun/received_events","type":"User","site_admin":false},"created_at":"2018-03-25T06:14:02Z","updated_at":"2018-03-25T06:14:02Z","author_association":"NONE","body":"@danschultzer I was actually thinking if we could just generate these schemas (https://github.com/danschultzer/ex_oauth2_provider/blob/master/lib/ex_oauth2_provider/oauth_applications/oauth_application.ex) to the users install just like this package generates controllers and views. For the grant schemas, I am pretty sure we can just stay with one schema instead of individual base schemas.\r\n\r\nAlso, because there is possibility of matching to `id` being in map (such as here: https://github.com/danschultzer/ex_oauth2_provider/blob/f9c77228f16c0433c713870c2925d853987099d8/lib/ex_oauth2_provider/oauth2/authorization/strategy/code.ex#L191), this fix would probably be incomplete in terms of people being able to use non-standard column name in the owner schema."}}
{"actor":{"display_login":"techgaun"}}