API-Skeletons / zf-oauth2-doctrine

OAuth2 Doctrine Adapter for Apigility
30 stars 26 forks source link

Question Re : #85

Closed barry1955 closed 7 years ago

barry1955 commented 7 years ago

I am currently working on adding zf-auth-doctrine to my application (Map based Facilities Mgt).

We have built all of our models using Sparxsystem's Enterprise Architect. I was not able to import OAuth2-orm.module.xml into EA, so I have built the database model based on the file and the publish ER Diagram in OAuth2-orm.module.xml, I saw the following, which seems to contradict the ER Diagrman

<many-to-many mn-entity="\ZF\OAuth2\Doctrine\Entity\AccessTokenToScope" uuid="d6c88e38-48c1-43d7-b5e9-b6902ee48e7c">
      <many-to-many-entity name="\ZF\OAuth2\Doctrine\Entity\Scope" owning-side="true" alias="scope" uuid="391c57b9-1832-4a9a-b7fb-75b2c5c59ebf">
        <many-to-many-field from="scope_id" to="id"/>
      </many-to-many-entity>

 <many-to-many-entity name="\ZF\OAuth2\Doctrine\Entity\AccessToken" owning-side="false" alias="accessToken" uuid="1a2f2f70-ba2a-49c8-a50c-ffe2206b4013">
        <many-to-many-field from="access_token_id" to="id"/>
</many-to-many-entity>

But the Diagram indicates this is a many-to-one (one-to-many).
I have built my model on the ER Diagram as it seems more correct. Am I missing something here?

I should point out that to my mind it seems that all the 1:n relationships are incorrectly coded in the xml.

If anyone is interested in the EA model I built I can provide it.

TomHAnderson commented 7 years ago

I have interest in your EA model because I'm unfamiliar with the Sparxsystem tool. If you have a model which can be included with this module that would be ideal. Else please share what you can.

The png diagram accurately represents the ERD for this module. The relationship between Scope and Client, AccessToken, AuthorizationCode, and RefreshToken (CAAR entities) is each a many to many with Scope on one side.

part 1: The diagram includes, and this isn't an official term, a meta entity which is part of the Skipper XML file and does not exist in the generated Doctrine XML metadata except as the table which creates the many to many join; each called *ToScope. The diagram indicates a many to one and a one to many with the many to many entity between them thereby making it a many to many.

part 2: Are you suggesting the relationship between Client and AccessToken, a 1:many, is incorrect?

part 3: Be aware dynamic relationships are created between the configured User entity and the CARR entities at run time. Also read the fine print in the ERD regarding the unique ClientID. I'm not suggesting you missed these but they are gotchas if you're duplicating the work.

TomHAnderson commented 7 years ago

@barry1955 I hope you haven't made the faux pas that https://github.com/API-Skeletons/zf-oauth2-doctrine/blob/master/media/OAuth2-orm.module.xml is Doctrine XML code. Perhaps these are the files you intended to use? https://github.com/API-Skeletons/zf-oauth2-doctrine/tree/master/config/orm

barry1955 commented 7 years ago

Hi, I was working from the published ERD and the XML, but I deferred to the diagram.

I see what happened, I had not anticipate the magic creation of the intersecting Entity.
I'm not a fan of this - as I said my Model conforms to the diagram. By way of explanation, I studied RDBMS in the 80's under Shir Nyssen, I've always used a 'fact modelling' approach, but that's bye the bye. I use EA because of the UML support.
I do not use the Doctrine in-built schema generation as we have a spatially extended Database Model in SQLSERVER (not my decision) and so far have not been able to take the time to get the Doctrine extensions for spatial working. Also EA allows me a great deal of flexibility in producing DDL.

What format can you accept? EA pumps out standard XMI other than that it's just images, DDL, Word, pdf.

I'll stick with naming every object explicitly though, so rather than one 'many-to-many' meta relationship, I prefer to see the 2 one-many that actually exist. In short it seems we agree, and I missed the magic bit. Good to know for the future.

Again, more than happy to post the EA model, with the caveat that its a work in progress.

Thanks again.

TomHAnderson commented 7 years ago

If your EA model can represent the ERD in another way which would help someone like yourself whom creates the SQL in a way other than the schema-tool then I think it would be beneficial to add to this repository.