From 648c6fc10b10cf9c520f7300c9f13dc1845ce6cc Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Thu, 14 Nov 2019 11:14:56 +0100 Subject: [PATCH 001/125] Fixed language errors in Installation.md --- INSTALLATION.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/INSTALLATION.md b/INSTALLATION.md index 8b25f6c1..285d3696 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -1,17 +1,17 @@ # Installation -This document dives a litle bit deeper into installing your component on a kubernetes cluster, looking for information on setting up your component on a lookal maschine? Take a look at the [tutorial](TUTORIAL.md) instead. +This document dives a little bit deeper into installing your component on a kubernetes cluster, looking for information on setting up your component on a local machine? Take a look at the [tutorial](TUTORIAL.md) instead. ## Setting up helm ## Setting up tiller -Create the tiller serviceaccount: +Create the tiller service account: ```CLI $ kubectl -n kube-system create serviceaccount tiller --kubeconfig="api/helm/kubeconfig.yaml" ``` -Next, bind the tiller serviceaccount to the cluster-admin role: +Next, bind the tiller service account to the cluster-admin role: ```CLI $ kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller --kubeconfig="api/helm/kubeconfig.yaml" ``` @@ -21,30 +21,30 @@ Now we can run helm init, which installs Tiller on our cluster, along with some $ helm init --service-account tiller --kubeconfig="api/helm/kubeconfig.yaml" ``` -To verify that Tiller is running, list the pods in thekube-system namespace: +To verify that Tiller is running, list the pods in the kube-system namespace: ```CLI $ kubectl get pods --namespace kube-system --kubeconfig="api/helm/kubeconfig.yaml" ``` The Tiller pod name begins with the prefix tiller-deploy-. -Now that we’ve installed both Helm components, we’re ready to use helm to install our first application. +Now that we've installed both Helm components, we're ready to use helm to install our first application. ## Setting up Kubernetes Dashboard -Afhter we installed helm and tiller we can easyallty use both to install kubernets dashboard +After we installed helm and tiller we can easily use both to install kubernetes dashboard ```CLI $ helm install stable/kubernetes-dashboard --name dashboard --kubeconfig="api/helm/kubeconfig.yaml" --namespace="kube-system" ``` -But before we can login to tille we need a token, we can get one of those trough the secrets. Get yourself a secret list by running the following command +But before we can login to tiller we need a token, we can get one of those trough the secrets. Get yourself a secret list by running the following command ```CLI $ kubectl -n kube-system get secret --kubeconfig="api/helm/kubeconfig.yaml" ``` -Becouse we just bound tiller to our admin acount and use tiller (trough helm) to manage our code deployment it makes sence to use the tiller token, lets look uo the tilles secret (it should loo something like "tiller-token-XXXXX" and ask for the coresponding token. +Because we just bound tiller to our admin account and use tiller (trough helm) to manage our code deployment it makes sense to use the tiller token, lets look at the tiller secret (it should look something like "tiller-token-XXXXX" and ask for the corresponding token. ```CLI -$ kubectl -n kube-system describe secrets tiller-token-5m4tg --kubeconfig="api/helm/kubeconfig.yaml" +$ kubectl -n kube-system describe secrets tiller-token-xxxxx --kubeconfig="api/helm/kubeconfig.yaml" ``` This should return the token, copy it to somewhere save (just the token not the other returned information) and start up a dashboard connection @@ -59,10 +59,10 @@ http://localhost:8001/api/v1/namespaces/kube-system/services/https:dashboard-kub ``` ## Deploying trough helm -First we always need to update our dependencys +First we always need to update our dependencies ```CLI $ helm dependency update ./api/helm - +``` If you want to create a new instance ```CLI $ helm install --name pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1 @@ -88,19 +88,19 @@ Note that you can replace commonground with the namespace that you want to use ( ## Making your app known on NLX -The proto component commes with an default NLX setup, if you made your own component however you might want to provide it trough the [NLX](https://www.nlx.io/) service. Furntunatly the proto component commes with an nice setup for NLX integration. +The proto component comes with an default NLX setup, if you made your own component however you might want to provide it trough the [NLX](https://www.nlx.io/) service. Fortunately the proto component comes with an nice setup for NLX integration. -First of all change the nececery lines in the [.env](.env) file, basiccaly everything under the NLX setup tag. Keep in mind that you wil need to have your component available on an (sub)domain name (a simple IP wont sufice). +First of all change the necessary lines in the [.env](.env) file, basically everything under the NLX setup tag. Keep in mind that you wil need to have your component available on an (sub)domain name (a simple IP wont sufice). -To force the re-generation of certificates simply delete the org.crt en org.key in the api/nlx-setup folder +To force the re-generation of certificates simply delete the org.crt en org.key in the api/nlx-setup folder. ## Deploying trough common-ground.dev ## Setting up analytics and a help chat function -As a developer you might be intrested to know how your application documentation is used, so you can see which parts of your documentation are most read and which parts might need some additional love. You can measure this (and other user interactions) with google tag manager. Just add your google tag id to the .env file (replacing the default) under GOOGLE_TAG_MANAGER_ID. +As a developer you might be interested to know how your application documentation is used, so you can see which parts of your documentation are most read and which parts might need some additional love. You can measure this (and other user interactions) with google tag manager. Just add your google tag id to the .env file (replacing the default) under GOOGLE_TAG_MANAGER_ID. -Have you seen our sweet support-chat on the documentation page? We didn't build that ourselves ;) We use a Hubspot chat for that, just head over to Hubspot, create an account and enter your Hubspot embed code in het .env file (replacing the default) under HUBSPOT_EMBED_CODE. +Have you seen our sweet support-chat on the documentation page? We didn't build that ourselves ;). We use a Hubspot chat for that, just head over to Hubspot, create an account and enter your Hubspot embed code in het .env file (replacing the default) under HUBSPOT_EMBED_CODE. -Would you like to use a different analytics or chat-tool? Just shoot us a [feature request](https://github.com/ConductionNL/commonground-component/issues/new?assignees=&labels=&template=feature_request.md&title=New Analytics or Chat provider) +Would you like to use a different analytics or chat-tool? Just shoot us a [feature request](https://github.com/ConductionNL/commonground-component/issues/new?assignees=&labels=&template=feature_request.md&title=New%20Analytics%20or%20Chat%20provider)! From 1abaf66797c7e69beb729989f1b38216098a97a0 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Thu, 14 Nov 2019 13:09:46 +0100 Subject: [PATCH 002/125] Checked DESIGN.md for language errors --- DESIGN.md | 34 +++++++++++++++++----------------- INSTALLATION.md | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index edcb7692..ac705c08 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -1,49 +1,49 @@ # Design Considerations -This component was designed inline with the [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie), [NORA](https://www.noraonline.nl/wiki/Standaarden), [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/index), [commonground principles](https://vng.nl/onderwerpenindex/bestuur/samen-organiseren-2019/common-ground) and international standards. +This component was designed in line with the [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie), [NORA](https://www.noraonline.nl/wiki/Standaarden), [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/index), [commonground principles](https://vng.nl/onderwerpenindex/bestuur/samen-organiseren-2019/common-ground) and international standards. -The spefic goal of this component is to provide a common architecture for common ground components as such the common ground principles are leading in design choices, and within those principles technological invoation and international complyancy is deemd most inportant. WE DO NOT WANT TO MAKE CONSESIONS TO CURRENT INFRASTRUCTURE. As such the component might differ on [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie), [NORA](https://www.noraonline.nl/wiki/Standaarden), [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/index) and other standards if they are deemed incompatible or out of line with international standards. +The specific goal of this component is to provide a common architecture for common ground components as such the common ground principles are leading in design choices, and within those principles technological invocation and international compliancy is deemed most important. **We do not want to mace consessions to the current infrastructure.** As such the component might differ on [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie), [NORA](https://www.noraonline.nl/wiki/Standaarden), [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/index) and other standards if they are deemed incompatible or out of line with international standards. The European factor ------- -The proto-component isn't just a Dutch Component, it is in easance a dutch translation of european components, nowhere is this more obvius than in the core code. Our component is based on [API Platform](https://api-platform.com/) an API specific version of the symfony framework. This framework is build by the lovely people of []() and is build with support of the Euroean Commision trough the [EU-FOSSA Hackathon](https://ec.europa.eu/info/news/first-eu-fossa-hackathon-it-happened-2019-may-03_en) and Digital Ocean trough [Hacktoberfest].(https://hacktoberfest.digitalocean.com/). +The proto-component isn't just a Dutch Component, it is in essence a dutch translation of european components, nowhere is this more obvious than in the core code. Our component is based on [API Platform](https://api-platform.com/) an API specific version of the symfony framework. This framework is build by the lovely people of []() and is build with support of the European Commission trough the [EU-FOSSA Hackathon](https://ec.europa.eu/info/news/first-eu-fossa-hackathon-it-happened-2019-may-03_en) and Digital Ocean trough [Hacktoberfest](https://hacktoberfest.digitalocean.com/). -But it dosn't just end there the [varnish container](https://hub.docker.com/r/eeacms/varnish/) that we use to speed up the API responce it build and maintained by [EEA]() (The European Environment Agency) and the development team at conduction itself is attached to the [Odyssey program](https://www.odyssey.org/) and originated from the [startupinresidence](https://startupinresidence.com/) program. +But it doesn't just end there. The [varnish container](https://hub.docker.com/r/eeacms/varnish/) that we use to speed up the API responce it build and maintained by [EEA]() (The European Environment Agency) and the development team at conduction itself is attached to the [Odyssey program](https://www.odyssey.org/) and originated from the [startupinresidence](https://startupinresidence.com/) program. So you could say that both change and a european perspective is in our blood. Domain Build-up and routing ------- -By convention the component assumes that you follow the common ground domain name build up, meaning {enviroment}.{component}.{rest of domain}. That means that only the first two url parts are used for routing. It is also assumed that when no envirment is supplied the production enviroment should be offerd E.g. a propper domain for the production API of the verzoeken registratie component would be prod.vrc.zaakonline.nl but it should also be reachable under vrc.zaakonline.nl. The proper location for the development enviroment shoud always be dev.vrc.zaakonlin.nl +By convention the component assumes that you follow the common ground domain name build up, meaning {environment}.{component}.{rest of domain}. That means that only the first two url parts are used for routing. It is also assumed that when no environment is supplied the production environment should be offered E.g. a proper domain for the production API of the verzoeken registratie component would be prod.vrc.zaakonline.nl but it should also be reachable under vrc.zaakonline.nl. The proper location for the development environment should always be dev.vrc.zaakonlin.nl -Enviroments and namespacing +Environments and namespacing ------- -We assume that for that you want to run several enviroments for development purposes. We identify the following namespaces for support. +We assume that for that you want to run several environments for development purposes. We identify the following namespaces for support. - prod (Production) - acce (Acceptation) - stag (Staging) - test (Testing) - dev (Development) -Becouse we base the commonground infastructure on kubernetes, and we want to keep a hard sepperation between enviroment we also assume that you are using your enviroment as a namespace +Because we base the common ground infrastructure on kubernetes, and we want to keep a hard separation between environment we also assume that you are using your environment as a namespace -Symfony libary managment gives us the optoin to define the libbarys on a per envirmoent base, you can find that definition in the [bundle config](api/config/bundles.php) +Symfony library management gives us the option to define the libraries on a per environment base, you can find that definition in the [bundle config](api/config/bundles.php) -Besides the API envormiments the component also ships with aditional tools/enviroments but those are not meant to be deployed +Besides the API environments the component also ships with additional tools/environments but those are not meant to be deployed - client (An react client frontend) -- admin ( An read admin interface) +- admin (An read admin interface) -On the local development docker deploy the client enviroment is used as default in stead of the production version of the api. +On the local development docker deploy the client environment is used as default instead of the production version of the api. -Loging Headers (NLX Audit trail) +Logging Headers (NLX Audit trail) ------- @todo update, a reaction about this has been given by the NLX team. -We inherit a couple of headers from the transaction logging within the [NLX schema](https://docs.nlx.io/further-reading/transaction-logs/), we strongly discurage the use of the `X-NLX-Request-Data-Subject` header as it might allow private data (such as BSN's) to show up in logging. +We inherit a couple of headers from the transaction logging within the [NLX schema](https://docs.nlx.io/further-reading/transaction-logs/), we strongly discourage the use of the `X-NLX-Request-Data-Subject` header as it might allow private data (such as BSNs) to show up in logging. __solution__ -The follwoing X-NLX headers have been implemented `X-NLX-Logrecord-ID`,`X-NLX-Request-Process-Id`,`X-NLX-Request-Data-Elements` and `X-NLX-Request-Data-Subject`, these are tied to the internal audit trail (see audit trail for more information), and `X-Audit-Toelichting` (from the ZGW API's) is implemented as `X-Audit-Clarification` +The following X-NLX headers have been implemented `X-NLX-Logrecord-ID`,`X-NLX-Request-Process-Id`,`X-NLX-Request-Data-Elements` and `X-NLX-Request-Data-Subject`, these are tied to the internal audit trail (see audit trail for more information), and `X-Audit-Toelichting` (from the ZGW APIs) is implemented as `X-Audit-Clarification` Api versioning ------- @@ -79,7 +79,7 @@ In compliance with [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/achter Notifications ------- @todo this needs to be implemented -For notifications we do not use the current [ZGW standard](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/notificaties) since we deem it insecure to send properties or data objects along with a notification. This is a potential security breach explained [here](https://github.com/VNG-Realisatie/gemma-zaken/issues/1427#issuecomment-549272696). It also doesn’t follow the [web standard](https://www.w3.org/TR/websub/). Instead we are developing our own subscriber service that is tailored for the NLX / VNG environment and based on current web standards [here](). +For notifications we do not use the current [ZGW standard](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/notificaties) since we deem it insecure to send properties or data objects along with a notification. This is a potential security breach explained [here](https://github.com/VNG-Realisatie/gemma-zaken/issues/1427#issuecomment-549272696). It also doesn�t follow the [web standard](https://www.w3.org/TR/websub/). Instead we are developing our own subscriber service that is tailored for the NLX / VNG environment and based on current web standards [here](). __solution__ In compliance with [w3.org](https://www.w3.org/TR/websub/) each endpoint returns an header containing an subscribtion url. That can be used in acordanse with the application to subscribe to both individual objects as collections. whereby collections serve as 'kanalen'. @@ -122,7 +122,7 @@ Comma Notation versus Bracket Notation on arrays's ------- The NL API standard uses comma notation on array's in http requests. E.g. fields=id,name,description however common browsers(based on chromium e.g. chrome and edge) use bracket notation for query style array's e.g. fields[]=id&fields[]=name,&fields[]=description. The difference of course is obvious since comma notation doesn't allow you to index arrays. [Interestingly enough there isn't actually a rfc spec for this](https://stackoverflow.com/questions/15854017/what-rfc-defines-arrays-transmitted-over-http). -It is perceivable that in future iterations we would like to use indexed array in situations where the index of the array can't be assumed on basis of url notation, when indexes aren’t numerical, when we don’t want an index to start at 0 or when indexes are purpusly missing (comma notation of id,name,description would always refert to the equivalent of fields: [ +It is perceivable that in future iterations we would like to use indexed array in situations where the index of the array can't be assumed on basis of url notation, when indexes aren�t numerical, when we don�t want an index to start at 0 or when indexes are purpusly missing (comma notation of id,name,description would always refert to the equivalent of fields: [ 0 => id, 1 => name, 2 => description diff --git a/INSTALLATION.md b/INSTALLATION.md index 285d3696..63989676 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -84,7 +84,7 @@ $ helm del pc-stag --purge --kubeconfig="api/helm/kubeconfig.yaml --namespace=st $ helm del pp-prod --purge --kubeconfig="api/helm/kubeconfig.yaml --namespace=prod" ``` -Note that you can replace commonground with the namespace that you want to use (normally the name of your component). +Note that you can replace common ground with the namespace that you want to use (normally the name of your component). ## Making your app known on NLX From a9eb60b56d0781c7899db2e5ee7e6136106aea9a Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Thu, 14 Nov 2019 13:48:53 +0100 Subject: [PATCH 003/125] Checked TUTORIAL.md for typos --- SECURITY.md | 2 +- TUTORIAL.md | 88 +++++++++++++++++++++++++++-------------------------- 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 0c41cb8e..f72a06d9 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,6 +1,6 @@ # SECURITY -Security of your common ground component henchmen’s on a few factors and is (in fact) for the most part provided by the common ground ecosystem. But there are definitely some steps that you should undertake yourself. We will however first briefly explain the security principles set in place so that you understand how you are being supported and what the limitation of that support is. +Security of your common ground component henchmens on a few factors and is (in fact) for the most part provided by the common ground ecosystem. But there are definitely some steps that you should undertake yourself. We will however first briefly explain the security principles set in place so that you understand how you are being supported and what the limitation of that support is. ## Codebase First of the code base, if you are extending the common ground-proto-component your code base will exist out of three parts. diff --git a/TUTORIAL.md b/TUTORIAL.md index 8c4f391c..74aad7ba 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -8,7 +8,7 @@ What do you need for this tutorial? * Docker for desktop ## Before you begin -For the steps consirning the generation of entities an example entity a availale, feel free to [take a look](https://github.com/ConductionNL/Proto-component-commonground/blob/master/api/src/Entity/ExampleEntity.php) at it if you have trouble figuring out the code. +For the steps considering the generation of entities an example entity a availale, feel free to [take a look](https://github.com/ConductionNL/Proto-component-commonground/blob/master/api/src/Entity/ExampleEntity.php) at it if you have trouble figuring out the code. ## Setting up your enviroment @@ -28,9 +28,9 @@ We ran a fork of the base Common Ground component, that means that we copied the ## Spinning up your component Before we can spin up our component we must first get a local copy from our repository, we can either do this through the command line (example here) or use a Git client. -For this example where going to use GitKraken but you can use any tool you like, feel free to skip this part if you are already familiar with setting up a local clone of your repository. +For this example we're going to use GitKraken but you can use any tool you like, feel free to skip this part if you are already familiar with setting up a local clone of your repository. -Open gitkraken press "clone a repro" and fill in the form (select where on your local machine you want the repository to be stored, and fill in the link of your repository on github), press "clone a repro" and you should then see GitKraken downloading your code. After it's done press "open now" (in the box on top) and voilá your codebase (you should see an initial commit on a master branche). +Open gitkraken press "clone a repo" and fill in the form (select where on your local machine you want the repository to be stored, and fill in the link of your repository on github), press "clone a repo" and you should then see GitKraken downloading your code. After it's done press "open now" (in the box on top) and voilá your codebase (you should see an initial commit on a master branch). You can now navigate to the folder where you just installed your code, it should contain some folders and files and generally look like this. We will get into the files later, lets first spin up our component! @@ -46,7 +46,7 @@ Your computer should now start up your local development environment. Don't worr Open your browser type http://localhost/ as address and hit enter, you should now see your common ground component up and running. ### trouble shooting -When spinning up components we make extensive use of the cashing of docker, and use volumes to reprecent server disks. When running in to unexpected trouble always remmember to clear your local docker vm with the -a command (removing image cash) +When spinning up components we make extensive use of the cashing of docker, and use volumes to represent server disks. When running in to unexpected trouble always remember to clear your local docker vm with the -a command (removing image cash) ```CLI $ docker system prune -a ``` @@ -69,18 +69,18 @@ Let's open a new command line window and navigate to our root folder, exactly li ```CLI $ docker-compose exec php bin/console make:entity ``` -We should now see a wizward that allows us to either make new entities, or add parameters to existing entities (by supplying the name of an existing entity). +We should now see a wizard that allows us to either make new entities, or add parameters to existing entities (by supplying the name of an existing entity). ## Keeping your repository up to date with the Conduction Common Ground component There are basically three reasons why you should want to keep your repository up to date with the Conduction proto component * Security, Conduction performs regular security updates on * Functionality we strive to make regular -* Compliance, as discussions in the broader Common Ground community progress API standars might advance or change. Conduction will regularly update the Common Ground component with those changes. +* Compliance, as discussions in the broader Common Ground community progress API standards might advance or change. Conduction will regularly update the Common Ground component with those changes. Best practice is to fetch the Conduction Common Ground component into a local upstream/master branch through Git. So let's first add the original Common Ground component as an remote called upstream, and create a local branch for that remote. -__Please make sure the you have commited al your changes to your current codebase and pushed a backup copy to your Git repo before continuing__ +__Please make sure the you have committed al your changes to your current codebase and pushed a backup copy to your Git repo before continuing__ ```CLI git remote add upstream https://github.com/ConductionNL/Proto-component-commonground.git @@ -88,7 +88,7 @@ git fetch upstream git branch upstream upstream/master ``` -You can then use your favorite Git tool to merge this branch into your normal working branche without the danger of overwriting your local code. Or alternatively you can use your GIT CLI (not recommended) +You can then use your favorite Git tool to merge this branch into your normal working branch without the danger of overwriting your local code. Or alternatively you can use your GIT CLI (not recommended) ```CLI git checkout master @@ -107,9 +107,9 @@ git merge upstream --allow-unrelated-histories Keep in mind that you wil need to make sure to stay up to date about changes on the Common Ground component repository. ## Renaming your component -Right now the name of your component is 'commonground' that's thats fine while running it localy or in its own kubernetes cluster but wil get you in when running it with other components when it without using a name space. So its good practice to name your component distinctifly. But besides al of these practical reasons its of course also just cool to name your child before you unleas it on the unsuspecting commonground community. +Right now the name of your component is 'commonground' that's that's fine while running it locally or in its own kubernetes cluster but wil get you in when running it with other components when it without using a name space. So its good practice to name your component distinctly. But besides al of these practical reasons its of course also just cool to name your child before you unleash it on the unsuspecting common ground community. -Oke, so before we can nae the component we need to come up with a name. There are a couple of conventions here. Firts of the name should tell us what the component does, or is suposede to do with one or two words. So we would normaly call an componant aboute dogs the DogComponent and one about cats te CatComponent. The second convention is that we don't usually actually name our component 'component' but indicate its position in de commonground architecture. For that we have the following options +Oke, so before we can nae the component we need to come up with a name. There are a couple of conventions here. First of the name should tell us what the component does, or is supposed to do with one or two words. So we would normally call an component about dogs the DogComponent and one about cats te CatComponent. The second convention is that we don't usually actually name our component 'component' but indicate its position in de common ground architecture. For that we have the following options: * Catalogus * RegistratieComponent * Service @@ -143,7 +143,7 @@ The we need to touch te following files //... ``` -## Setting up security and acces (also helps with serialization) +## Setting up security and access (also helps with serialization) ```PHP // src/Entity/Organisation.php @@ -193,12 +193,12 @@ class Organisation Keep in mind that we need to add the assert annotation to our class dependencies under 'use'. -More inforation on using validation can be found at the [symfony website](https://symfony.com/doc/current/validation.html), but it is als worth notting that tis commonent comes pre packed with some typical NL valdidators like BSN. You can find those [here](). +More inforation on using validation can be found at the [symfony website](https://symfony.com/doc/current/validation.html), but it is als worth nothing that tis component comes pre packed with some typical NL validators like BSN. You can find those [here](). ## Using UUID -As default doctrine uses auto increment integers as identifiers (1,2, etc). For modern webapplications we howver prefer the use of UUID's. (e.g. e2984465-190a-4562-829e-a8cca81aa35d). Why? Wel for one it is more secure integer id's are easly gasable and make it posible to "aks" endpoint about objects that you should know about. But UUID's also have a benifit in futere proofing the application. If we in the futere want to merge a table with another table (for example becouse two organisations using a component perform a merger) then we would have to reasign al id's and relations if we where using int based id's (both tables would have a row 1,2 etc) with UUID's however the change of doubles range somwhere in the biljons. Meaning that it i likly that we oly need to either re identify only a handful of rows or more likely none at al! Turning our entire migration into a copy pase action. +As default doctrine uses auto increment integers as identifiers (1,2, etc). For modern web applications we however prefer the use of UUID's. (e.g. e2984465-190a-4562-829e-a8cca81aa35d). Why? Wel for one it is more secure integer id's are easily guessable and make it possible to "ask" endpoint about objects that you should not know about. But UUID's also have a benefit in future proofing the application. If we in the future want to merge a table with another table (for example because two organisations using a component perform a merger) then we would have to reassign al id's and relations if we where using int based id's (both tables would have a row 1,2 etc) with UUID's however the change of doubles range somewhere in the billions. Meaning that it is likely that we only need to either reidentify only a handful of rows or more likely none at al! Turning our entire migration into a copy paste action. -The proto component supports ramsy's uuid objects stratagy out of the box, so to use UUID's as intifier simply we need to add the ApiProperty as a dependecy +The proto component supports Ramsey's uuid objects strategy out of the box, so to use UUID's as identifier simply we need to add the ApiProperty as a dependency ```PHP @@ -269,10 +269,10 @@ into this //... ``` -and your all done +and you're all done -### Rrouble shooting -If you have already spunn your component including your new entity your going to run into some trouble becouse doctrine is going to try changing your primary key collum (id) from an integer to string (tables tend not to like that). In that case its best to just drop your database and reinstall it using the following commands: +### Trouble shooting +If you have already spun your component including your new entity your going to run into some trouble because doctrine is going to try changing your primary key column (id) from an integer to string (tables tend not to like that). In that case its best to just drop your database and reinstall it using the following commands: ```CLI $ bin/console doctrine:schema:drop @@ -281,13 +281,13 @@ $ bin/console doctrine:schema:update --force ## Advanced data sets -Oke lets make it complex, until now we have just added some simple entities to our component, but what if we want to ataches one entity to another? Fortunatly our build in database engine support rather complex senarios called associations. So let [take a look](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/association-mapping.html) at that. +Oke lets make it complex, until now we have just added some simple entities to our component, but what if we want to attaches one entity to another? Fortunately our build in database engine support rather complex scenarios called associations. So let [take a look](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/association-mapping.html) at that. -Bafled? Wel its rather complex. But remember that Make:entity command that we used earlier? That actuelly accepts relations as a data type. Or to but it simply instead of using the default 'string' we could just type "ManyToOne" and it will just fire up some qoustions that will help it determine how you want your relations to be. +Baffled? Wel its rather complex. But remember that Make:entity command that we used earlier? That actually accepts relations as a data type. Or to but it simply instead of using the default 'string' we could just type "ManyToOne" and it will just fire up some questions that will help it determine how you want your relations to be. ### Trouble shooting -A very common error when linking entities togehter is circle refrances, those will break our serializatoin. Furtunaltly we have a need way to prevent that. Even better symfony gives us exact control of how deep we want the circular refereance to go. To do this we need to use the `MaxDepth()` annotation. So lets import that +A very common error when linking entities together is circle references, those will break our serialization. Fortunately we have a need way to prevent that. Even better symfony gives us exact control of how deep we want the circular reference to go. To do this we need to use the `MaxDepth()` annotation. So lets import that ```PHP //... @@ -311,11 +311,11 @@ class ExampleEntity //... ``` -We can now prevent circular referances by setting a max depth on the properties cousing the circular refrance. - +We can now prevent circular references by setting a max depth on the properties causing the circular reference. +```PHP //... /** - * @var ArrayCollection $stuffs Some stuff that is atached to this example object + * @var ArrayCollection $stuffs Some stuff that is attached to this example object * * @MaxDepth(1) * @Groups({"read","write"}) @@ -325,21 +325,21 @@ We can now prevent circular referances by setting a max depth on the properties //... ``` -## Datafixtures -For testing cases it can be usefull to use datafixtures a predefined set of data that fills the database of your component at startup. Since we use php classes to describe our objects creating fixtures is easy (you can find an example in your project folder at api/src/DataFixtures). We simply go trough some classes asign values and persist them to the database. Once we have written our fixtures we can use a single command to load them +## Data fixtures +For testing cases it can be useful to use data fixtures a predefined set of data that fills the database of your component at startup. Since we use php classes to describe our objects creating fixtures is easy (you can find an example in your project folder at api/src/DataFixtures). We simply go trough some classes assign values and persist them to the database. Once we have written our fixtures we can use a single command to load them ```CLI $ bin/console doctrine:fixtures:load --env=dev ``` -Be mindfull of the --env=dev here! Doctrine wil only allow fixture loading on a dev enviroment (for obvius security reasons) +Be mindful of the --env=dev here! Doctrine wil only allow fixture loading on a dev environment (for obvious security reasons) -More inforation on using datafixtures can be found at the [symfony website](https://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html)(you can skipp the instalation instructions) we also enourage you to take a look at the [tabbelen component](https://github.com/ConductionNL/landelijketabellencatalogus) that makes extansive use of datafixtures. +More information on using data fixtures can be found at the [symfony website](https://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html) (you can skipp the installation instructions) we also encourage you to take a look at the [tabellen component](https://github.com/ConductionNL/landelijketabellencatalogus) that makes extensive use of data fixtures. ## Sharing your work -A vital part of te common ground community is sharing your work, and telling other people what you are working. This way people can help you wiht problems that you run into. And keep tabs on any (security) updates that you make to you code. Sounds like a lot of work right? +A vital part of te common ground community is sharing your work, and telling other people what you are working. This way people can help you with problems that you run into. And keep tabs on any (security) updates that you make to you code. Sounds like a lot of work right? -Wel it actually isn't, there is a specific commonground platform over at common-gorund.dev that reads repositorys and updates user. So the only thing we need to do is tell this platform that we have started a new common ground repository. And tell it when we have updates ours. We can do all that by simply adding a webhook to our component. +Wel it actually isn't, there is a specific common ground platform over at common-ground.dev that reads repositories and updates user. So the only thing we need to do is tell this platform that we have started a new common ground repository. And tell it when we have updates ours. We can do all that by simply adding a webhook to our component. When using Github. To set up a webhook, go to the settings page of your repository or organization. From there, click Webhooks, then Add webhook. Use te following settings: * Payload URL: https://www.common-ground.dev/webhook/github @@ -347,7 +347,7 @@ When using Github. To set up a webhook, go to the settings page of your reposito * Secret: [leave blanck] * Events: [just the push event] -Now every time you update your repository the commonground dev page will allerted, rescan your repository and do al the apropriate platform actions. It just as easy as that. +Now every time you update your repository the commonground dev page will alerted, rescan your repository and do al the appropriate platform actions. It just as easy as that. Automated Testing and Deployment (continues integration) @@ -356,29 +356,30 @@ The following bit of the tutorial requires two additional accounts - [https://hub.docker.com/](https://hub.docker.com/) (You might already have this for docker for desktop) - [https://travis-ci.org](https://travis-ci.org) (You can use you github account) -The proto component ships with a pre-fab continues integration script based on travis. What does this mean you ask? Continuous integration (or CI for short) is an optimized and automated way for your code to become part of your projects. In the case of your commonground component that means that we will automatically validate new code commites or pushes and (if everything checks out) build that code and deploy the containers thereof to docker hub. Making is possible to update al the environments that use those components. +The proto component ships with a pre-fab continues integration script based on travis. What does this mean you ask? Continuous integration (or CI for short) is an optimized and automated way for your code to become part of your projects. In the case of your commonground component that means that we will automatically validate new code commits or pushes and (if everything checks out) build that code and deploy the containers thereof to docker hub. Making is possible to update al the environments that use those components. -Oke that's nice, but how do we do that? Actually it is very simple. First of all make sure you have a docker account, log into [docker hub](https://hub.docker.com/) and have a look around. We don't need to create anything just yet'but it is nice to get a feeling of the place. As you can see docker hub also uses repositories etc. So that recognizable. +Okay, that's nice, but how do we do that? Actually it is very simple. First of all make sure you have a docker account, log into [docker hub](https://hub.docker.com/) and have a look around. We don't need to create anything just yet, but it is nice to get a feeling of the place. As you can see docker hub also uses repositories etc. So that recognizable. -Next we need to prepare our github repository that holds our code. For the travis script to work as intended we need to create a couple of branches(if we don't have those already) open up yout git interface and create a branch called 'development' and a branch called 'staging'. Don't forget to push the branches so that they are present on github (and not just on your local machine). +Next we need to prepare our github repository that holds our code. For the travis script to work as intended we need to create a couple of branches(if we don't have those already) open up your git interface and create a branch called 'development' and a branch called 'staging'. Don't forget to push the branches so that they are present on github (and not just on your local machine). -Oke just one more place to go and that is travis, head over to [https://travis-ci.org](https://travis-ci.org) and login with your gitacount. If everything is alright you should see your repository there. Activate it by pressing 'activate repository' and then go to 'More options' -> 'Settings' and scroll down to enviroment variables. Here we can present travis wit the variables that it need to execute our build script. Lets first set the common variables that we need for all our branches: `DOCKER_PASSWORD` your docker password,`DOCKER_REGISTRY` docker.io/[your username] ,`DOCKER_USERNAME` your docker user name. This will be used by travis to push the completed containers into docker hub. Next we need to specify a couple of variables that are branch specific. Or to be more exact, set the same variable `APP_ENV` with different values for different branches. It needs to be 'staging'->stag,'master'->prod,'development'->dev. +Oke just one more place to go and that is travis, head over to [https://travis-ci.org](https://travis-ci.org) and login with your github account. If everything is alright you should see your repository there. Activate it by pressing 'activate repository' and then go to 'More options' -> 'Settings' and scroll down to environment variables. Here we can present travis wit the variables that it need to execute our build script. Lets first set the common variables that we need for all our branches: `DOCKER_PASSWORD` your docker password,`DOCKER_REGISTRY` docker.io/[your username] ,`DOCKER_USERNAME` your docker user name. This will be used by travis to push the completed containers into docker hub. Next we need to specify a couple of variables that are branch specific. Or to be more exact, set the same variable `APP_ENV` with different values for different branches. It needs to be 'staging'->stag,'master'->prod,'development'->dev. And all done! Head over back to the code on your computer and make a small change. Then commit push that change into github. Travis should automatically pick op your change and start a build. ### Unit / Behat -adas +TODO ### Postman -ad +TODO ### Trouble shooting -Please make sure that your github repositry is set to public, and keep in mind that a complex travis build (and sertenly one that includes a pushing of containers can take up to 20 minutes). +Please make sure that your github repository is set to public, and keep in mind that a complex travis build (and certainly one that includes a pushing of containers can take up to 20 minutes). + Documentation and dockblocks ------- -asdsa +TODO Audittrail ------- @@ -401,7 +402,7 @@ class ExampleEntity //... ``` -Next we need to tell the specific properties that we want to log that they are loggable (again this is a conscious choice, to prevent us from accidently logging stuff like bsn numbers), we do that by adding the `@Gedmo\Versioned` annotation to those specific properties. That would then look something like this: +Next we need to tell the specific properties that we want to log that they are loggable (again this is a conscious choice, to prevent us from accidentally logging stuff like bsn numbers), we do that by adding the `@Gedmo\Versioned` annotation to those specific properties. That would then look something like this: ```PHP //... @@ -421,7 +422,7 @@ Next we need to tell the specific properties that we want to log that they are l //... ``` -Okay actually we are now good to go, at least we are logging those things that we want logged. But.... How do we view those logs? In commonground we have a [convention](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/audit-trail) to expose a /audittrail subresource on resources that are logged. So lets add that trough our `@ApiResource` anotation. +Okay actually we are now good to go, at least we are logging those things that we want logged. But.... How do we view those logs? In common ground we have a [convention](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/audit-trail) to expose a /audittrail subresource on resources that are logged. So lets add that trough our `@ApiResource` annotation. ```PHP //... @@ -438,17 +439,18 @@ class ExampleEntity //... ``` -And now we have a fully nl api strategie integrated audit trail! +And now we have a fully nl api strategy integrated audit trail! Setting up automated deployment (continues delivery) ------- -adasd +TODO ## Commonground specific data types - +TODO ### incompleteDate + ### underInvestigation From 87d6b828ebecb842cb1908abd246ec8e8ccabc5c Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Sat, 16 Nov 2019 17:50:54 +0100 Subject: [PATCH 004/125] Started development on annotation parsing - healtcheck - audittrail - validators to docs - entity description to tag description --- .gitignore | 2 + api/src/Swagger/SwaggerDecorator.php | 83 ++++++++++++++++++++++++++-- 2 files changed, 81 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c4dd0691..baa17284 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ api/helm/kubeconfig.yaml !/api/public/bundle/* + +.idea/ diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index f0c871be..be6ac767 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -3,27 +3,71 @@ namespace App\Swagger; +use ApiPlatform\Core\Swagger\Serializer\DocumentationNormalizer; +use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Cache\Adapter\AdapterInterface as CacheInterface; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Common\Annotations\AnnotationReader ; final class SwaggerDecorator implements NormalizerInterface { + private $metadataFactory; + private $documentationNormalizer; private $decorated; private $params; private $cash; + private $em; + private $annotationReader; - public function __construct(NormalizerInterface $decorated, ParameterBagInterface $params, CacheInterface $cache) + public function __construct( + ResourceMetadataFactoryInterface $metadataFactory, + DocumentationNormalizer $documentationNormalizer, + NormalizerInterface $decorated, + ParameterBagInterface $params, + CacheInterface $cache, + EntityManagerInterface $em, + AnnotationReader $annotationReader + ) { + $this->metadataFactory = $metadataFactory; + $this->documentationNormalizer = $documentationNormalizer; $this->decorated = $decorated; $this->params = $params; $this->cash = $cache; + $this->em = $em; + $this->annotationReader = $annotationReader; } public function normalize($object, $format = null, array $context = []) { $docs = $this->decorated->normalize($object, $format, $context); + /* The we need to enrich al the entities and add the autoated routes */ + + // Lets get al the entities known to doctrine + $entities = $this->em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames(); + + // Then we loop trough the entities to find the api platform entities + foreach($entities as $entity){ + $reflector = new \ReflectionClass($entity); + var_dump($this->annotationReader->getClassAnnotations($reflector)); + + // lest break for now + break; + + // If the entity is not a apiplatform entity lets continue + //if(){ + // continue + //} + } + + + + // This gets a resourceclass bassed on the route name, could + //$resourceMetadata = $resourceClass ? $this->metadataFactory->create($resourceClass) : null; + // Lest add an host if($this->params->get('common_ground.oas.host')){ $docs['host']= $this->params->get('common_ground.oas.host'); @@ -165,13 +209,44 @@ public function normalize($object, $format = null, array $context = []) 'schema'=>['type'=>'string', 'format' => 'date-time'], 'in' => 'query', ]; - } - - } + } + } + } + + /* @todo dit afbouwen */ + + /* + if(config heltchecks is true){ + $tag=[]; + $tag['name']=''; + $tag['description']=''; + array_unshift($fruits_list, $tag); + } + + if(config audittrail is true){ + $tag=[]; + $tag['name']=''; + $tag['description']=''; + array_unshift($fruits_list, $tag); + } + + if(config notifications is true){ + $tag=[]; + $tag['name']=''; + $tag['description']=''; + array_unshift($fruits_list, $tag); } + + if(config authorization is true){ + $tag=[]; + $tag['name']=''; + $tag['description']=''; + array_unshift($fruits_list, $tag); + } + */ return $docs; } From 2ca9569ddc4dcd73e97c0c9925794bf8374f388b Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Sun, 17 Nov 2019 23:29:10 +0100 Subject: [PATCH 005/125] Added tag descriptions from entities --- api/composer.json | 1 + api/composer.lock | 2 +- api/helm/values.yaml | 1 - api/src/Entity/ExampleEntity.php | 14 ++- api/src/Swagger/SwaggerDecorator.php | 155 +++++++++++++++++++++++---- 5 files changed, 152 insertions(+), 21 deletions(-) diff --git a/api/composer.json b/api/composer.json index 08220e05..5f2cf5aa 100644 --- a/api/composer.json +++ b/api/composer.json @@ -10,6 +10,7 @@ "doctrine/doctrine-fixtures-bundle": "^3.2", "guzzlehttp/guzzle": "^6.3", "lexik/jwt-authentication-bundle": "^2.6", + "phpdocumentor/reflection-docblock": "^4.3", "ramsey/uuid": "^3.8", "ramsey/uuid-doctrine": "^1.5", "sensiolabs/security-checker": "^6.0", diff --git a/api/composer.lock b/api/composer.lock index 1fbe45a6..cdf70a77 100644 --- a/api/composer.lock +++ b/api/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f3b8b4fa5bc19705f8f77ba64ce249e5", + "content-hash": "38df876b57237e6be24848f1f8f637da", "packages": [ { "name": "api-platform/api-pack", diff --git a/api/helm/values.yaml b/api/helm/values.yaml index fd5426c0..b53a056a 100644 --- a/api/helm/values.yaml +++ b/api/helm/values.yaml @@ -5,7 +5,6 @@ settings: registryBase: docker.io/conduction projectName: pc - version: dev env: dev debug: 1 replicaCount: 1 diff --git a/api/src/Entity/ExampleEntity.php b/api/src/Entity/ExampleEntity.php index 6fde0bc3..1ff29279 100644 --- a/api/src/Entity/ExampleEntity.php +++ b/api/src/Entity/ExampleEntity.php @@ -16,9 +16,21 @@ use App\Filter\LikeFilter; /** + * This is an example entity + * + * With an adtional description, all in all its pritty nice [url](www.google.nl) + * * @ApiResource( * normalizationContext={"groups"={"read"}, "enable_max_depth"=true}, - * denormalizationContext={"groups"={"write"}, "enable_max_depth"=true} + * denormalizationContext={"groups"={"write"}, "enable_max_depth"=true}, + * itemOperations={ + * "get","put","delete", + * "audittrail"={ + * "method"="GET", + * "name"="Provides an auditrail for this entity", + * "description"="Provides an auditrail for this entity" + * } + * } * ) * @ORM\Entity(repositoryClass="App\Repository\ExampleEntityRepository") * @Gedmo\Loggable diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index be6ac767..27754379 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -3,13 +3,12 @@ namespace App\Swagger; -use ApiPlatform\Core\Swagger\Serializer\DocumentationNormalizer; -use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Cache\Adapter\AdapterInterface as CacheInterface; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\Common\Annotations\AnnotationReader ; +use Doctrine\Common\Annotations\Reader as AnnotationReader; +use ApiPlatform\Core\PathResolver\OperationPathResolverInterface; final class SwaggerDecorator implements NormalizerInterface { @@ -22,8 +21,6 @@ final class SwaggerDecorator implements NormalizerInterface private $annotationReader; public function __construct( - ResourceMetadataFactoryInterface $metadataFactory, - DocumentationNormalizer $documentationNormalizer, NormalizerInterface $decorated, ParameterBagInterface $params, CacheInterface $cache, @@ -31,8 +28,6 @@ public function __construct( AnnotationReader $annotationReader ) { - $this->metadataFactory = $metadataFactory; - $this->documentationNormalizer = $documentationNormalizer; $this->decorated = $decorated; $this->params = $params; $this->cash = $cache; @@ -46,21 +41,46 @@ public function normalize($object, $format = null, array $context = []) /* The we need to enrich al the entities and add the autoated routes */ + + // Lets make sure that we have tags + if(!array_key_exists ('tags',$docs)){$docs['tags']=[];} + // Lets get al the entities known to doctrine $entities = $this->em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames(); // Then we loop trough the entities to find the api platform entities foreach($entities as $entity){ - $reflector = new \ReflectionClass($entity); - var_dump($this->annotationReader->getClassAnnotations($reflector)); - - // lest break for now - break; + //$reflector = new \ReflectionClass($entity); + $metadata = $this->em->getClassMetadata($entity); + $reflector = $metadata->getReflectionClass(); + + $properties = $metadata->getReflectionProperties(); + $annotations = $this->annotationReader->getClassAnnotations($reflector); - // If the entity is not a apiplatform entity lets continue - //if(){ - // continue - //} + foreach($annotations as $annotation){ + $annotationReflector = new \ReflectionClass($annotation); + if($annotationReflector->name == "ApiPlatform\Core\Annotation\ApiResource"){ + + // Lets add the class info to the tag + $shortName = $reflector->getShortName (); + + $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); + $docblock = $factory->create($reflector->getDocComment()); + $summary = $docblock->getSummary(); + $description = $docblock->getDescription()->render(); + $description = $summary."\n\n".$description; + + $tag = []; + $tag['name'] = $shortName; + $tag['description'] = $description; + + $docs['tags'][] = $tag; + + // And lets add the aditional docs + $this->getAdditionalEntityDocs($entity); + break; + } + } } @@ -164,13 +184,25 @@ public function normalize($object, $format = null, array $context = []) ]; // NLX loging headers $call['parameters'][] = [ - 'name' => 'X-Audit-Clarification', + 'name' => 'X-NLX-Audit-Clarification', 'description' => 'A clarification as to why a request has been made (doelbinding)', 'in' => 'header', ]; if($method == "get"){ + + + // Health JSON + $call['produces'][] = 'application/health+json'; + + // WEBSUB header + $call['parameters'][] = [ + 'name' => 'Link', + 'description' => 'A [websub](https://www.w3.org/TR/websub/#discovery) header like ; rel="hub"', + 'in' => 'header', + ]; + // Lets add the extend functionality $call['parameters'][] = [ 'name' => 'extend[]', @@ -208,7 +240,7 @@ public function normalize($object, $format = null, array $context = []) 'description' => 'Returns objects valid until a given date time', 'schema'=>['type'=>'string', 'format' => 'date-time'], 'in' => 'query', - ]; + ]; } } } @@ -247,6 +279,52 @@ public function normalize($object, $format = null, array $context = []) array_unshift($fruits_list, $tag); } */ + //var_dump($docs); + + + // Aditional tags + + + // Security tag + $tag = []; + $tag['name'] = 'Health Checks'; + $tag['description'] = 'Authorization'; + $tag['externalDocs'] = []; + $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; + array_unshift($docs['tags'], $tag); + + // Security tag + $tag = []; + $tag['name'] = 'Notifications'; + $tag['description'] = 'Authorization'; + $tag['externalDocs'] = []; + $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; + array_unshift($docs['tags'], $tag); + + + // Security tag + $tag = []; + $tag['name'] = 'Audit trail'; + $tag['description'] = 'Authorization'; + $tag['externalDocs'] = []; + $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; + array_unshift($docs['tags'], $tag); + + // Security tag + $tag = []; + $tag['name'] = 'Authorization'; + $tag['description'] = 'Authorization'; + $tag['externalDocs'] = []; + $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; + array_unshift($docs['tags'], $tag); + + // Security tag + + // Security tag + + //$docs['tags']['name'] + + var_dump($docs); return $docs; } @@ -254,4 +332,45 @@ public function supportsNormalization($data, $format = null) { return $this->decorated->supportsNormalization($data, $format); } + + private function getAdditionalEntityDocs($entity){ + + $metadata = $this->em->getClassMetadata($entity); + $reflector = $metadata->getReflectionClass(); + $properties = $metadata->getReflectionProperties(); + $annotations = $this->annotationReader->getClassAnnotations($reflector); + + // Add audittrail + // Add healthcheck + + //var_dump($propertyAnnotation); + + // Lets take a look at the properties an annotions, + foreach($properties as $property){ + + // The annotations for this propertu + $propertyAnnotations = $this->annotationReader->getPropertyAnnotations($property); + + // Check the annotations for symfony vallidations + foreach($propertyAnnotations as $propertyAnnotation){ + + // Lentgh + if(get_class($propertyAnnotation) == "Symfony\Component\Validator\Constraints\NotNull"){ + + } + + // Lentgh + if(get_class($propertyAnnotation) == "Symfony\Component\Validator\Constraints\Length"){ + + } + } + + } + + + + $additionalDocs = []; + + return $additionalDocs; + } } \ No newline at end of file From 7d8d29f4229e5d1252b58a7cd610dd5c35e0c631 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 19 Nov 2019 08:47:11 +0100 Subject: [PATCH 006/125] Added auth, notification, audittrail and healthchecks to config --- .env | 34 +++++++++++---- api/config/packages/api_platform.yaml | 7 +-- api/config/packages/twig.yaml | 15 +++++-- api/helm/templates/configmap.yaml | 13 +++++- api/helm/templates/php-deployment.yaml | 35 ++++++++++++++- api/src/Swagger/SwaggerDecorator.php | 59 ++++++++++++++------------ api/templates/helm/values.yaml.twig | 10 ++++- docker-compose.yml | 12 +++--- 8 files changed, 135 insertions(+), 50 deletions(-) diff --git a/.env b/.env index a6cbce66..9c0e599a 100644 --- a/.env +++ b/.env @@ -8,9 +8,13 @@ # Enviroment settings ################################################## -# Depracticed, now set as CONTAINER_PROJECT_NAME +# The shortcode for this component, should be a small set of letters reprecentint the application APP_NAME=pc -# Do you want to dsiplay the symfony debug toolbar? +# The Full title of the application +APP_TITLE=Proto Component +# The current version of the application +APP_VERSION=V.0.1 +# Do you want to display the symfony debug toolbar? APP_DEBUG=1 # What is the enviroment type you want to use for local production? (choose between dec,stag,prod, acce or test) APP_ENV=dev @@ -19,32 +23,44 @@ APP_ENV=dev # Documentation settings ################################################## -APP_DEMO=dev -APP_REPRO=dev +APP_DEMO=pc.zaakonline.nl +APP_REPRO=https://github.com/ConductionNL/Proto-component-commonground ################################################## # Docker settings ################################################## CONTAINER_REGISTRY_BASE=docker.io/conduction -CONTAINER_PROJECT_TITLE=Proto Component CONTAINER_PROJECT_NAME=pc -CONTAINER_PROJECT_VERSION=V.0.1 ################################################## -# Websub settings +# Notifcation settings ################################################## -WEBSUB_PROVIDER=sasd -WEBSUB_AUTHORIZATION=sasd +NOTIFICATION_ENABLED=false +NOTIFICATION_PROVIDER=sasd +NOTIFICATION_ENABLED_AUTHORIZATION=sasd ################################################## # Authorization settings ################################################## +AUTH_ENABLED=false AUTH_PROVIDER=sasd AUTH_AUTHORIZATION=sasd +################################################## +# Auditrail settings +################################################## + +AUDITTRAIL_ENABLED=false + +################################################## +# Healthcheck settings +################################################## + +HEALTH_ENABLED=false + ################################################## # NLX Setup, read more at https://docs.nlx.io/get-started/# ################################################## diff --git a/api/config/packages/api_platform.yaml b/api/config/packages/api_platform.yaml index de2b19c8..9c8fa787 100644 --- a/api/config/packages/api_platform.yaml +++ b/api/config/packages/api_platform.yaml @@ -23,11 +23,12 @@ api_platform: title: '%env(APP_TITLE)%' description: | API Details - - Component: %env(CONTAINER_PROJECT_TITLE)% - - Reference: %env(CONTAINER_PROJECT_NAME)% + - Component: %env(APP_TITLE)% + - Reference: %env(APP_NAME)% - Enviroment: %env(APP_ENV)% - - Version: %env(CONTAINER_PROJECT_VERSION)% + - Version: %env(APP_VERSION)% - Repository: [%env(APP_REPRO)%](%env(APP_REPRO)%) / [zip](%env(APP_REPRO)%/archive/master.zip) + - Docker Image: [%env(APP_REPRO)%](%env(APP_REPRO)%) - Datamodel: [postman](/schema/openapi.postman_collection) / [oas](/schema/openapi.yaml) / [pdf](/schema/datamodel.pdf) / [mwb](/schema/datamodel.mwb) %env(APP_DESCRIPTION)% diff --git a/api/config/packages/twig.yaml b/api/config/packages/twig.yaml index d58f0a2d..1a687ce2 100644 --- a/api/config/packages/twig.yaml +++ b/api/config/packages/twig.yaml @@ -5,15 +5,24 @@ twig: globals: google_tag_manager_id: '%env(GOOGLE_TAG_MANAGER_ID)%' hubspot_embed_code: '%env(HUBSPOT_EMBED_CODE)%' - container_registry_base: '%env(CONTAINER_REGISTRY_BASE)%' - container_project_title: '%env(CONTAINER_PROJECT_TITLE)%' + + container_registry_base: '%env(CONTAINER_REGISTRY_BASE)%' container_project_name: '%env(CONTAINER_PROJECT_NAME)%' - container_project_version: '%env(CONTAINER_PROJECT_VERSION)%' + + app_name: '%env(APP_NAME)%' + app_title: '%env(APP_TITLE)%' + app_version: '%env(APP_VERSION)%' app_env: '%env(APP_ENV)%' app_debug: '%env(APP_DEBUG)%' app_demo: '%env(APP_DEMO)%' app_repro: '%env(APP_REPRO)%' app_description: '%env(APP_DESCRIPTION)%' + + app_auth: '%env(AUTH_ENABLED)%' + app_audittrail: '%env(AUDITTRAIL_ENABLED)%' + app_notification: '%env(NOTIFICATION_ENABLED)%' + app_health: '%env(HEALTH_ENABLED)%' + nlx_outway: '%env(NLX_OUTWAY)%' nlx_inway: '%env(NLX_INWAY)%' form_themes: diff --git a/api/helm/templates/configmap.yaml b/api/helm/templates/configmap.yaml index 462fedb6..744744e6 100644 --- a/api/helm/templates/configmap.yaml +++ b/api/helm/templates/configmap.yaml @@ -11,12 +11,23 @@ metadata: app.kubernetes.io/managed-by: {{ .Release.Service }} data: project_name: {{ .Values.settings.projectName | quote }} + app-name: {{ .Values.settings.name | quote }} + app-title: {{ .Values.settings.title | quote }} + app-version: {{ .Values.settings.version | quote }} + app-repro: {{ .Values.settings.repro | quote }} + app-demo: {{ .Values.settings.demo | quote }} + + #config + app-auth: {{ .Values.settings.demo | quote }} + app-audittrail: {{ .Values.settings.app_audittrail | quote }} + app-notification: {{ .Values.settings.app_notification | quote }} + app-health: {{ .Values.settings.demo | quote }} + env: {{ .Values.settings.env | quote }} debug: {{ .Values.settings.debug | quote }} cors-allow-origin: {{ .Values.settings.corsAllowOrigin | quote }} trusted-proxies: {{ join "," .Values.settings.trustedProxies }} trusted-hosts: {{ .Values.settings.trustedHosts | quote }} - project-name: {{ .Values.settings.projectName | quote }} php-service: {{ include "name" . }}-{{ .Values.settings.env }}-php varnish-url: {{ if .Values.varnish.enabled }}http://varnish{{ else }}{{ .Values.varnish.url | quote }}{{ end }} diff --git a/api/helm/templates/php-deployment.yaml b/api/helm/templates/php-deployment.yaml index bd471b70..7f4e1b31 100644 --- a/api/helm/templates/php-deployment.yaml +++ b/api/helm/templates/php-deployment.yaml @@ -46,7 +46,17 @@ spec: valueFrom: configMapKeyRef: name: {{ template "fullname" . }} - key: project-name + key: app-name + - name: APP_TITLE + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: app-title + - name: APP_VERSION + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: app-version - name: APP_ENV valueFrom: configMapKeyRef: @@ -57,6 +67,29 @@ spec: configMapKeyRef: name: {{ template "fullname" . }} key: debug + # config + - name: AUTH_ENABLED + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: app-auth + - name: AUDITTRAIL_ENABLED + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: app-audittrail + - name: NOTIFICATION_ENABLED + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: app-notification + - name: HEALTH_ENABLED + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: app-health + + # bla bla - name: CORS_ALLOW_ORIGIN valueFrom: configMapKeyRef: diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index 27754379..8bed5f8b 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -286,41 +286,46 @@ public function normalize($object, $format = null, array $context = []) // Security tag - $tag = []; - $tag['name'] = 'Health Checks'; - $tag['description'] = 'Authorization'; - $tag['externalDocs'] = []; - $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; - array_unshift($docs['tags'], $tag); + if(getenv('HEALTH_ENABLED')){ + $tag = []; + $tag['name'] = 'Health Checks'; + $tag['description'] = 'Authorization'; + $tag['externalDocs'] = []; + $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; + array_unshift($docs['tags'], $tag); + } // Security tag - $tag = []; - $tag['name'] = 'Notifications'; - $tag['description'] = 'Authorization'; - $tag['externalDocs'] = []; - $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; - array_unshift($docs['tags'], $tag); - + if(getenv('NOTIFICATION_ENABLED')){ + $tag = []; + $tag['name'] = 'Notifications'; + $tag['description'] = 'Authorization'; + $tag['externalDocs'] = []; + $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; + array_unshift($docs['tags'], $tag); + } - // Security tag - $tag = []; - $tag['name'] = 'Audit trail'; - $tag['description'] = 'Authorization'; - $tag['externalDocs'] = []; - $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; - array_unshift($docs['tags'], $tag); // Security tag - $tag = []; - $tag['name'] = 'Authorization'; - $tag['description'] = 'Authorization'; - $tag['externalDocs'] = []; - $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; - array_unshift($docs['tags'], $tag); + if(getenv('AUDITTRAIL_ENABLED')){ + $tag = []; + $tag['name'] = 'Audit trail'; + $tag['description'] = 'Authorization'; + $tag['externalDocs'] = []; + $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; + array_unshift($docs['tags'], $tag); + } // Security tag + if(getenv('AUTH_ENABLED')){ + $tag = []; + $tag['name'] = 'Authorization'; + $tag['description'] = 'Authorization'; + $tag['externalDocs'] = []; + $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; + array_unshift($docs['tags'], $tag); + } - // Security tag //$docs['tags']['name'] diff --git a/api/templates/helm/values.yaml.twig b/api/templates/helm/values.yaml.twig index 1d024ae9..9a2e6d2a 100644 --- a/api/templates/helm/values.yaml.twig +++ b/api/templates/helm/values.yaml.twig @@ -5,6 +5,11 @@ settings: registryBase: {{ container_registry_base }} projectName: {{ container_project_name }} + name: {{ app_name }} + title: {{ app_title }} + version: {{ app_version }} + repro: {{ app_repro }} + demo: {{ app_demo }} env: {{ app_env }} debug: {{ app_debug }} replicaCount: 1 @@ -20,7 +25,10 @@ settings: loadbalancerEnabled: false # If you want to enable NLX you are requered to add the appropreate certificates to you nlx-settings folder (located in the /api folder) nlxInwayEnabled: {{ nlx_inway }} - nlxOutwayEnabled: {{ nlx_outway }} + # If you are runnig a single component on a kubernetes cluster you can just easaliy enable the load balancer, if not you need to set up a multi component load balancer + notificationEnabled: false + audittrailEnabled: false + authorisationEnabled: false php: diff --git a/docker-compose.yml b/docker-compose.yml index 1506d754..afd238d8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,15 +29,17 @@ services: environment: - APP_ENV=${APP_ENV} - APP_DEBUG=${APP_DEBUG} - - APP_VERSION=${CONTAINER_PROJECT_VERSION} - - APP_TITLE=${CONTAINER_PROJECT_TITLE} - - APP_NAME=${CONTAINER_PROJECT_NAME} + - APP_VERSION=${APP_VERSION} + - APP_NAME=${APP_NAME} + - APP_TITLE=${APP_TITLE} + - AUTH_ENABLED=${AUTH_ENABLED} + - AUDITTRAIL_ENABLED=${AUDITTRAIL_ENABLED} + - NOTIFICATION_ENABLED=${NOTIFICATION_ENABLED} + - HEALTH_ENABLED=${HEALTH_ENABLED} - NLX_OUTWAY=${NLX_OUTWAY} - NLX_INWAY=${NLX_INWAY} - CONTAINER_REGISTRY_BASE=${CONTAINER_REGISTRY_BASE} - - CONTAINER_PROJECT_TITLE=${CONTAINER_PROJECT_TITLE} - CONTAINER_PROJECT_NAME=${CONTAINER_PROJECT_NAME} - - CONTAINER_PROJECT_VERSION=${CONTAINER_PROJECT_VERSION} - DATABASE_URL=postgres://api-platform:!ChangeMe!@db/api?serverVersion=10.1 ports: - "8082:80" From a5add0a8736440d8166ee00203b81dac04d4c301 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 19 Nov 2019 08:53:01 +0100 Subject: [PATCH 007/125] Added Archive configuration --- .env | 6 ++++++ api/helm/templates/configmap.yaml | 9 +++++---- api/helm/templates/php-deployment.yaml | 5 +++++ api/templates/helm/values.yaml.twig | 2 ++ docker-compose.yml | 1 + 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 9c0e599a..bd3a2c4b 100644 --- a/.env +++ b/.env @@ -61,6 +61,12 @@ AUDITTRAIL_ENABLED=false HEALTH_ENABLED=false +################################################## +# Archive settings +################################################## + +ARCHIVE_ENABLED=false + ################################################## # NLX Setup, read more at https://docs.nlx.io/get-started/# ################################################## diff --git a/api/helm/templates/configmap.yaml b/api/helm/templates/configmap.yaml index 744744e6..fb7093d7 100644 --- a/api/helm/templates/configmap.yaml +++ b/api/helm/templates/configmap.yaml @@ -18,10 +18,11 @@ data: app-demo: {{ .Values.settings.demo | quote }} #config - app-auth: {{ .Values.settings.demo | quote }} - app-audittrail: {{ .Values.settings.app_audittrail | quote }} - app-notification: {{ .Values.settings.app_notification | quote }} - app-health: {{ .Values.settings.demo | quote }} + app-auth: {{ .Values.settings.authorisationEnabled | quote }} + app-audittrail: {{ .Values.settings.audittrailEnabled | quote }} + app-notification: {{ .Values.settings.notificationEnabled | quote }} + app-health: {{ .Values.settings.healthEnabled | quote }} + app-archive: {{ .Values.settings.archiveEnabled | quote }} env: {{ .Values.settings.env | quote }} debug: {{ .Values.settings.debug | quote }} diff --git a/api/helm/templates/php-deployment.yaml b/api/helm/templates/php-deployment.yaml index 7f4e1b31..21884a08 100644 --- a/api/helm/templates/php-deployment.yaml +++ b/api/helm/templates/php-deployment.yaml @@ -88,6 +88,11 @@ spec: configMapKeyRef: name: {{ template "fullname" . }} key: app-health + - name: ARCHIVE_ENABLED + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: app-archive # bla bla - name: CORS_ALLOW_ORIGIN diff --git a/api/templates/helm/values.yaml.twig b/api/templates/helm/values.yaml.twig index 9a2e6d2a..059cb8fb 100644 --- a/api/templates/helm/values.yaml.twig +++ b/api/templates/helm/values.yaml.twig @@ -29,6 +29,8 @@ settings: notificationEnabled: false audittrailEnabled: false authorisationEnabled: false + healthEnabled: false + archiveEnabled: false php: diff --git a/docker-compose.yml b/docker-compose.yml index afd238d8..8c89927d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,6 +36,7 @@ services: - AUDITTRAIL_ENABLED=${AUDITTRAIL_ENABLED} - NOTIFICATION_ENABLED=${NOTIFICATION_ENABLED} - HEALTH_ENABLED=${HEALTH_ENABLED} + - ARCHIVE_ENABLED=${ARCHIVE_ENABLED} - NLX_OUTWAY=${NLX_OUTWAY} - NLX_INWAY=${NLX_INWAY} - CONTAINER_REGISTRY_BASE=${CONTAINER_REGISTRY_BASE} From 5f7dbcf10c589882d7a8a8ec46c8fafb3a82cb6e Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 19 Nov 2019 11:03:04 +0100 Subject: [PATCH 008/125] Notification, Audittrail, Archive, Timetravel & expand functionality --- .env | 1 + api/config/packages/api_platform.yaml | 17 +-- api/helm/Chart.yaml | 2 +- api/helm/templates/php-deployment.yaml | 10 ++ api/helm/values.yaml | 12 +- api/public/schema/openapi.yaml | 158 ++++++------------------- api/src/Swagger/SwaggerDecorator.php | 12 +- api/templates/helm/Chart.yaml.twig | 4 +- docker-compose.yml | 3 + 9 files changed, 76 insertions(+), 143 deletions(-) diff --git a/.env b/.env index bd3a2c4b..85eed307 100644 --- a/.env +++ b/.env @@ -32,6 +32,7 @@ APP_REPRO=https://github.com/ConductionNL/Proto-component-commonground CONTAINER_REGISTRY_BASE=docker.io/conduction CONTAINER_PROJECT_NAME=pc +CONTAINER_REPRO=https://hub.docker.com/repository/docker/conduction/pc-php ################################################## # Notifcation settings diff --git a/api/config/packages/api_platform.yaml b/api/config/packages/api_platform.yaml index 9c8fa787..4f35c06b 100644 --- a/api/config/packages/api_platform.yaml +++ b/api/config/packages/api_platform.yaml @@ -4,16 +4,16 @@ parameters: # environment variables are not available yet. # You should not need to change this value. env(VARNISH_URL): '' - env(APP_VERSION): '' + env(APP_VERSION): ' + env(APP_NAME): ''' env(APP_TITLE): '' env(APP_DESCRIPTION): '' env(APP_REPRO): '' env(APP_DEMO): '' env(APP_ENV): '' env(CONTAINER_REGISTRY_BASE): '' - env(CONTAINER_PROJECT_TITLE): '' env(CONTAINER_PROJECT_NAME): '' - env(CONTAINER_PROJECT_VERSION): '' + env(CONTAINER_REPRO): '' api_platform: mapping: @@ -27,16 +27,11 @@ api_platform: - Reference: %env(APP_NAME)% - Enviroment: %env(APP_ENV)% - Version: %env(APP_VERSION)% - - Repository: [%env(APP_REPRO)%](%env(APP_REPRO)%) / [zip](%env(APP_REPRO)%/archive/master.zip) - - Docker Image: [%env(APP_REPRO)%](%env(APP_REPRO)%) + - Repository: [online](%env(APP_REPRO)%) / [zip](%env(APP_REPRO)%/archive/master.zip) + - Docker Image: [online](%env(CONTAINER_REPRO)%) - Datamodel: [postman](/schema/openapi.postman_collection) / [oas](/schema/openapi.yaml) / [pdf](/schema/datamodel.pdf) / [mwb](/schema/datamodel.mwb) - %env(APP_DESCRIPTION)% - - Voor het gebruik van deze applicatie is een JWT Token nodig, deze hangt altijd vast aan een applicatie, ofwel user. Geldige JWT Tokens worden aangemaakt bij het registreren van een applicatie en kennen een beperkte houdbaarheid. - JWT Tokens kunnen zowel worden verlengd, als opnieuw worden aangevraagd, dit aan de hand van de applicatie id en sleutel. - Let er bij het meegeven van JWT tokens op dat deze moet worden voorafgegaan door een Bearer en een spatie, onder de header Authorization. De volledig naam wordt daarmee: 'Authorization: Bearer [TOKEN]'. - + %env(APP_DESCRIPTION)% version: '%env(APP_VERSION)%' diff --git a/api/helm/Chart.yaml b/api/helm/Chart.yaml index 858796cb..31ac8664 100644 --- a/api/helm/Chart.yaml +++ b/api/helm/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 appVersion: V.0.1 description: Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar. -name: protocomponent +name: pc version: 0.1.0 home: https://common-ground.dev icon: https://common-ground.dev/logo-250x250.png \ No newline at end of file diff --git a/api/helm/templates/php-deployment.yaml b/api/helm/templates/php-deployment.yaml index 21884a08..bca6a7fc 100644 --- a/api/helm/templates/php-deployment.yaml +++ b/api/helm/templates/php-deployment.yaml @@ -67,6 +67,16 @@ spec: configMapKeyRef: name: {{ template "fullname" . }} key: debug + - name: APP_DEMO + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: app-demo + - name: APP_REPRO + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: app-repro # config - name: AUTH_ENABLED valueFrom: diff --git a/api/helm/values.yaml b/api/helm/values.yaml index b53a056a..b79502c2 100644 --- a/api/helm/values.yaml +++ b/api/helm/values.yaml @@ -5,6 +5,11 @@ settings: registryBase: docker.io/conduction projectName: pc + name: pc + title: Proto Component + version: V.0.1 + repro: https://github.com/ConductionNL/Proto-component-commonground + demo: pc.zaakonline.nl env: dev debug: 1 replicaCount: 1 @@ -20,7 +25,12 @@ settings: loadbalancerEnabled: false # If you want to enable NLX you are requered to add the appropreate certificates to you nlx-settings folder (located in the /api folder) nlxInwayEnabled: false - nlxOutwayEnabled: true + # If you are runnig a single component on a kubernetes cluster you can just easaliy enable the load balancer, if not you need to set up a multi component load balancer + notificationEnabled: false + audittrailEnabled: false + authorisationEnabled: false + healthEnabled: false + archiveEnabled: false php: diff --git a/api/public/schema/openapi.yaml b/api/public/schema/openapi.yaml index cb1cc166..549b9016 100644 --- a/api/public/schema/openapi.yaml +++ b/api/public/schema/openapi.yaml @@ -8,14 +8,11 @@ info: - Reference: pc - Enviroment: dev - Version: V.0.1 - - Repository: []() / [zip](/archive/master.zip) + - Repository: [online](https://github.com/ConductionNL/Proto-component-commonground) / [zip](https://github.com/ConductionNL/Proto-component-commonground/archive/master.zip) + - Docker Image: [online](https://hub.docker.com/repository/docker/conduction/pc-php) - Datamodel: [postman](/schema/openapi.postman_collection) / [oas](/schema/openapi.yaml) / [pdf](/schema/datamodel.pdf) / [mwb](/schema/datamodel.mwb) Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar. - - Voor het gebruik van deze applicatie is een JWT Token nodig, deze hangt altijd vast aan een applicatie, ofwel user. Geldige JWT Tokens worden aangemaakt bij het registreren van een applicatie en kennen een beperkte houdbaarheid. - JWT Tokens kunnen zowel worden verlengd, als opnieuw worden aangevraagd, dit aan de hand van de applicatie id en sleutel. - Let er bij het meegeven van JWT tokens op dat deze moet worden voorafgegaan door een Bearer en een spatie, onder de header Authorization. De volledig naam wordt daarmee: 'Authorization: Bearer [TOKEN]'. paths: /example_entities: @@ -114,9 +111,13 @@ paths: description: 'A key-value list of data subjects related to this request. e.g. `bsn=12345678, kenteken=ab-12-fg`' in: header - - name: X-Audit-Clarification + name: X-NLX-Audit-Clarification description: 'A clarification as to why a request has been made (doelbinding)' in: header + - + name: Link + description: 'A [websub](https://www.w3.org/TR/websub/#discovery) header like ; rel="hub"' + in: header - name: 'extend[]' required: false @@ -155,6 +156,8 @@ paths: type: string format: date-time in: query + produces: + - application/health+json post: tags: - ExampleEntity @@ -252,14 +255,14 @@ paths: description: 'A key-value list of data subjects related to this request. e.g. `bsn=12345678, kenteken=ab-12-fg`' in: header - - name: X-Audit-Clarification + name: X-NLX-Audit-Clarification description: 'A clarification as to why a request has been made (doelbinding)' in: header '/example_entities/{id}': get: tags: - ExampleEntity - operationId: getExampleEntityItem + operationId: audittrailExampleEntityItem summary: 'Retrieves a ExampleEntity resource.' parameters: - @@ -294,9 +297,13 @@ paths: description: 'A key-value list of data subjects related to this request. e.g. `bsn=12345678, kenteken=ab-12-fg`' in: header - - name: X-Audit-Clarification + name: X-NLX-Audit-Clarification description: 'A clarification as to why a request has been made (doelbinding)' in: header + - + name: Link + description: 'A [websub](https://www.w3.org/TR/websub/#discovery) header like ; rel="hub"' + in: header - name: 'extend[]' required: false @@ -365,52 +372,8 @@ paths: $ref: '#/components/schemas/ExampleEntity-read' 404: description: 'Resource not found' - delete: - tags: - - ExampleEntity - operationId: deleteExampleEntityItem - summary: 'Removes the ExampleEntity resource.' - responses: - 204: - description: 'ExampleEntity resource deleted' - 404: - description: 'Resource not found' - parameters: - - - name: id - in: path - required: true - schema: - type: string - - - name: Authorization - description: 'The JWT of the entity performing the request' - in: header - - - name: API-Version - description: 'The version of the API conform [Landelijke API-strategie.](https://geonovum.github.io/KP-APIs/#versioning)' - example: 1.0.1 - in: header - - - name: X-NLX-Logrecord-ID - description: 'A globally unique id of the request, which makes a request traceable throughout the network.' - in: header - - - name: X-NLX-Request-Process-Id - description: 'A process id for purpose registration (doelbinding)' - in: header - - - name: X-NLX-Request-Data-Elements - description: 'A list of requested data elements' - in: header - - - name: X-NLX-Request-Data-Subject - description: 'A key-value list of data subjects related to this request. e.g. `bsn=12345678, kenteken=ab-12-fg`' - in: header - - - name: X-Audit-Clarification - description: 'A clarification as to why a request has been made (doelbinding)' - in: header + produces: + - application/health+json put: tags: - ExampleEntity @@ -449,7 +412,7 @@ paths: description: 'A key-value list of data subjects related to this request. e.g. `bsn=12345678, kenteken=ab-12-fg`' in: header - - name: X-Audit-Clarification + name: X-NLX-Audit-Clarification description: 'A clarification as to why a request has been made (doelbinding)' in: header responses: @@ -511,11 +474,16 @@ paths: schema: $ref: '#/components/schemas/ExampleEntity-write' description: 'The updated ExampleEntity resource' - patch: + delete: tags: - ExampleEntity - operationId: patchExampleEntityItem - summary: 'Updates the ExampleEntity resource.' + operationId: deleteExampleEntityItem + summary: 'Removes the ExampleEntity resource.' + responses: + 204: + description: 'ExampleEntity resource deleted' + 404: + description: 'Resource not found' parameters: - name: id @@ -549,73 +517,14 @@ paths: description: 'A key-value list of data subjects related to this request. e.g. `bsn=12345678, kenteken=ab-12-fg`' in: header - - name: X-Audit-Clarification + name: X-NLX-Audit-Clarification description: 'A clarification as to why a request has been made (doelbinding)' in: header - responses: - 200: - description: 'ExampleEntity resource updated' - content: - application/hal+json: - schema: - $ref: '#/components/schemas/ExampleEntity-read' - application/ld+json: - schema: - $ref: '#/components/schemas/ExampleEntity-read' - application/vnd.api+json: - schema: - $ref: '#/components/schemas/ExampleEntity-read' - application/json: - schema: - $ref: '#/components/schemas/ExampleEntity-read' - application/xml: - schema: - $ref: '#/components/schemas/ExampleEntity-read' - application/x-yaml: - schema: - $ref: '#/components/schemas/ExampleEntity-read' - text/csv: - schema: - $ref: '#/components/schemas/ExampleEntity-read' - text/html: - schema: - $ref: '#/components/schemas/ExampleEntity-read' - 400: - description: 'Invalid input' - 404: - description: 'Resource not found' - requestBody: - content: - application/hal+json: - schema: - $ref: '#/components/schemas/ExampleEntity-write' - application/ld+json: - schema: - $ref: '#/components/schemas/ExampleEntity-write' - application/vnd.api+json: - schema: - $ref: '#/components/schemas/ExampleEntity-write' - application/json: - schema: - $ref: '#/components/schemas/ExampleEntity-write' - application/xml: - schema: - $ref: '#/components/schemas/ExampleEntity-write' - application/x-yaml: - schema: - $ref: '#/components/schemas/ExampleEntity-write' - text/csv: - schema: - $ref: '#/components/schemas/ExampleEntity-write' - text/html: - schema: - $ref: '#/components/schemas/ExampleEntity-write' - description: 'The updated ExampleEntity resource' components: schemas: ExampleEntity-read: type: object - description: '' + description: 'This is an example entity' properties: id: readOnly: true @@ -630,7 +539,7 @@ components: - name ExampleEntity-write: type: object - description: '' + description: 'This is an example entity' required: - name properties: @@ -640,6 +549,13 @@ components: description: description: 'The description of this example property' type: string +tags: + - + name: ExampleEntity + description: | + This is an example entity + + With an adtional description, all in all its pritty nice [url](www.google.nl) host: irc.zaakonline.nl servers: - diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index 8bed5f8b..d7f0d214 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -286,7 +286,7 @@ public function normalize($object, $format = null, array $context = []) // Security tag - if(getenv('HEALTH_ENABLED')){ + if(getenv('HEALTH_ENABLED')=="true"){ $tag = []; $tag['name'] = 'Health Checks'; $tag['description'] = 'Authorization'; @@ -296,7 +296,7 @@ public function normalize($object, $format = null, array $context = []) } // Security tag - if(getenv('NOTIFICATION_ENABLED')){ + if(getenv('NOTIFICATION_ENABLED')=="true"){ $tag = []; $tag['name'] = 'Notifications'; $tag['description'] = 'Authorization'; @@ -307,7 +307,7 @@ public function normalize($object, $format = null, array $context = []) // Security tag - if(getenv('AUDITTRAIL_ENABLED')){ + if(getenv('AUDITTRAIL_ENABLED')=="true"){ $tag = []; $tag['name'] = 'Audit trail'; $tag['description'] = 'Authorization'; @@ -317,7 +317,7 @@ public function normalize($object, $format = null, array $context = []) } // Security tag - if(getenv('AUTH_ENABLED')){ + if(getenv('AUTH_ENABLED')=="true"){ $tag = []; $tag['name'] = 'Authorization'; $tag['description'] = 'Authorization'; @@ -327,9 +327,7 @@ public function normalize($object, $format = null, array $context = []) } - //$docs['tags']['name'] - - var_dump($docs); + //var_dump($docs); return $docs; } diff --git a/api/templates/helm/Chart.yaml.twig b/api/templates/helm/Chart.yaml.twig index 7795e920..6da2f97a 100644 --- a/api/templates/helm/Chart.yaml.twig +++ b/api/templates/helm/Chart.yaml.twig @@ -1,7 +1,7 @@ apiVersion: v1 -appVersion: {{ container_project_version }} +appVersion: {{ app_version }} description: {{ app_description }} -name: {{ container_project_title|replace({' ': ''})|lower }} +name: {{ app_name|replace({' ': ''})|lower }} version: 0.1.0 home: https://common-ground.dev icon: https://common-ground.dev/logo-250x250.png \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 8c89927d..1e2f587f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,6 +32,8 @@ services: - APP_VERSION=${APP_VERSION} - APP_NAME=${APP_NAME} - APP_TITLE=${APP_TITLE} + - APP_DEMO=${APP_DEMO} + - APP_REPRO=${APP_REPRO} - AUTH_ENABLED=${AUTH_ENABLED} - AUDITTRAIL_ENABLED=${AUDITTRAIL_ENABLED} - NOTIFICATION_ENABLED=${NOTIFICATION_ENABLED} @@ -41,6 +43,7 @@ services: - NLX_INWAY=${NLX_INWAY} - CONTAINER_REGISTRY_BASE=${CONTAINER_REGISTRY_BASE} - CONTAINER_PROJECT_NAME=${CONTAINER_PROJECT_NAME} + - CONTAINER_REPRO=${CONTAINER_REPRO} - DATABASE_URL=postgres://api-platform:!ChangeMe!@db/api?serverVersion=10.1 ports: - "8082:80" From 03ceb43aacce2391f0da15f32f8006c7f1f69e8b Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 19 Nov 2019 12:17:05 +0100 Subject: [PATCH 009/125] Update on helm files --- .env | 2 ++ INSTALLATION.md | 12 ++++++------ api/config/packages/api_platform.yaml | 2 +- api/helm/Chart.yaml | 2 +- api/helm/templates/configmap.yaml | 7 ++----- api/helm/templates/php-deployment.yaml | 5 +++++ api/helm/values.yaml | 3 ++- api/public/schema/openapi.yaml | 2 +- api/src/Entity/ExampleEntity.php | 25 +++++++++++++++++++++++++ api/templates/helm/Chart.yaml.twig | 2 +- api/templates/helm/values.yaml.twig | 3 ++- docker-compose.yml | 1 + 12 files changed, 49 insertions(+), 17 deletions(-) diff --git a/.env b/.env index 85eed307..0380f3ac 100644 --- a/.env +++ b/.env @@ -18,6 +18,8 @@ APP_VERSION=V.0.1 APP_DEBUG=1 # What is the enviroment type you want to use for local production? (choose between dec,stag,prod, acce or test) APP_ENV=dev +# The description for this api +APP_DESCRIPTION='Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.' ################################################## # Documentation settings diff --git a/INSTALLATION.md b/INSTALLATION.md index 63989676..05bad3ed 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -65,16 +65,16 @@ $ helm dependency update ./api/helm ``` If you want to create a new instance ```CLI -$ helm install --name pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1 -$ helm install --name pc-stag ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=stag --set settings.env=stag,settings.debug=0 -$ helm install --name pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=prod --set settings.env=prod,settings.debug=0 +$ helm install --name pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1,settings.loadbalancerEnabled=true +$ helm install --name pc-stag ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=stag --set settings.env=stag,settings.debug=0,settings.loadbalancerEnabled=true +$ helm install --name pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=prod --set settings.env=prod,settings.debug=0,settings.loadbalancerEnabled=true ``` Or update if you want to update an existing one ```CLI -$ helm upgrade pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1 -$ helm upgrade pc-stag ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=stag --set settings.env=stag,settings.debug=0 -$ helm upgrade pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=prod --set settings.env=prod,settings.debug=0 +$ helm upgrade pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1,settings.loadbalancerEnabled=true +$ helm upgrade pc-stag ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=stag --set settings.env=stag,settings.debug=0,settings.loadbalancerEnabled=true +$ helm upgrade pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=prod --set settings.env=prod,settings.debug=0,settings.loadbalancerEnabled=true ``` Or del if you want to delete an existing one diff --git a/api/config/packages/api_platform.yaml b/api/config/packages/api_platform.yaml index 4f35c06b..81c20da1 100644 --- a/api/config/packages/api_platform.yaml +++ b/api/config/packages/api_platform.yaml @@ -41,7 +41,7 @@ api_platform: enable_re_doc: true # In the NL api strategie we use snake case for naming - name_converter: 'Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter' + # name_converter: 'Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter' # Lets confirm to JSON-HA: first, as per common ground. But allow other serializers formats: diff --git a/api/helm/Chart.yaml b/api/helm/Chart.yaml index 31ac8664..7c3c8a6a 100644 --- a/api/helm/Chart.yaml +++ b/api/helm/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 appVersion: V.0.1 -description: Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar. +description: ''Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.'' name: pc version: 0.1.0 home: https://common-ground.dev diff --git a/api/helm/templates/configmap.yaml b/api/helm/templates/configmap.yaml index fb7093d7..61797a1f 100644 --- a/api/helm/templates/configmap.yaml +++ b/api/helm/templates/configmap.yaml @@ -16,21 +16,18 @@ data: app-version: {{ .Values.settings.version | quote }} app-repro: {{ .Values.settings.repro | quote }} app-demo: {{ .Values.settings.demo | quote }} - - #config + app-description: {{ .Values.settings.description | quote }} app-auth: {{ .Values.settings.authorisationEnabled | quote }} app-audittrail: {{ .Values.settings.audittrailEnabled | quote }} app-notification: {{ .Values.settings.notificationEnabled | quote }} app-health: {{ .Values.settings.healthEnabled | quote }} app-archive: {{ .Values.settings.archiveEnabled | quote }} - env: {{ .Values.settings.env | quote }} debug: {{ .Values.settings.debug | quote }} cors-allow-origin: {{ .Values.settings.corsAllowOrigin | quote }} trusted-proxies: {{ join "," .Values.settings.trustedProxies }} trusted-hosts: {{ .Values.settings.trustedHosts | quote }} - php-service: {{ include "name" . }}-{{ .Values.settings.env }}-php - + php-service: {{ include "name" . }}-{{ .Values.settings.env }}-php varnish-url: {{ if .Values.varnish.enabled }}http://varnish{{ else }}{{ .Values.varnish.url | quote }}{{ end }} mercure-publish-url: {{ .Values.mercure.publishUrl | quote }} mercure-subscribe-url: {{ .Values.mercure.subscribeUrl | quote }} diff --git a/api/helm/templates/php-deployment.yaml b/api/helm/templates/php-deployment.yaml index bca6a7fc..1b03232e 100644 --- a/api/helm/templates/php-deployment.yaml +++ b/api/helm/templates/php-deployment.yaml @@ -52,6 +52,11 @@ spec: configMapKeyRef: name: {{ template "fullname" . }} key: app-title + - name: APP_DESCRIPTION + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: app-description - name: APP_VERSION valueFrom: configMapKeyRef: diff --git a/api/helm/values.yaml b/api/helm/values.yaml index b79502c2..6bf6d3b2 100644 --- a/api/helm/values.yaml +++ b/api/helm/values.yaml @@ -8,7 +8,8 @@ settings: name: pc title: Proto Component version: V.0.1 - repro: https://github.com/ConductionNL/Proto-component-commonground + description: ''Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.'' + repro: https://github.com/ConductionNL/Proto-component-commonground' demo: pc.zaakonline.nl env: dev debug: 1 diff --git a/api/public/schema/openapi.yaml b/api/public/schema/openapi.yaml index 549b9016..d3c1e631 100644 --- a/api/public/schema/openapi.yaml +++ b/api/public/schema/openapi.yaml @@ -12,7 +12,7 @@ info: - Docker Image: [online](https://hub.docker.com/repository/docker/conduction/pc-php) - Datamodel: [postman](/schema/openapi.postman_collection) / [oas](/schema/openapi.yaml) / [pdf](/schema/datamodel.pdf) / [mwb](/schema/datamodel.mwb) - Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar. + 'Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.' paths: /example_entities: diff --git a/api/src/Entity/ExampleEntity.php b/api/src/Entity/ExampleEntity.php index 1ff29279..f41fad32 100644 --- a/api/src/Entity/ExampleEntity.php +++ b/api/src/Entity/ExampleEntity.php @@ -89,6 +89,19 @@ class ExampleEntity */ private $description; + /** + * @var string $camelCase Proof that we camel case our api + * @example Is the best group ever + * + * @Assert\Length( + * max = 2555 + * ) + * @Gedmo\Versioned + * @Groups({"read","write"}) + * @ORM\Column(type="string", length=255, nullable=true) + */ + private $camelCase; + public function getId(): ?int { return $this->id; @@ -118,4 +131,16 @@ public function setDescription(?string $description): self return $this; } + public function getCamelCase(): ?string + { + return $this->camelCase; + } + + public function setCamelCase(?string $camelCase): self + { + $this->camelCase = $camelCase; + + return $this; + } + } diff --git a/api/templates/helm/Chart.yaml.twig b/api/templates/helm/Chart.yaml.twig index 6da2f97a..821c26b2 100644 --- a/api/templates/helm/Chart.yaml.twig +++ b/api/templates/helm/Chart.yaml.twig @@ -1,6 +1,6 @@ apiVersion: v1 appVersion: {{ app_version }} -description: {{ app_description }} +description: '{{ app_description }}' name: {{ app_name|replace({' ': ''})|lower }} version: 0.1.0 home: https://common-ground.dev diff --git a/api/templates/helm/values.yaml.twig b/api/templates/helm/values.yaml.twig index 059cb8fb..33aebbd8 100644 --- a/api/templates/helm/values.yaml.twig +++ b/api/templates/helm/values.yaml.twig @@ -8,7 +8,8 @@ settings: name: {{ app_name }} title: {{ app_title }} version: {{ app_version }} - repro: {{ app_repro }} + description: '{{ app_description }}' + repro: {{ app_repro }}' demo: {{ app_demo }} env: {{ app_env }} debug: {{ app_debug }} diff --git a/docker-compose.yml b/docker-compose.yml index 1e2f587f..56e9368b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,6 +34,7 @@ services: - APP_TITLE=${APP_TITLE} - APP_DEMO=${APP_DEMO} - APP_REPRO=${APP_REPRO} + - APP_DESCRIPTION=${APP_DESCRIPTION} - AUTH_ENABLED=${AUTH_ENABLED} - AUDITTRAIL_ENABLED=${AUDITTRAIL_ENABLED} - NOTIFICATION_ENABLED=${NOTIFICATION_ENABLED} From 3801e401ba1abf90bcd3810565f5ee849a8d5425 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 19 Nov 2019 15:33:25 +0100 Subject: [PATCH 010/125] Fix on env variables --- api/config/packages/api_platform.yaml | 5 +++++ api/helm/templates/configmap.yaml | 2 ++ api/src/Entity/ExampleEntity.php | 2 +- docker-compose.yml | 8 ++++---- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/api/config/packages/api_platform.yaml b/api/config/packages/api_platform.yaml index 81c20da1..11f8555f 100644 --- a/api/config/packages/api_platform.yaml +++ b/api/config/packages/api_platform.yaml @@ -11,6 +11,11 @@ parameters: env(APP_REPRO): '' env(APP_DEMO): '' env(APP_ENV): '' + env(AUTH_ENABLED): '' + env(AUDITTRAIL_ENABLED): '' + env(NOTIFICATION_ENABLED): '' + env(HEALTH_ENABLED): '' + env(ARCHIVE_ENABLED): '' env(CONTAINER_REGISTRY_BASE): '' env(CONTAINER_PROJECT_NAME): '' env(CONTAINER_REPRO): '' diff --git a/api/helm/templates/configmap.yaml b/api/helm/templates/configmap.yaml index 61797a1f..55279410 100644 --- a/api/helm/templates/configmap.yaml +++ b/api/helm/templates/configmap.yaml @@ -17,11 +17,13 @@ data: app-repro: {{ .Values.settings.repro | quote }} app-demo: {{ .Values.settings.demo | quote }} app-description: {{ .Values.settings.description | quote }} + app-auth: {{ .Values.settings.authorisationEnabled | quote }} app-audittrail: {{ .Values.settings.audittrailEnabled | quote }} app-notification: {{ .Values.settings.notificationEnabled | quote }} app-health: {{ .Values.settings.healthEnabled | quote }} app-archive: {{ .Values.settings.archiveEnabled | quote }} + env: {{ .Values.settings.env | quote }} debug: {{ .Values.settings.debug | quote }} cors-allow-origin: {{ .Values.settings.corsAllowOrigin | quote }} diff --git a/api/src/Entity/ExampleEntity.php b/api/src/Entity/ExampleEntity.php index f41fad32..389740cf 100644 --- a/api/src/Entity/ExampleEntity.php +++ b/api/src/Entity/ExampleEntity.php @@ -91,7 +91,7 @@ class ExampleEntity /** * @var string $camelCase Proof that we camel case our api - * @example Is the best group ever + * @example Best api ever * * @Assert\Length( * max = 2555 diff --git a/docker-compose.yml b/docker-compose.yml index 56e9368b..43498f17 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,6 +27,10 @@ services: # If you develop on Linux, uncomment the following line to use a bind-mounted host directory instead # - ./api/var:/srv/api/var:rw environment: + - CONTAINER_REGISTRY_BASE=${CONTAINER_REGISTRY_BASE} + - CONTAINER_PROJECT_NAME=${CONTAINER_PROJECT_NAME} + - CONTAINER_REPRO=${CONTAINER_REPRO} + - DATABASE_URL=postgres://api-platform:!ChangeMe!@db/api?serverVersion=10.1 - APP_ENV=${APP_ENV} - APP_DEBUG=${APP_DEBUG} - APP_VERSION=${APP_VERSION} @@ -42,10 +46,6 @@ services: - ARCHIVE_ENABLED=${ARCHIVE_ENABLED} - NLX_OUTWAY=${NLX_OUTWAY} - NLX_INWAY=${NLX_INWAY} - - CONTAINER_REGISTRY_BASE=${CONTAINER_REGISTRY_BASE} - - CONTAINER_PROJECT_NAME=${CONTAINER_PROJECT_NAME} - - CONTAINER_REPRO=${CONTAINER_REPRO} - - DATABASE_URL=postgres://api-platform:!ChangeMe!@db/api?serverVersion=10.1 ports: - "8082:80" From 78127b20a09ad222f311cbea46d63cc66c406502 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Mon, 25 Nov 2019 10:25:04 +0100 Subject: [PATCH 011/125] Fixes on design.md --- DESIGN.md | 211 ++++++++++++++++++++++------ api/docker/php/docker-entrypoint.sh | 9 +- api/src/Entity/ExampleEntity.php | 2 + 3 files changed, 173 insertions(+), 49 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index ac705c08..1f5104e0 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -1,16 +1,124 @@ -# Design Considerations +# Design Considerations as Proposal + +Welcome, you are currently viewing the design decisions for the proto component. The proto component aims to provide a framework for the quick development of production apis for the commonground project. + +*index* +- [The European factor](#the-european-factor) +- [On standards and standardisation](#on-standards-and-standardization) +- [NL API Strategie](#nl-api-strategie) + +*Design Choices* +- [NLX](#nlx) +- [English](#english) +- [Fields](#fields) +- [Search](#search) +- [Queries](#queries) +- [Extending](#extending) +- [Timetravel](#timetravel) +- [Archivation](#archivation) +- [Audittrail](#audittrail) +- [Healthchecks](#healthchecks) +- [Notifications](#notifications) +- [Authentication](#authentication) +- [Authorization](#authorization) +- [Ordering](#ordering) +- [Translations](#translations) +- [Errors](#errors) +- [Arrays](#arrays) +- [Filtering](#filtering) + +*Implementation choices* +- [Api Versioning](#api-versioning) +- [Environments and namespacing](#environments-and-namespacing) +- [Domain Build-up and routing](#domain-build-up-and-routing) +- Container Setup](#container-setup) -This component was designed in line with the [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie), [NORA](https://www.noraonline.nl/wiki/Standaarden), [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/index), [commonground principles](https://vng.nl/onderwerpenindex/bestuur/samen-organiseren-2019/common-ground) and international standards. - -The specific goal of this component is to provide a common architecture for common ground components as such the common ground principles are leading in design choices, and within those principles technological invocation and international compliancy is deemed most important. **We do not want to mace consessions to the current infrastructure.** As such the component might differ on [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie), [NORA](https://www.noraonline.nl/wiki/Standaarden), [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/index) and other standards if they are deemed incompatible or out of line with international standards. The European factor ------- -The proto-component isn't just a Dutch Component, it is in essence a dutch translation of european components, nowhere is this more obvious than in the core code. Our component is based on [API Platform](https://api-platform.com/) an API specific version of the symfony framework. This framework is build by the lovely people of []() and is build with support of the European Commission trough the [EU-FOSSA Hackathon](https://ec.europa.eu/info/news/first-eu-fossa-hackathon-it-happened-2019-may-03_en) and Digital Ocean trough [Hacktoberfest](https://hacktoberfest.digitalocean.com/). +The proto-component isn't just a Dutch Component, it is in essence a Dutch translation of European components, nowhere is this more obvious than in the core code. Our component is based on [API Platform](https://api-platform.com/) an API specific version of the symfony framework. This framework is build by the lovely people of []() and is build with support of the European Commission trough the [EU-FOSSA Hackathon](https://ec.europa.eu/info/news/first-eu-fossa-hackathon-it-happened-2019-may-03_en) and Digital Ocean trough [Hacktoberfest](https://hacktoberfest.digitalocean.com/). + +But it doesn't just end there. The [varnish container](https://hub.docker.com/r/eeacms/varnish/) that we use to speed up the API response is build and maintained by [EEA]() (The European Environment Agency) and the development team at conduction itself is attached to the [Odyssey program](https://www.odyssey.org/) and originated from the [startupinresidence](https://startupinresidence.com/) program. + +So you could say that both change and a European perspective is in our blood. + +On standards and standardization +------- +The specific goal of the proto component (which this current code base is a version of) is to provide a common architecture for common ground components. As such the common ground principles are leading in design choices, and within those principles international compliancy and technological invocation is deemed most important. **We do not want to make concessions to the current infrastructure.** As such the component might differ on [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie), [NORA](https://www.noraonline.nl/wiki/Standaarden), [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/index) and or other standards if they are deemed incompatible or out of line with (inter)national standards and or good practices. + +Unfortunatly (inter)national standards standards can be conflicting. We therefore prioritize standards on two grounds + +- International standards are put before local standards +- Standards caried by a standard organisation (like ISO, W3C etc) at put before floating standards (like RFC's) wichs are put before industraty standards, good practices and so on. + +### Commonground specific standards + +This component was designed in line with the [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie), [NORA](https://www.noraonline.nl/wiki/Standaarden), [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/index), [commonground principles](https://vng.nl/onderwerpenindex/bestuur/samen-organiseren-2019/common-ground). + +## NL API Strategie + +The [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie) takes a special place in this component, it is designed as a set of guidelines for API's for the dutch landscape. As such we follow it as close as posible. It dos however contains inconsistenies with both international standards and good practices. On those items we do not follow the norm but consider it our duty to try to change the norm. + +** We implement ** + +api-01, api-02, api-03, api-05, api-06, api-10, api-11, api-12, api-13,api-14, api-16, api-18, api-19, api-20, api-21, api-22, api-23, api-24, api-25, api-26, api-27, api-28, api-29, api-30, api-33, api-34, api-35, api-42 + +** We want to implement ** +- [api-14](https://docs.geostandaarden.nl/api/API-Strategie/#api-14) Use OAuth 2.0 for authorisation + +** We do not implement ** + +- [api-04](https://docs.geostandaarden.nl/api/API-Strategie/#api-04) Define interfaces in Dutch unless there is an official English glossary (see [english](#english)) +- [api-09](https://docs.geostandaarden.nl/api/API-Strategie/#api-09) Implement custom representation if supported see [fields](#fields)) +- [api-17](https://docs.geostandaarden.nl/api/API-Strategie/#api-17) Publish documentation in Dutch unless there is existing documentation in English or there is an official English glossary (see [english](#english)) +- [api-31](https://docs.geostandaarden.nl/api/API-Strategie/#api-31) Use the query parameter sorteer to sort (see [ordering](#ordering)) +- [api-32](https://docs.geostandaarden.nl/api/API-Strategie/#api-32) Use the query parameter zoek for full-text search (see [search](#search)) +- [api-36](https://docs.geostandaarden.nl/api/API-Strategie/#api-36) Provide a POST endpoint for GEO queries (see [queries](#queries)) +- [api-37](https://docs.geostandaarden.nl/api/API-Strategie/#api-37) Support mixed queries at POST endpoints available (see [queries](#queries)) +*[api-38](https://docs.geostandaarden.nl/api/API-Strategie/#api-38) Put results of a global spatial query in the relevant geometric context (see [queries](#queries)) +- + +** We doubt or havn't made a choice yet about** + +- [api-15](https://docs.geostandaarden.nl/api/API-Strategie/#api-15) Use PKIoverheid certificates for access-restricted or purpose-limited API authentication +- [api-39](https://docs.geostandaarden.nl/api/API-Strategie/#api-39) Use ETRS89 as the preferred coordinate reference system (CRS) +- [api-40](https://docs.geostandaarden.nl/api/API-Strategie/#api-40) Pass the coordinate reference system (CRS) of the request and the response in the headers +- [api-41](https://docs.geostandaarden.nl/api/API-Strategie/#api-41) Use content negotiation to serve different CRS + +NLX +------- +We implement the [NLX system](https://docs.nlx.io/understanding-the-basics/introduction/) as part of the basic commonground infrastructure, as such nlx headers are used in the internal logging. +The following X-NLX headers have been implemented for that reason `X-NLX-Logrecord-ID`,`X-NLX-Request-Process-Id`,`X-NLX-Request-Data-Elements` and `X-NLX-Request-Data-Subject`, these are tied to the internal audit trail (see audit trail for more information), and `X-Audit-Toelichting` (from the ZGW APIs) is implemented as `X-Audit-Clarification` -But it doesn't just end there. The [varnish container](https://hub.docker.com/r/eeacms/varnish/) that we use to speed up the API responce it build and maintained by [EEA]() (The European Environment Agency) and the development team at conduction itself is attached to the [Odyssey program](https://www.odyssey.org/) and originated from the [startupinresidence](https://startupinresidence.com/) program. +We do not use other NLX headers since they (conform to the [NLX schema](https://docs.nlx.io/further-reading/transaction-logs/))wil not reach the provider. Please note that the use of nlx is optional. The component can be used without NLX. In that case the `X-NLX` header should be set to false, the `X-NLX-Logrecord-ID` should be provided with an log record designd by the client application to be retracable to a unique user and action. Other headers still aplly. -So you could say that both change and a european perspective is in our blood. +We strongly discourage the use of the `X-NLX-Request-Data-Subject` header as it might allow private data (such as BSNs) to show up in logging. + +English +------- +The [NL API Standard](https://geonovum.github.io/KP-APIs/#api-04-define-interfaces-in-dutch-unless-there-is-an-official-english-glossary) describes that there is a preference for Dutch in API documentation. + +> Define resources and the underlying entities, fields and so on (the information model ad the external interface) in Dutch. English is allowed in case there is an official English glossary. + +We view this as a breach with good coding practice and international coding standards, all documentation and code is therefore supplied in English. We do however provide transaltion (or i18n) support. + +Fields +------- +A part of the [haal centraal](https://raw.githubusercontent.com/VNG-Realisatie/Haal-Centraal-BRP-bevragen/master/api-specificatie/Bevraging-Ingeschreven-Persoon/openapi.yaml) the concept of field limitations has been introduced its general purpose being to allow an application to limit the returned fields to prevent the unnecessary transportation of (private) data. In the [NL API Strategie](https://github.com/VNG-Realisatie/Haal-Centraal-BRP-bevragen/blob/master/features/fields.feature) this has been implemented as a parameter consisting of comma separated values. However the normal web standard for optional lists (conform w3c form standards) is an array. + +Search +------- +As part of [api-32](https://docs.geostandaarden.nl/api/API-Strategie/#api-32) a `zoeken` query has been itroduced that can handle wildcards. This breaks best practice, first of allest practice is a `search` query parameter (see also the nodes on [English](#english)). Secondly wildcards are a sql concept, not a webconcept, they are also a rather old concept severly limiting the search options provided. Instead the [regeular expresion standard](https://en.wikipedia.org/wiki/Regular_expression) should be used. + +__solution__ +We implement a `search` query parameter on resource collections, that filters with regex. + +Queries +------- +In several examples of the nl apistrategie we see query parameters being atached to post requests. This is unusual in the sence that sending query strings allong with a post is ocnsiderd bad practice (becouse query parameters end up as part of an url and are therfore logged by servers). But is is technically posile folowing RFC 3986. The real pain is that in the NL api-stratgie the POST requests seems to be used to search, ot in other words GET data. This is where compliance with HTTP (1.1) breaks. + +__solution__ +We do not implement a query endpoint on post requests. Domain Build-up and routing @@ -36,25 +144,13 @@ Besides the API environments the component also ships with additional tools/envi On the local development docker deploy the client environment is used as default instead of the production version of the api. -Logging Headers (NLX Audit trail) -------- -@todo update, a reaction about this has been given by the NLX team. - -We inherit a couple of headers from the transaction logging within the [NLX schema](https://docs.nlx.io/further-reading/transaction-logs/), we strongly discourage the use of the `X-NLX-Request-Data-Subject` header as it might allow private data (such as BSNs) to show up in logging. - -__solution__ -The following X-NLX headers have been implemented `X-NLX-Logrecord-ID`,`X-NLX-Request-Process-Id`,`X-NLX-Request-Data-Elements` and `X-NLX-Request-Data-Subject`, these are tied to the internal audit trail (see audit trail for more information), and `X-Audit-Toelichting` (from the ZGW APIs) is implemented as `X-Audit-Clarification` - -Api versioning +Api Versioning ------- As per [landelijke API-strategie.](https://geonovum.github.io/KP-APIs/#versioning) major versions in endpoint minor versions in header, for this the `API-Version` is used (instead of the `api-version` header used in haal centraal) -Fields -------- -A part of the [haal centraal](https://raw.githubusercontent.com/VNG-Realisatie/Haal-Centraal-BRP-bevragen/master/api-specificatie/Bevraging-Ingeschreven-Persoon/openapi.yaml) the concept of field limitations has been introduced its general purpose being to allow an application to limit the returned fields to prevent the unnecessary transportation of (private) data. In the [NL API Strategie](https://github.com/VNG-Realisatie/Haal-Centraal-BRP-bevragen/blob/master/features/fields.feature) this has been implemented as a parameter consisting of comma separated values. However the normal web standard for optional lists (conform w3c form standards) is an array. __solution__ -The fields parameter and functionality has been implemented as an array +The fields parameter and functionality has been implemented as an array, and should be used that way. We do howver support an comma separted value list. Extending ------- @@ -65,60 +161,86 @@ The extend parameter has been implemented as an array Archivation ------- -In line with the extending and fields principle whereby we only want resources that we need it was deemed, nice to make a sub resource of the archivation properties. This also results in a bid cleaner code. +There is a need (by law) for archivation, meaning that we should only keep resources for a fixed amount of time and delete them there afther. In line with the extending and fields principle whereby we only want resource properties that we need when we needid, it is deemded good practice make a sub resource of the archivation properties. For the archivation proterties the [zgw](https://zaken-api.vng.cloud/api/v1/schema/#operation/zaak_list) is followed and translated to englisch. + + +```json +{ + "id": "e2984465-190a-4562-829e-a8cca81aa35d", + "nomination": "destroy", + "action_date": "2019-11-25T07:26:54Z", + "status": "to_be_archived", +} +``` + +This gives us an intresting thought, acording to [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie/#api-10-implement-operations-that-do-not-fit-the-crud-model-as-sub-resources) subresources should have there own endpoint. Therefore we could use a archive sub of a difrend object for archivation rules e.g. /zaken/{uuid}/archivation for a verzoek. This in itself leads credence to the thought that archivation should have its own central crud api. Audittrail ------- -@todo this needs to be implemented -For notifications we use the base mechanism as provided by [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/audit-trail) but we differ on insight into the data that should be returned and feel that the international standard [RFC 3881](https://tools.ietf.org/html/rfc3881) should have been followed here. +For audittrail we use the base mechanism as provided by [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/audit-trail), we do however diver on some key point, +- Personal data schould never be part of a log, therefore only the user id with the client should be logged (insted of the name) +- Besides an endpoint per resource there should be a general enpoint to search all audit trials of a component +- [Timetravel](#timetravel) in combinaition with objects versioning makes the return of complete objects unnecesary. But an auditrail endpoint should support the [extend](#extending) functionalitiy to provide the option of obtaining complete objects. + __solution__ -In compliance with [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/audit-trail) each individual object should support an /audittrail endpoint. You can look into the [tutorial](TUTORIAL.md) for specifications on how to activate an audit trail for a given object. However, instead of the values mention in the vng.cloud design we follow [RFC 3881](https://tools.ietf.org/html/rfc3881) for the return values. And we give NLX values precedence if provided. +In compliance with [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/audit-trail) each individual object should support an /audittrail endpoint. You can look into the [tutorial](TUTORIAL.md) for specifications on how to activate an audit trail for a given object. + +Healthchecks +------- +From [issue 154](https://github.com/VNG-Realisatie/huwelijksplanner/issues/154) + +For healthc + +__solution__ + Notifications ------- -@todo this needs to be implemented -For notifications we do not use the current [ZGW standard](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/notificaties) since we deem it insecure to send properties or data objects along with a notification. This is a potential security breach explained [here](https://github.com/VNG-Realisatie/gemma-zaken/issues/1427#issuecomment-549272696). It also doesn�t follow the [web standard](https://www.w3.org/TR/websub/). Instead we are developing our own subscriber service that is tailored for the NLX / VNG environment and based on current web standards [here](). +For notifications we do not YET use the current [ZGW standard](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/notificaties) since there is an [dicusion](https://github.com/VNG-Realisatie/gemma-zaken/issues/1427#issuecomment-549272696) about the posible insecurity of sending properties or data objects along with a notification. It also dosn't follow the [web standard](https://www.w3.org/TR/websub/). We wait for the conclusion of that discusion before making an implementation. + +__solution__ +In compliance with [w3.org](https://www.w3.org/TR/websub/) each endpoint returns an header containing an subscribtion url. That can be used in acordanse with the application to subscribe to both individual objects as collections. whereby collections serve as 'kanalen'. We aim to implement the ZGW notificatie component, but feel that further features on that component would be required to make to be fully suported. We will suply feature requests per issue to support this effort. + +Authentication +------- __solution__ -In compliance with [w3.org](https://www.w3.org/TR/websub/) each endpoint returns an header containing an subscribtion url. That can be used in acordanse with the application to subscribe to both individual objects as collections. whereby collections serve as 'kanalen'. -Scopes, Authentication and Authorization +Authorization ------- -@todo this needs to be implemented -We implement user scopes as per [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/autorisatie-scopes) standard. But see problems with how the scopes are defined and named, and consider the general setup to be to focused on ZGW (including Dutch naming, zgw specific fields like maxVertrouwlijkheid and a lack of CRUD thinking). There is a further document concerning [Authentication and Authorization](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/authenticatie-autorisatie) that details how we should authenticate users and give them scopes. We agree with the principles of the document on application based authorization and the use of JWT tokens. But disagree on some key technical aspect. Most important being that the architecture doesn't take into consideration the use of one component by several organizations +We implement user scopes as per [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/autorisatie-scopes) standard. But see problems with how the scopes are defined and named, and consider the general setup to be to focused on ZGW (including Dutch naming, zgw specific fields like maxVertrouwlijkheid and a lack of CRUD thinking). There is a further document concerning [Authentication and Authorization](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/authenticatie-autorisatie) that details how we should authenticate users and give them scopes. We agree with the principles of the document on application based authorization and the use of JWT tokens. But disagree on some key technical aspect. Most important being that the architecture doesn't take into consideration the use of one component by several organizations at once. Or scopese per property. __solution__ -No solution as of yet, so there is no implementation of Authorization or Scopes. We might build a new Authorization Component in the long run. +No solution as of yet, so there is no implementation of Authorization or Scopes. We aim to implement the ZGW authorisatie component, but feel that further features on that component would be required to make to be fully suported. We will suply feature requests per issue to support this effort. Timetravel ------- A part of the [haal centraal](https://raw.githubusercontent.com/VNG-Realisatie/Haal-Centraal-BRP-bevragen/master/api-specificatie/Bevraging-Ingeschreven-Persoon/openapi.yaml) the concept of timetravel has been introduced, as in getting the version of an object as it was on a given date. For this the `geldigop` [see the docs](file:///C:/Users/ruben/Desktop/doc_gba_historie.html#operation/getBewoningen) header is used. In addition the `geldigvan` and `geldigtot` are introduced as collection filters. -The commonground proto componant natively supports time traveling on all entities that are annotaded with the @Gedmo\Loggable, this is done by adding the ?validOn=[date] query to a request, date can either be a datetime or datedatime string. Any value supported by php's [strtotime()](https://www.php.net/manual/en/function.strtotime.php) is supported. Keep in mind that this returns the entity a as it was valid on that time or better put, the last changed version BEFORE that moment. To get a complete list of all changes on a item the ?showLogs=true quarry can be used. +The commonground proto componant natively supports time traveling on all entities that are annotaded with the @Gedmo\Loggable, this is done by adding the ?validOn=[date] query to a request, date can either be a datetime or datedatime string. Any value supported by php's [strtotime()](https://www.php.net/manual/en/function.strtotime.php) is supported. Keep in mind that this returns the entity a as it was valid on that time or better put, the last changed version BEFORE that moment. To get a complete list of all changes on a item the /audittrail endpoint can be used. __solution__ -In compliance with [schema.org](https://schema.org/validFrom) `geldigop`,`geldigvan` and `geldigtot` are implemented as `validOn`,`validFrom` and `validUntil`. And can be used a query parameters on colelction operations. +In compliance with [schema.org](https://schema.org/validFrom) `geldigop`,`geldigvan` and `geldigtot` are implemented as `validOn`,`validFrom` and `validUntil`. And can be used a query parameters on collection operations/ -Additionally `validOn` can be used on a single object get request to get the version of that object on a given date, a 404 is returned if no version of that object can be given for that date +Additionally `validOn` can be used on a single object get request to get the version of that object on a given date, a 404 is returned if no version of that object can be given for the given date -Ordering results +Ordering ------- In the [zaak-api](https://zaken-api.vng.cloud/api/v1/schema/#operation/zaak_list) ordering is done in a single field parameter, we however prefer to be able to order on multiple fields in combination of ascending and descending orders. We therefore implement an order parameter as array where they key is the property on wish should be ordered and the value the type of ordering e.g. `?order[name]=desc&order[status]=asc`. The order in which the keys are added to the order array determines the order in which they are applied. -Dutch versus English -------- -The [NL API Standard](https://geonovum.github.io/KP-APIs/#api-04-define-interfaces-in-dutch-unless-there-is-an-official-english-glossary) describes that there is a preference for Dutch in API documentation. - -> Define resources and the underlying entities, fields and so on (the information model ad the external interface) in Dutch. English is allowed in case there is an official English glossary. - -We view this as a breach with good coding practice and international coding standards, all documentation is therefore supplied in English +Translations +------- +We support translations trough the `Accept-Language` header (read the [docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language)), the fallback langouge for all messages is englisch +Errors +------- +See [jsonapi](https://jsonapi.org/examples/#error-objects) and the [rfc](https://tools.ietf.org/html/rfc7807). -Comma Notation versus Bracket Notation on arrays's +Arrays ------- The NL API standard uses comma notation on array's in http requests. E.g. fields=id,name,description however common browsers(based on chromium e.g. chrome and edge) use bracket notation for query style array's e.g. fields[]=id&fields[]=name,&fields[]=description. The difference of course is obvious since comma notation doesn't allow you to index arrays. [Interestingly enough there isn't actually a rfc spec for this](https://stackoverflow.com/questions/15854017/what-rfc-defines-arrays-transmitted-over-http). @@ -202,3 +324,4 @@ A component is (speaking in kubernetes terms) a service that is available at | string | bsn | | | | | | string | iban | | | | | | | | | | | | + diff --git a/api/docker/php/docker-entrypoint.sh b/api/docker/php/docker-entrypoint.sh index 459dee21..2f39d520 100755 --- a/api/docker/php/docker-entrypoint.sh +++ b/api/docker/php/docker-entrypoint.sh @@ -62,14 +62,13 @@ if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then echo "Loading fixtures" bin/console doctrine:fixtures:load --no-interaction - # echo "Creating OAS documentation" # Lets update the docs to show the latest chages - # bin/console api:openapi:export --output=/srv/api/public/schema/openapi.yaml --yaml --spec-version=3 + echo "Creating OAS documentation" + bin/console api:openapi:export --output=/srv/api/public/schema/openapi.yaml --yaml --spec-version=3 # this should only be done in an build - # echo "Updating Helm charts" - # Lets update the docs to show the latest chages - # bin/console app:helm:update --location=/srv/api/helm --spec-version=3 + echo "Updating Helm charts" + bin/console app:helm:update --location=/srv/api/helm --spec-version=3 fi fi diff --git a/api/src/Entity/ExampleEntity.php b/api/src/Entity/ExampleEntity.php index 389740cf..8eee3dac 100644 --- a/api/src/Entity/ExampleEntity.php +++ b/api/src/Entity/ExampleEntity.php @@ -1,5 +1,7 @@ Date: Mon, 25 Nov 2019 16:24:16 +0100 Subject: [PATCH 012/125] Fixed issue with case sensitivity --- api/templates/helm/{values.yaml.twig => Values.yaml.twig} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename api/templates/helm/{values.yaml.twig => Values.yaml.twig} (100%) diff --git a/api/templates/helm/values.yaml.twig b/api/templates/helm/Values.yaml.twig similarity index 100% rename from api/templates/helm/values.yaml.twig rename to api/templates/helm/Values.yaml.twig From 221e83abea455040d4337103bb953bb4a06677ff Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 26 Nov 2019 11:07:56 +0100 Subject: [PATCH 013/125] Added automatic oas for @example and @assert annotations --- DESIGN.md | 4 +- api/src/Entity/ExampleEntity.php | 19 +--- api/src/Swagger/SwaggerDecorator.php | 143 ++++++++++++++++++++++----- 3 files changed, 125 insertions(+), 41 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 1f5104e0..34ff5696 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -2,7 +2,7 @@ Welcome, you are currently viewing the design decisions for the proto component. The proto component aims to provide a framework for the quick development of production apis for the commonground project. -*index* +*Index* - [The European factor](#the-european-factor) - [On standards and standardisation](#on-standards-and-standardization) - [NL API Strategie](#nl-api-strategie) @@ -31,7 +31,7 @@ Welcome, you are currently viewing the design decisions for the proto component. - [Api Versioning](#api-versioning) - [Environments and namespacing](#environments-and-namespacing) - [Domain Build-up and routing](#domain-build-up-and-routing) -- Container Setup](#container-setup) +- [Container Setup](#container-setup) The European factor diff --git a/api/src/Entity/ExampleEntity.php b/api/src/Entity/ExampleEntity.php index 8eee3dac..94f81e03 100644 --- a/api/src/Entity/ExampleEntity.php +++ b/api/src/Entity/ExampleEntity.php @@ -42,19 +42,8 @@ class ExampleEntity { /** * @var \Ramsey\Uuid\UuidInterface - * - * @ApiProperty( - * identifier=true, - * attributes={ - * "swagger_context"={ - * "description" = "The UUID identifier of this object", - * "type"="string", - * "format"="uuid", - * "example"="e2984465-190a-4562-829e-a8cca81aa35d" - * } - * } - * ) - * + * @example e2984465-190a-4562-829e-a8cca81aa35d + * * @Assert\Uuid * @Groups({"read"}) * @ORM\Id @@ -93,10 +82,10 @@ class ExampleEntity /** * @var string $camelCase Proof that we camel case our api - * @example Best api ever + * @example Best api ever * * @Assert\Length( - * max = 2555 + * max = 255 * ) * @Gedmo\Versioned * @Groups({"read","write"}) diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index d7f0d214..597d7fae 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -4,11 +4,12 @@ namespace App\Swagger; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Cache\Adapter\AdapterInterface as CacheInterface; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Common\Annotations\Reader as AnnotationReader; -use ApiPlatform\Core\PathResolver\OperationPathResolverInterface; + final class SwaggerDecorator implements NormalizerInterface { @@ -19,13 +20,15 @@ final class SwaggerDecorator implements NormalizerInterface private $cash; private $em; private $annotationReader; + private $camelCaseToSnakeCaseNameConverter; public function __construct( NormalizerInterface $decorated, ParameterBagInterface $params, CacheInterface $cache, EntityManagerInterface $em, - AnnotationReader $annotationReader + AnnotationReader $annotationReader, + CamelCaseToSnakeCaseNameConverter $camelCaseToSnakeCaseNameConverter ) { $this->decorated = $decorated; @@ -33,6 +36,7 @@ public function __construct( $this->cash = $cache; $this->em = $em; $this->annotationReader = $annotationReader; + $this->camelCaseToSnakeCaseNameConverter= $camelCaseToSnakeCaseNameConverter; } public function normalize($object, $format = null, array $context = []) @@ -41,13 +45,35 @@ public function normalize($object, $format = null, array $context = []) /* The we need to enrich al the entities and add the autoated routes */ + //var_dump($docs); // Lets make sure that we have tags if(!array_key_exists ('tags',$docs)){$docs['tags']=[];} + // Lets make sure that we have security and JWT-Claims + if(!array_key_exists ('securityDefinitions',$docs)){$docs['securityDefinitions']=[];} + + // Lets add JWT-Oauth + $docs['securityDefinitions']['JWT-Oauth'] = [ + "type"=>"oauth2", + "authorizationUrl"=>"http://petstore.swagger.io/api/oauth/dialog", + "flow"=>"implicit", + "scopes"=>[] #scopes will be filled later autmaticly + ]; + + $docs['securityDefinitions']['JWT-Token'] = [ + "type"=>"apiKey", + "in"=> "header", # can be "header", "query" or "cookie" + "name"=> "Authorization", # name of the header, query parameter or cookie + "scopes"=>[] #scopes will be filled later autmaticly + ]; + + // Lets get al the entities known to doctrine $entities = $this->em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames(); + $additionalDocs = []; + // Then we loop trough the entities to find the api platform entities foreach($entities as $entity){ //$reflector = new \ReflectionClass($entity); @@ -74,19 +100,33 @@ public function normalize($object, $format = null, array $context = []) $tag['name'] = $shortName; $tag['description'] = $description; - $docs['tags'][] = $tag; + $docs['tags'][] = $tag; // And lets add the aditional docs - $this->getAdditionalEntityDocs($entity); + + //$additionalEntityDocs = $this->getAdditionalEntityDocs($entity); + $entityDocs = $this->getAdditionalEntityDocs($entity); + $additionalDocs= array_merge($additionalDocs,$entityDocs['properties']); + + // Security + $docs['securityDefinitions']['JWT-Oauth']['scopes']= array_merge($docs['securityDefinitions']['JWT-Oauth']['scopes'],$entityDocs['security']); + $docs['securityDefinitions']['JWT-Token']['scopes']= array_merge($docs['securityDefinitions']['JWT-Token']['scopes'],$entityDocs['security']); + break; } } } - - - - // This gets a resourceclass bassed on the route name, could - //$resourceMetadata = $resourceClass ? $this->metadataFactory->create($resourceClass) : null; + + // Oke dit is echt but lelijk + $schemas = (array) $docs['definitions']; + foreach($schemas as $schemaName => $schema){ + $additionalDocs[$schemaName] = array_merge( (array) $schema, $additionalDocs[$schemaName]); + $properties = (array) $schema['properties']; + foreach($properties as $propertyName => $property){ + $additionalDocs[$schemaName]['properties'][$propertyName] = array_merge( (array) $property, $additionalDocs[$schemaName]['properties'][$propertyName] ); + } + } + $docs['definitions'] = $additionalDocs; // Lest add an host if($this->params->get('common_ground.oas.host')){ @@ -342,37 +382,92 @@ private function getAdditionalEntityDocs($entity){ $reflector = $metadata->getReflectionClass(); $properties = $metadata->getReflectionProperties(); $annotations = $this->annotationReader->getClassAnnotations($reflector); + $additionalDocs = ['properties','security'=>[]]; + $required = []; // Add audittrail // Add healthcheck - //var_dump($propertyAnnotation); + $class = $reflector->getShortName(); + $path = '/'.$this->camelCaseToSnakeCaseNameConverter->normalize($class); + // Lets take a look at the properties an annotions, - foreach($properties as $property){ + foreach($properties as $property){ - // The annotations for this propertu - $propertyAnnotations = $this->annotationReader->getPropertyAnnotations($property); + // The dockBlocks for thie property + $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); + $docblock = $factory->create($property->getDocComment()); + $tags = $docblock->getTags(); + $atributes = []; - // Check the annotations for symfony vallidations - foreach($propertyAnnotations as $propertyAnnotation){ + foreach($tags as $tag){ + $name = $tag->getName(); + $description = $tag->getDescription(); + // + //$description = (string) $description; - // Lentgh - if(get_class($propertyAnnotation) == "Symfony\Component\Validator\Constraints\NotNull"){ + switch ($name) { + // Docblocks + case "example": + $atributes['example'] = (string) $description; + break; - } - - // Lentgh - if(get_class($propertyAnnotation) == "Symfony\Component\Validator\Constraints\Length"){ - - } + // Groups + case "Groups": + $propertyAnnotation = $this->annotationReader->getPropertyAnnotation($property, "Symfony\Component\Serializer\Annotation\Groups"); + $groups = $propertyAnnotation->getGroups(); + break; + + // Constrainds (Validation) + case "Assert\Uuid": + $atributes['format'] = 'uuid'; + break; + case "Assert\Email": + $atributes['format'] = 'email'; + break; + case "Assert\Url": + $atributes['format'] = 'url'; + break; + case "Assert\Regex": + $atributes['format'] = 'regex'; + break; + case "Assert\Ip": + $atributes['format'] = 'ip'; + break; + case "Assert\Json": + $atributes['format'] = 'json'; + break; + case "Assert\Choice": + //@todo + //$atributes['format'] = 'json'; + break; + + case "Assert\NotNull": + $required[] = $property->name; + break; + case "Assert\Length": + $propertyAnnotation = $this->annotationReader->getPropertyAnnotation($property, "Symfony\Component\Validator\Constraints\Length"); + if($propertyAnnotation->max){$atributes['maxLength'] = $propertyAnnotation->max;} + if($propertyAnnotation->min){$atributes['minLength'] = $propertyAnnotation->min;} + break; + } + } + // Lets write everything to the docs + foreach($groups as $group){ + //$additionalDocs["components"]['schemas'][$class."-".$group] = $atributes; + $additionalDocs['properties'][$class."-".$group]["properties"][$property->name]= $atributes; + $additionalDocs['properties'][$class."-".$group]["required"] = $required; + + + if(!array_key_exists ($class.".".$group,$additionalDocs['security'])){$additionalDocs['security'][$class.".".$group] = $group.' right to the '.$class.' resource'; } + } } - $additionalDocs = []; return $additionalDocs; } From 4304a6ec467da29b4f0907cdaf2c629ba35e2438 Mon Sep 17 00:00:00 2001 From: rjzondervan Date: Tue, 26 Nov 2019 11:30:30 +0100 Subject: [PATCH 014/125] creating a GitHub action to build, run and push components --- .github/workflows/dockerimage.yml | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/dockerimage.yml diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml new file mode 100644 index 00000000..e299708b --- /dev/null +++ b/.github/workflows/dockerimage.yml @@ -0,0 +1,53 @@ +name: Docker Image CI + +on: + pull_request: + branches: + - master + - staging + - development + push: + branches: + - master + - staging + - development + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Pulling old images, if any + run: docker-compose pull --ignore-pull-failures + - name: Setting APP_ENV + env: + APP_ENV: dev + run: echo "set APP_ENV to $APP_ENV" + - if: contains( github.ref, 'master' ) || contains( github.base_ref, 'master' ) + env: + APP_ENV: prod + run: echo "set APP_ENV to $APP_ENV" + - if: contains( github.ref, 'staging' ) || contains( github.base_ref, 'staging' ) + env: + APP_ENV: stag + run: echo "set APP_ENV to $APP_ENV" + - name: Build the Docker image + run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV + - name: Run the docker image + run: docker-compose up -d + - name: Taking some sleep + run: sleep 100 + - name: Check if all containers are running + run: docker ps + #docker-compose logs + - name: Security Checks + run: docker-compose exec -T php composer req sensiolabs/security-checker + - name: Chores + run: docker-compose down + - name: Login to DockerHub Registry + run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin + - name: Push to docker hub + run: docker-compose push From c9cf334a03123fd9ca273403a56eb89c289349e7 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Tue, 26 Nov 2019 13:20:55 +0100 Subject: [PATCH 015/125] adding logs for debugging --- .github/workflows/dockerimage.yml | 3 +- .idea/workspace.xml | 100 ++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 .idea/workspace.xml diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index e299708b..2d11e911 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -42,7 +42,8 @@ jobs: run: sleep 100 - name: Check if all containers are running run: docker ps - #docker-compose logs + - name: Dumping the logs + run: docker-compose logs - name: Security Checks run: docker-compose exec -T php composer req sensiolabs/security-checker - name: Chores diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..8e8ff17f --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,100 @@ + + + + + + + $PROJECT_DIR$/api/composer.json + + + + + + + + + + + + + + + + + + + + + + + + 1573726460744 + + + 1573726496674 + + + 1573733386819 + + + 1573735733551 + + + + + + + + + + + + + \ No newline at end of file From 0660750d569ccd2ad485d212fc01b0719a53905c Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 26 Nov 2019 14:05:36 +0100 Subject: [PATCH 016/125] fix on missing array index --- api/src/Swagger/SwaggerDecorator.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index 597d7fae..3f84954e 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -47,6 +47,9 @@ public function normalize($object, $format = null, array $context = []) //var_dump($docs); + // Lets make sure that we have definitions + if(!array_key_exists ('definitions',$docs)){$docs['definitions']=[];} + // Lets make sure that we have tags if(!array_key_exists ('tags',$docs)){$docs['tags']=[];} @@ -461,7 +464,7 @@ private function getAdditionalEntityDocs($entity){ $additionalDocs['properties'][$class."-".$group]["required"] = $required; - if(!array_key_exists ($class.".".$group,$additionalDocs['security'])){$additionalDocs['security'][$class.".".$group] = $group.' right to the '.$class.' resource'; } + if(!array_key_exists ($group,$additionalDocs['security'])){$additionalDocs['security'][$group] = $group.' right to the '.$class.' resource'; } } } From 8f177cd4c4c63718997b5a1ece19320317d33ae8 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 26 Nov 2019 15:31:46 +0100 Subject: [PATCH 017/125] Fixes on delete error in postman --- api/src/Subscriber/LogSubscriber.php | 84 ------------------------ api/src/Subscriber/ValidOnSubscriber.php | 13 ++-- 2 files changed, 7 insertions(+), 90 deletions(-) delete mode 100644 api/src/Subscriber/LogSubscriber.php diff --git a/api/src/Subscriber/LogSubscriber.php b/api/src/Subscriber/LogSubscriber.php deleted file mode 100644 index c58d7d1c..00000000 --- a/api/src/Subscriber/LogSubscriber.php +++ /dev/null @@ -1,84 +0,0 @@ -params = $params; - $this->em= $em; - $this->serializer= $serializer; - $this->annotationReader = $annotationReader; - } - - public static function getSubscribedEvents() - { - return [ - KernelEvents::VIEW => ['Log', EventPriorities::PRE_SERIALIZE], - ]; - - } - - public function Log(GetResponseForControllerResultEvent $event) - { - $result = $event->getControllerResult(); - $showLogs= $event->getRequest()->query->get('showLogs'); - - // Lets see if this class has a Loggableannotation - $loggable = false; - $reflClass = new \ReflectionClass($result); - $annotations = $this->annotationReader->getClassAnnotations($reflClass); - - foreach($annotations as $annotation ){ - if(get_class($annotation) == "Gedmo\Mapping\Annotation\Loggable"){ - $loggable = true; - } - } - - // Only do somthing if we are on te log route and the entity is logable - /* @todo we should trhow errors here foruser feedback */ - if (!$showLogs || !$loggable) { - return $result; - } - - $repo = $this->em->getRepository('Gedmo\Loggable\Entity\LogEntry'); // we use default log entry class - $logs = $repo->getLogEntries($result); - - // now we need to overide the normal subscriber - $json = $this->serializer->serialize( - $logs, - 'jsonhal',['enable_max_depth' => true] - ); - - $response = new Response( - $json, - Response::HTTP_OK, - ['content-type' => 'application/json+hal'] - ); - - $event->setResponse($response); - - return; - } -} diff --git a/api/src/Subscriber/ValidOnSubscriber.php b/api/src/Subscriber/ValidOnSubscriber.php index 220b5288..616d66ef 100644 --- a/api/src/Subscriber/ValidOnSubscriber.php +++ b/api/src/Subscriber/ValidOnSubscriber.php @@ -48,6 +48,13 @@ public function validOn(GetResponseForControllerResultEvent $event) $geldigOp = $event->getRequest()->query->get('geldigOp', false); $validOn = $event->getRequest()->query->get('validOn', $geldigOp); + + // Only do somthing if fields is query supplied + if (!$validOn) { + return $result; + } + + // Lets see if this class has a Loggableannotation $loggable = false; $reflClass = new \ReflectionClass($result); @@ -58,12 +65,6 @@ public function validOn(GetResponseForControllerResultEvent $event) $loggable = true; } } - - // Only do somthing if fields is query supplied - if (!$validOn) { - return $result; - } - /* @todo propper error handling */ if(!$loggable){ throw new \Exception('This enity is not loggable therefore no previus versions can be obtained'); From ed11b2e6097b857dd79518a38bd145d80cf88197 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Tue, 26 Nov 2019 15:58:08 +0100 Subject: [PATCH 018/125] First attempt to deploy to kubernetes --- .github/workflows/dockerimage.yml | 4 + .idea/workspace.xml | 141 ++++++++++++++++++++++++++++-- 2 files changed, 140 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 2d11e911..698ec235 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -52,3 +52,7 @@ jobs: run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin - name: Push to docker hub run: docker-compose push + - name: Deploy through helm + env: + KUBECONFIG: ${{ secrets.KUBECONFIG }} + run: helm install --name pc-dev ./api/helm --kubeconfig=$KUBECONFIG --namespace=dev --set settings.env=dev,settings.debug=1 diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 8e8ff17f..63cda310 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,14 +1,17 @@ - + + + + - + $PROJECT_DIR$/api/composer.json @@ -24,6 +27,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -52,6 +172,7 @@ @@ -85,7 +213,9 @@ - + + @@ -95,6 +225,7 @@ - \ No newline at end of file From c676dc58cb92ccbc2b087979238476e2dc424d96 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Tue, 26 Nov 2019 16:17:29 +0100 Subject: [PATCH 019/125] No deployment from pull requests --- .github/workflows/dockerimage.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 698ec235..4ae9ced0 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -53,6 +53,7 @@ jobs: - name: Push to docker hub run: docker-compose push - name: Deploy through helm + if: contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' ) env: KUBECONFIG: ${{ secrets.KUBECONFIG }} run: helm install --name pc-dev ./api/helm --kubeconfig=$KUBECONFIG --namespace=dev --set settings.env=dev,settings.debug=1 From 347c8d9d3eb3fa9d8a2bb1005d501e728984800e Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 06:37:17 +0100 Subject: [PATCH 020/125] Setup helm deploy with enviroment --- .github/workflows/dockerimage.yml | 2 +- api/src/Swagger/SwaggerDecorator.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 4ae9ced0..5f3d8a18 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -56,4 +56,4 @@ jobs: if: contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' ) env: KUBECONFIG: ${{ secrets.KUBECONFIG }} - run: helm install --name pc-dev ./api/helm --kubeconfig=$KUBECONFIG --namespace=dev --set settings.env=dev,settings.debug=1 + run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig=$KUBECONFIG --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index 3f84954e..8a6edbd6 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -122,8 +122,10 @@ public function normalize($object, $format = null, array $context = []) // Oke dit is echt but lelijk $schemas = (array) $docs['definitions']; - foreach($schemas as $schemaName => $schema){ + foreach($schemas as $schemaName => $schema){ + $additionalDocs[$schemaName] = array_merge( (array) $schema, $additionalDocs[$schemaName]); + $properties = (array) $schema['properties']; foreach($properties as $propertyName => $property){ $additionalDocs[$schemaName]['properties'][$propertyName] = array_merge( (array) $property, $additionalDocs[$schemaName]['properties'][$propertyName] ); From a5171fb7c5cb77f459d00c1437906976e0d7bc41 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 06:53:23 +0100 Subject: [PATCH 021/125] Setting up deploy file --- .github/deploy.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/deploy.yml diff --git a/.github/deploy.yml b/.github/deploy.yml new file mode 100644 index 00000000..3bd4c3c9 --- /dev/null +++ b/.github/deploy.yml @@ -0,0 +1,4 @@ +# View examples and documentation at https://deliverybot.dev/docs/ +production: + environment: production + production_environment: true From 17c5f5dad9051150821a5aa81b4fb2cfdfebd91c Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 07:19:25 +0100 Subject: [PATCH 022/125] tried to fix it --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 5f3d8a18..45b88c29 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -56,4 +56,4 @@ jobs: if: contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' ) env: KUBECONFIG: ${{ secrets.KUBECONFIG }} - run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig=$KUBECONFIG --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 + run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig="$KUBECONFIG" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 From d1bf3136973f7aadf07b20190d6ed43f9ded7c2e Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 08:39:22 +0100 Subject: [PATCH 023/125] Create kubeconfig file --- .github/workflows/dockerimage.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 45b88c29..6144200f 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -20,6 +20,16 @@ jobs: steps: - uses: actions/checkout@v1 + - name: Create kube config + uses: finnp/create-file-action@master + env: + FILE_NAME: "kubeconfig.yaml" + FILE_DATA: ${{ secrets.KUBECONFIG }} + - name: Deploy through helm + if: contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' ) + env: + KUBECONFIG: ${{ secrets.KUBECONFIG }} + run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - name: Pulling old images, if any run: docker-compose pull --ignore-pull-failures - name: Setting APP_ENV @@ -52,8 +62,3 @@ jobs: run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin - name: Push to docker hub run: docker-compose push - - name: Deploy through helm - if: contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' ) - env: - KUBECONFIG: ${{ secrets.KUBECONFIG }} - run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig="$KUBECONFIG" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 From 36ffcaab5e4a9d02248781f6f0d990aea9e8edb7 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 08:39:22 +0100 Subject: [PATCH 024/125] Create kubeconfig file --- .github/workflows/dockerimage.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 45b88c29..6144200f 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -20,6 +20,16 @@ jobs: steps: - uses: actions/checkout@v1 + - name: Create kube config + uses: finnp/create-file-action@master + env: + FILE_NAME: "kubeconfig.yaml" + FILE_DATA: ${{ secrets.KUBECONFIG }} + - name: Deploy through helm + if: contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' ) + env: + KUBECONFIG: ${{ secrets.KUBECONFIG }} + run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - name: Pulling old images, if any run: docker-compose pull --ignore-pull-failures - name: Setting APP_ENV @@ -52,8 +62,3 @@ jobs: run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin - name: Push to docker hub run: docker-compose push - - name: Deploy through helm - if: contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' ) - env: - KUBECONFIG: ${{ secrets.KUBECONFIG }} - run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig="$KUBECONFIG" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 From 0d9568b732cf763d97ebfb5daed2c3e77d4e30dc Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 27 Nov 2019 09:18:16 +0100 Subject: [PATCH 025/125] Some experimenting with APP_ENV --- .github/workflows/dockerimage.yml | 3 +- .idea/workspace.xml | 132 +----------------------------- 2 files changed, 5 insertions(+), 130 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 957efdb2..b74d6067 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -33,7 +33,8 @@ jobs: - if: contains( github.ref, 'staging' ) || contains( github.base_ref, 'staging' ) env: APP_ENV: stag - run: echo "set APP_ENV to $APP_ENV" + run: echo "set APP_ENV to $APP_ENV" + - run: echo "APP_ENV is now $APP_ENV" - name: Build the Docker image run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV - name: Run the docker image diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 63cda310..bf2a5276 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -11,7 +11,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -172,7 +55,6 @@ @@ -225,7 +100,6 @@ - - \ No newline at end of file From d37b48475009ea6aa490b714a70a1311ef3b4a3a Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 27 Nov 2019 09:18:16 +0100 Subject: [PATCH 026/125] Revert "Some experimenting with APP_ENV" This reverts commit 0d9568b732cf763d97ebfb5daed2c3e77d4e30dc. --- .github/workflows/dockerimage.yml | 3 +- .idea/workspace.xml | 132 +++++++++++++++++++++++++++++- 2 files changed, 130 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index b74d6067..957efdb2 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -33,8 +33,7 @@ jobs: - if: contains( github.ref, 'staging' ) || contains( github.base_ref, 'staging' ) env: APP_ENV: stag - run: echo "set APP_ENV to $APP_ENV" - - run: echo "APP_ENV is now $APP_ENV" + run: echo "set APP_ENV to $APP_ENV" - name: Build the Docker image run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV - name: Run the docker image diff --git a/.idea/workspace.xml b/.idea/workspace.xml index bf2a5276..63cda310 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -11,7 +11,7 @@ - + $PROJECT_DIR$/api/composer.json @@ -27,6 +27,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -55,6 +172,7 @@ @@ -100,6 +225,7 @@ - \ No newline at end of file From 63f5d80bf5cd9222ec766f2aae54b581e8a57f21 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 27 Nov 2019 09:19:17 +0100 Subject: [PATCH 027/125] Adding a debugging step --- .github/workflows/dockerimage.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 957efdb2..343bdeca 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -34,6 +34,7 @@ jobs: env: APP_ENV: stag run: echo "set APP_ENV to $APP_ENV" + - run: echo "APP_ENV is now $APP_ENV" - name: Build the Docker image run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV - name: Run the docker image From ec0c8cb9f6c618555a416ec1cf6718d5622d5980 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 27 Nov 2019 09:26:20 +0100 Subject: [PATCH 028/125] Fear was confirmed, attempt to solve. --- .github/workflows/dockerimage.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 343bdeca..88ba3799 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -17,7 +17,8 @@ jobs: build: runs-on: ubuntu-latest - + env: + APP_ENV: dev steps: - uses: actions/checkout@v1 - name: Pulling old images, if any From 64a207e92abe045960af9abf9315b44056260a96 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 27 Nov 2019 09:28:44 +0100 Subject: [PATCH 029/125] Some testing with my solution --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 88ba3799..88b98f39 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest env: - APP_ENV: dev + APP_ENV: test steps: - uses: actions/checkout@v1 - name: Pulling old images, if any From dff45cf090f4c1f622d0de286ee6393a0970d49b Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 27 Nov 2019 09:38:09 +0100 Subject: [PATCH 030/125] Trying suggested solution --- .github/workflows/dockerimage.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 88b98f39..f6d8fc66 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -24,9 +24,9 @@ jobs: - name: Pulling old images, if any run: docker-compose pull --ignore-pull-failures - name: Setting APP_ENV - env: - APP_ENV: dev - run: echo "set APP_ENV to $APP_ENV" + run: | + echo ::set-env name=APP_ENV::dev + echo "set APP_ENV to $APP_ENV" - if: contains( github.ref, 'master' ) || contains( github.base_ref, 'master' ) env: APP_ENV: prod From fd2a6bcd6e531d2a293c02a18bfbf1c16adc68d1 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 27 Nov 2019 09:50:50 +0100 Subject: [PATCH 031/125] New attempt --- .github/workflows/dockerimage.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index f6d8fc66..adbef710 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -17,8 +17,6 @@ jobs: build: runs-on: ubuntu-latest - env: - APP_ENV: test steps: - uses: actions/checkout@v1 - name: Pulling old images, if any From ab87947a489c58f5ac80e2e81865ec0c3a5b1948 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 27 Nov 2019 09:53:49 +0100 Subject: [PATCH 032/125] Applying confirmed solution throughout. --- .github/workflows/dockerimage.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index adbef710..182d9ea9 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -26,13 +26,13 @@ jobs: echo ::set-env name=APP_ENV::dev echo "set APP_ENV to $APP_ENV" - if: contains( github.ref, 'master' ) || contains( github.base_ref, 'master' ) - env: - APP_ENV: prod - run: echo "set APP_ENV to $APP_ENV" + run: | + echo ::set-env name=APP_ENV::prod + echo "set APP_ENV to $APP_ENV" - if: contains( github.ref, 'staging' ) || contains( github.base_ref, 'staging' ) - env: - APP_ENV: stag - run: echo "set APP_ENV to $APP_ENV" + run: | + echo ::set-env name=APP_ENV::stag + echo "set APP_ENV to $APP_ENV" - run: echo "APP_ENV is now $APP_ENV" - name: Build the Docker image run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV From ca5a30bb0c41056f232c25a2bec57a6854293740 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 27 Nov 2019 12:05:20 +0100 Subject: [PATCH 033/125] Making the process a little bit more neat, skipping deployment steps when secrets not set --- .github/workflows/dockerimage.yml | 34 +++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 182d9ea9..e73dbdf9 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -21,19 +21,22 @@ jobs: - uses: actions/checkout@v1 - name: Pulling old images, if any run: docker-compose pull --ignore-pull-failures - - name: Setting APP_ENV + - name: Setting APP_ENV to dev run: | echo ::set-env name=APP_ENV::dev echo "set APP_ENV to $APP_ENV" - - if: contains( github.ref, 'master' ) || contains( github.base_ref, 'master' ) + - name: Setting APP_ENV to prod + if: contains( github.ref, 'master' ) || contains( github.base_ref, 'master' ) run: | echo ::set-env name=APP_ENV::prod echo "set APP_ENV to $APP_ENV" - - if: contains( github.ref, 'staging' ) || contains( github.base_ref, 'staging' ) + - name: Setting APP_ENV to stag + if: contains( github.ref, 'staging' ) || contains( github.base_ref, 'staging' ) run: | echo ::set-env name=APP_ENV::stag echo "set APP_ENV to $APP_ENV" - - run: echo "APP_ENV is now $APP_ENV" + - name: Print definitive APP_ENV + run: echo "APP_ENV is now $APP_ENV" - name: Build the Docker image run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV - name: Run the docker image @@ -49,12 +52,27 @@ jobs: - name: Chores run: docker-compose down - name: Login to DockerHub Registry - run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin - - name: Push to docker hub + id: dockerhub-login + run: | + if [ "${{ secrets.DOCKERHUB_PASSWORD }}" != "" ] && [ "${{ secrets.DOCKERHUB_USERNAME }}" != "" ]; then + echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin + echo "##[set-output name=success;]true" + else + echo "##[set-output name=success;]false" + fi + - if: steps.dockerhub-login.outputs.success == 'true' + name: Push to docker hub run: docker-compose push - name: Create kube config + id: kubeconfig if: contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' ) - run: printf "${{ secrets.KUBECONFIG }}" > kubeconfig.yaml + run: | + if [ "${{ secrets.KUBECONFIG }}" != "" ]; then + printf "${{ secrets.KUBECONFIG }}" > kubeconfig.yaml + echo "##[set-output name=success]true" + else + echo "##[set-output name=success]false" + fi - name: Deploy through helm - if: contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' ) + if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true From 2210828e0374527a2e2f4c72d12eef386745f812 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 12:11:41 +0000 Subject: [PATCH 034/125] Apply fixes from StyleCI --- api/config/bundles.php | 30 +- api/src/Command/ApiHelmCommand.php | 118 +-- api/src/Entity/ExampleEntity.php | 88 +- api/src/Entity/NLXRequestLog.php | 4 +- api/src/Filter/LikeFilter.php | 81 +- api/src/Filter/RegexpFilter.php | 81 +- .../Repository/NLXRequestLogRepository.php | 21 +- api/src/Service/NLXLogService.php | 18 +- api/src/Subscriber/FieldsSubscriber.php | 114 +-- api/src/Subscriber/NLXSubscriber.php | 199 ++-- api/src/Subscriber/ValidOnSubscriber.php | 178 ++-- api/src/Swagger/SwaggerDecorator.php | 942 +++++++++--------- api/src/Types/IncompleteDateType.php | 98 +- api/src/Types/UnderInvestigationType.php | 121 +-- api/src/ValueObject/IncompleteDate.php | 118 ++- api/src/ValueObject/UnderInvestigation.php | 55 +- 16 files changed, 1126 insertions(+), 1140 deletions(-) diff --git a/api/config/bundles.php b/api/config/bundles.php index 426c3ab7..fa4a09fd 100644 --- a/api/config/bundles.php +++ b/api/config/bundles.php @@ -1,19 +1,19 @@ ['all' => true], - Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], - Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true], - Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], - Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], - Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], - ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], - Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], - Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], - Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], - Conduction\CommonGroundBundle\CommonGroundBundle::class => ['all' => true], - Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], - Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], - Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['all' => true], - Tbbc\MoneyBundle\TbbcMoneyBundle::class => ['all' => true], + Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], + Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], + Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true], + Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], + Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], + Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], + Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], + Conduction\CommonGroundBundle\CommonGroundBundle::class => ['all' => true], + Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], + Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], + Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['all' => true], + Tbbc\MoneyBundle\TbbcMoneyBundle::class => ['all' => true], ]; diff --git a/api/src/Command/ApiHelmCommand.php b/api/src/Command/ApiHelmCommand.php index 6bac5366..0caa16f6 100644 --- a/api/src/Command/ApiHelmCommand.php +++ b/api/src/Command/ApiHelmCommand.php @@ -1,5 +1,7 @@ twig= $twig; - - parent::__construct(); - } - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('app:helm:update') - // the short description shown while running "php bin/console list" - ->setDescription('Creates a new helm chart.') - - // the full command description shown when running the command with - // the "--help" option - ->setHelp('This command allows you to create a new hel chart from the helm template') - ->setAliases(['app:helm:export']) - ->setDescription('Dump the OpenAPI documentation') - ->addOption('location', null, InputOption::VALUE_OPTIONAL, 'Write output to files in the given location','/srv/api/helm') - ->addOption('spec-version', null, InputOption::VALUE_OPTIONAL, 'Helm version to use ("0.1.0")', '0.1.0') - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new SymfonyStyle($input, $output); - /** @var string $version */ - $version = $input->getOption('spec-version'); - - //if (!\in_array($version, ['0.1.0'], true)) { - // throw new InvalidOptionException(sprintf('This tool only supports version 2 and 3 of the OpenAPI specification ("%s" given).', $version)); - //} - - $values = $this->twig->render('helm/Values.yaml.twig'); - $chart = $this->twig->render('helm/Chart.yaml.twig'); - - - if (!empty($location= $input->getOption('location')) && \is_string($location)) { - file_put_contents($location.'/values.yaml', $values); - file_put_contents($location.'/Chart.yaml', $chart); - $io->success(sprintf('Data written to %s (specification version %s).', $location, $version)); - } else { - // outputs multiple lines to the console (adding "\n" at the end of each line) - $output->writeln([ - 'Helm Chart Creator', - '============', - $chart, - ]); - } - } + private $twig; + + public function __construct(Environment $twig) + { + $this->twig = $twig; + + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('app:helm:update') + // the short description shown while running "php bin/console list" + ->setDescription('Creates a new helm chart.') + + // the full command description shown when running the command with + // the "--help" option + ->setHelp('This command allows you to create a new hel chart from the helm template') + ->setAliases(['app:helm:export']) + ->setDescription('Dump the OpenAPI documentation') + ->addOption('location', null, InputOption::VALUE_OPTIONAL, 'Write output to files in the given location', '/srv/api/helm') + ->addOption('spec-version', null, InputOption::VALUE_OPTIONAL, 'Helm version to use ("0.1.0")', '0.1.0'); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new SymfonyStyle($input, $output); + /** @var string $version */ + $version = $input->getOption('spec-version'); + + //if (!\in_array($version, ['0.1.0'], true)) { + // throw new InvalidOptionException(sprintf('This tool only supports version 2 and 3 of the OpenAPI specification ("%s" given).', $version)); + //} + + $values = $this->twig->render('helm/Values.yaml.twig'); + $chart = $this->twig->render('helm/Chart.yaml.twig'); + + if (!empty($location = $input->getOption('location')) && \is_string($location)) { + file_put_contents($location.'/values.yaml', $values); + file_put_contents($location.'/Chart.yaml', $chart); + $io->success(sprintf('Data written to %s (specification version %s).', $location, $version)); + } else { + // outputs multiple lines to the console (adding "\n" at the end of each line) + $output->writeln([ + 'Helm Chart Creator', + '============', + $chart, + ]); + } + } } diff --git a/api/src/Entity/ExampleEntity.php b/api/src/Entity/ExampleEntity.php index 94f81e03..47705b5c 100644 --- a/api/src/Entity/ExampleEntity.php +++ b/api/src/Entity/ExampleEntity.php @@ -5,23 +5,18 @@ namespace App\Entity; use ApiPlatform\Core\Annotation\ApiFilter; -use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter; use ApiPlatform\Core\Annotation\ApiResource; -use ApiPlatform\Core\Annotation\ApiProperty; +use App\Filter\LikeFilter; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; -use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Serializer\Annotation\Groups; -use Symfony\Component\Serializer\Annotation\MaxDepth; - - -use App\Filter\LikeFilter; +use Symfony\Component\Validator\Constraints as Assert; /** - * This is an example entity - * + * This is an example entity. + * * With an adtional description, all in all its pritty nice [url](www.google.nl) - * + * * @ApiResource( * normalizationContext={"groups"={"read"}, "enable_max_depth"=true}, * denormalizationContext={"groups"={"write"}, "enable_max_depth"=true}, @@ -40,55 +35,59 @@ */ class ExampleEntity { - /** - * @var \Ramsey\Uuid\UuidInterface - * @example e2984465-190a-4562-829e-a8cca81aa35d - * - * @Assert\Uuid - * @Groups({"read"}) - * @ORM\Id - * @ORM\Column(type="uuid", unique=true) - * @ORM\GeneratedValue(strategy="CUSTOM") - * @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator") - */ - private $id; + /** + * @var \Ramsey\Uuid\UuidInterface + * + * @example e2984465-190a-4562-829e-a8cca81aa35d + * + * @Assert\Uuid + * @Groups({"read"}) + * @ORM\Id + * @ORM\Column(type="uuid", unique=true) + * @ORM\GeneratedValue(strategy="CUSTOM") + * @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator") + */ + private $id; /** - * @var string $name The name of this example property - * @example My Group - * - * @Assert\NotNull - * @Assert\Length( - * max = 255 - * ) + * @var string The name of this example property + * + * @example My Group + * + * @Assert\NotNull + * @Assert\Length( + * max = 255 + * ) * @Gedmo\Versioned - * @Groups({"read","write"}) + * @Groups({"read","write"}) * @ORM\Column(type="string", length=255) */ private $name; /** - * @var string $description The description of this example property - * @example Is the best group ever - * - * @Assert\Length( - * max = 2555 - * ) + * @var string The description of this example property + * + * @example Is the best group ever + * + * @Assert\Length( + * max = 2555 + * ) * @Gedmo\Versioned - * @Groups({"read","write"}) + * @Groups({"read","write"}) * @ORM\Column(type="text", nullable=true) */ private $description; /** - * @var string $camelCase Proof that we camel case our api - * @example Best api ever - * - * @Assert\Length( - * max = 255 - * ) + * @var string Proof that we camel case our api + * + * @example Best api ever + * + * @Assert\Length( + * max = 255 + * ) * @Gedmo\Versioned - * @Groups({"read","write"}) + * @Groups({"read","write"}) * @ORM\Column(type="string", length=255, nullable=true) */ private $camelCase; @@ -133,5 +132,4 @@ public function setCamelCase(?string $camelCase): self return $this; } - } diff --git a/api/src/Entity/NLXRequestLog.php b/api/src/Entity/NLXRequestLog.php index c3c3a1c4..1d886b85 100644 --- a/api/src/Entity/NLXRequestLog.php +++ b/api/src/Entity/NLXRequestLog.php @@ -235,12 +235,12 @@ public function setEndpoint(string $endpoint): self public function getMethod(): ?string { - return $this->method; + return $this->method; } public function setMethod(string $method): self { - $this->method = $method; + $this->method = $method; return $this; } diff --git a/api/src/Filter/LikeFilter.php b/api/src/Filter/LikeFilter.php index 1496dd18..029c73e9 100644 --- a/api/src/Filter/LikeFilter.php +++ b/api/src/Filter/LikeFilter.php @@ -1,4 +1,5 @@ isPropertyEnabled($property, $resourceClass) || - !$this->isPropertyMapped($property, $resourceClass) - ) { - return; - } - - $parameterName = $queryNameGenerator->generateParameterName($property); // Generate a unique parameter name to avoid collisions with other filters - $queryBuilder - ->andWhere(sprintf('o.%s LIKE :%s', $property, $parameterName)) - ->setParameter($parameterName, $value); - } - - // This function is only used to hook in documentation generators (supported by Swagger and Hydra) - public function getDescription(string $resourceClass): array - { - if (!$this->properties) { - return []; - } - - $description = []; - foreach ($this->properties as $property => $strategy) { - $description["like_$property"] = [ - 'property' => $property, - 'type' => 'string', - 'required' => false, - 'swagger' => [ - 'description' => 'This filter narows your result using the * and _ wildcards, where * is assumed to be one or more characters and _ is assumed to be a single character', - 'name' => $property, - 'type' => 'string', - ], - ]; - } - - return $description; - } -} \ No newline at end of file + protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null) + { + // otherwise filter is applied to order and page as well + if ( + !$this->isPropertyEnabled($property, $resourceClass) || + !$this->isPropertyMapped($property, $resourceClass) + ) { + return; + } + + $parameterName = $queryNameGenerator->generateParameterName($property); // Generate a unique parameter name to avoid collisions with other filters + $queryBuilder + ->andWhere(sprintf('o.%s LIKE :%s', $property, $parameterName)) + ->setParameter($parameterName, $value); + } + + // This function is only used to hook in documentation generators (supported by Swagger and Hydra) + public function getDescription(string $resourceClass): array + { + if (!$this->properties) { + return []; + } + + $description = []; + foreach ($this->properties as $property => $strategy) { + $description["like_$property"] = [ + 'property' => $property, + 'type' => 'string', + 'required' => false, + 'swagger' => [ + 'description' => 'This filter narows your result using the * and _ wildcards, where * is assumed to be one or more characters and _ is assumed to be a single character', + 'name' => $property, + 'type' => 'string', + ], + ]; + } + + return $description; + } +} diff --git a/api/src/Filter/RegexpFilter.php b/api/src/Filter/RegexpFilter.php index ffda6ff7..da1f747e 100644 --- a/api/src/Filter/RegexpFilter.php +++ b/api/src/Filter/RegexpFilter.php @@ -1,4 +1,5 @@ isPropertyEnabled($property, $resourceClass) || - !$this->isPropertyMapped($property, $resourceClass) - ) { - return; - } - - $parameterName = $queryNameGenerator->generateParameterName($property); // Generate a unique parameter name to avoid collisions with other filters - $queryBuilder - ->andWhere(sprintf('REGEXP(o.%s, :%s) = 1', $property, $parameterName)) - ->setParameter($parameterName, $value); - } - - // This function is only used to hook in documentation generators (supported by Swagger and Hydra) - public function getDescription(string $resourceClass): array - { - if (!$this->properties) { - return []; - } - - $description = []; - foreach ($this->properties as $property => $strategy) { - $description["regexp_$property"] = [ - 'property' => $property, - 'type' => 'string', - 'required' => false, - 'swagger' => [ - 'description' => 'Filter for an exact match using a [Regular expression](https://en.wikipedia.org/wiki/Regular_expression).', - 'name' => $property, - 'type' => 'string', - ], - ]; - } - - return $description; - } -} \ No newline at end of file + protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null) + { + // otherwise filter is applied to order and page as well + if ( + !$this->isPropertyEnabled($property, $resourceClass) || + !$this->isPropertyMapped($property, $resourceClass) + ) { + return; + } + + $parameterName = $queryNameGenerator->generateParameterName($property); // Generate a unique parameter name to avoid collisions with other filters + $queryBuilder + ->andWhere(sprintf('REGEXP(o.%s, :%s) = 1', $property, $parameterName)) + ->setParameter($parameterName, $value); + } + + // This function is only used to hook in documentation generators (supported by Swagger and Hydra) + public function getDescription(string $resourceClass): array + { + if (!$this->properties) { + return []; + } + + $description = []; + foreach ($this->properties as $property => $strategy) { + $description["regexp_$property"] = [ + 'property' => $property, + 'type' => 'string', + 'required' => false, + 'swagger' => [ + 'description' => 'Filter for an exact match using a [Regular expression](https://en.wikipedia.org/wiki/Regular_expression).', + 'name' => $property, + 'type' => 'string', + ], + ]; + } + + return $description; + } +} diff --git a/api/src/Repository/NLXRequestLogRepository.php b/api/src/Repository/NLXRequestLogRepository.php index ed8d0a95..bc1dad3c 100644 --- a/api/src/Repository/NLXRequestLogRepository.php +++ b/api/src/Repository/NLXRequestLogRepository.php @@ -20,19 +20,18 @@ public function __construct(RegistryInterface $registry) } /** - * @return NLXRequestLog[] Returns an array of NLXRequestLog objects - */ + * @return NLXRequestLog[] Returns an array of NLXRequestLog objects + */ public function getLogEntries($entity) { - return $this->createQueryBuilder('l') - ->where('l.objectClass = :objectClass') - ->setParameter('objectClass', $this->getEntityManager()->getMetadataFactory()->getMetadataFor(get_class($entity))->getName()) - ->andWhere('l.objectId = :objectId') - ->setParameter('objectId', $entity->getId()) - ->orderBy('l.loggedAt', 'DESC') - ->getQuery() - ->getResult(); - + return $this->createQueryBuilder('l') + ->where('l.objectClass = :objectClass') + ->setParameter('objectClass', $this->getEntityManager()->getMetadataFactory()->getMetadataFor(get_class($entity))->getName()) + ->andWhere('l.objectId = :objectId') + ->setParameter('objectId', $entity->getId()) + ->orderBy('l.loggedAt', 'DESC') + ->getQuery() + ->getResult(); } /* diff --git a/api/src/Service/NLXLogService.php b/api/src/Service/NLXLogService.php index 24c5cff1..3f2d2e3c 100644 --- a/api/src/Service/NLXLogService.php +++ b/api/src/Service/NLXLogService.php @@ -1,4 +1,5 @@ em = $em; - } - + private $em; + + public function __construct(EntityManagerInterface $em) + { + $this->em = $em; + } } diff --git a/api/src/Subscriber/FieldsSubscriber.php b/api/src/Subscriber/FieldsSubscriber.php index 1372fd99..f842a8e2 100644 --- a/api/src/Subscriber/FieldsSubscriber.php +++ b/api/src/Subscriber/FieldsSubscriber.php @@ -2,73 +2,67 @@ namespace App\Subscriber; -use ApiPlatform\Core\Exception\InvalidArgumentException; use ApiPlatform\Core\EventListener\EventPriorities; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Serializer\SerializerInterface; -use Doctrine\ORM\EntityManagerInterface; -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; - -use App\Service\RequestTypeService; class FieldsSubscriber implements EventSubscriberInterface { - private $params; - private $serializer; - - public function __construct(ParameterBagInterface $params, SerializerInterface $serializer) - { - $this->params = $params; - $this->serializer= $serializer; - } - - public static function getSubscribedEvents() - { - return [ - KernelEvents::VIEW => ['FilterFields', EventPriorities::PRE_SERIALIZE], - ]; - - } - - public function FilterFields(GetResponseForControllerResultEvent $event) - { - $result = $event->getControllerResult(); - $fields = $event->getRequest()->query->get('fields'); - - // Only do somthing if fields is query supplied - if (!$fields) { - return $result; - } - - // let turn fields into an array if it isn't one already - if(!is_array($fields)){ - $fields = explode(",", $fields); - } - - - // we always need to return an id and links (in order not to break stuff) - if(!in_array("id",$fields)){$fields[]='id';} - if(!in_array("_links",$fields)){$fields[]='_links';} - - // now we need to overide the normal subscriber - $json = $this->serializer->serialize( - $result, - 'jsonhal',['enable_max_depth' => true,'attributes'=> $fields] - ); - - $response = new Response( - $json, - Response::HTTP_OK, - ['content-type' => 'application/json+hal'] - ); - - $event->setResponse($response); - - return; - } + private $params; + private $serializer; + + public function __construct(ParameterBagInterface $params, SerializerInterface $serializer) + { + $this->params = $params; + $this->serializer = $serializer; + } + + public static function getSubscribedEvents() + { + return [ + KernelEvents::VIEW => ['FilterFields', EventPriorities::PRE_SERIALIZE], + ]; + } + + public function FilterFields(GetResponseForControllerResultEvent $event) + { + $result = $event->getControllerResult(); + $fields = $event->getRequest()->query->get('fields'); + + // Only do somthing if fields is query supplied + if (!$fields) { + return $result; + } + + // let turn fields into an array if it isn't one already + if (!is_array($fields)) { + $fields = explode(',', $fields); + } + + // we always need to return an id and links (in order not to break stuff) + if (!in_array('id', $fields)) { + $fields[] = 'id'; + } + if (!in_array('_links', $fields)) { + $fields[] = '_links'; + } + + // now we need to overide the normal subscriber + $json = $this->serializer->serialize( + $result, + 'jsonhal', ['enable_max_depth' => true, 'attributes'=> $fields] + ); + + $response = new Response( + $json, + Response::HTTP_OK, + ['content-type' => 'application/json+hal'] + ); + + $event->setResponse($response); + } } diff --git a/api/src/Subscriber/NLXSubscriber.php b/api/src/Subscriber/NLXSubscriber.php index d846884b..5411001e 100644 --- a/api/src/Subscriber/NLXSubscriber.php +++ b/api/src/Subscriber/NLXSubscriber.php @@ -2,118 +2,109 @@ namespace App\Subscriber; -use ApiPlatform\Core\Exception\InvalidArgumentException; use ApiPlatform\Core\EventListener\EventPriorities; +use App\Entity\NLXRequestLog; +use App\Service\NLXLogService; +use Doctrine\ORM\EntityManagerInterface; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Serializer\SerializerInterface; -use Doctrine\ORM\EntityManagerInterface; -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; -use Symfony\Component\HttpFoundation\Session\Session; - - -use App\Service\NLXLogService; -use App\Entity\NLXRequestLog; class NLXSubscriber implements EventSubscriberInterface { - private $params; - private $em; - private $serializer; - private $nlxLogService; - - public function __construct(ParameterBagInterface $params, EntityManagerInterface $em, SerializerInterface $serializer,NLXLogService $nlxLogService) - { - $this->params = $params; - $this->em = $em; - $this->serializer = $serializer; - $this->nlxLogService = $nlxLogService; - } - - public static function getSubscribedEvents() - { - return [ - KernelEvents::VIEW => ['NLXLog', EventPriorities::PRE_VALIDATE], - KernelEvents::VIEW => ['NLXAudit', EventPriorities::PRE_SERIALIZE], - ]; - - } - - public function NLXAudit(GetResponseForControllerResultEvent $event){ - - $result = $event->getControllerResult(); - $auditTrail= $event->getRequest()->query->get('auditTrail'); - - // Only do somthing if we are on te log route and the entity is logable - /* @todo we should trhow errors here foruser feedback */ - if (!$auditTrail ) { - return $result; - } - - $repo = $this->em->getRepository('App\Entity\NLXRequestLog'); - $logs = $repo->getLogEntries($result); - - - // now we need to overide the normal subscriber - $json = $this->serializer->serialize( - $logs, - 'jsonhal',['enable_max_depth' => true] - ); - - $response = new Response( - $json, - Response::HTTP_OK, - ['content-type' => 'application/json+hal'] - ); - - $event->setResponse($response); - - return; - } - - - public function NLXLog(GetResponseForControllerResultEvent $event) - { - $result = $event->getControllerResult(); - - $session = new Session(); - $session->start(); - // See: https://docs.nlx.io/further-reading/transaction-logs/ - - $log = New NLXRequestLog; - $log->setApplicationId ($event->getRequest()->headers->get('X-NLX-Application-Id')); - $log->setRequestId ($event->getRequest()->headers->get('X-NLX-Request-Id')); - $log->setUserId ($event->getRequest()->headers->get('X-NLX-Request-User-Id')); - $log->setSubjectId ($event->getRequest()->headers->get('X-NLX-Request-Subject-Identifier')); - $log->setProcessId ($event->getRequest()->headers->get('X-NLX-Request-Process-Id')); - $log->setDataElements ($event->getRequest()->headers->get('X-NLX-Request-Data-Elements')); - $log->setDataSubjects ($event->getRequest()->headers->get('X-NLX-Request-Data-Subject')); - $log->setObjectId ($result->getid()); - $log->setObjectClass ($this->em->getMetadataFactory()->getMetadataFor(get_class($result))->getName()); - $log->setRoute ($event->getRequest()->attributes->get('_route')); - $log->setEndpoint ($event->getRequest()->getPathInfo()); - $log->setMethod ($event->getRequest()->getMethod()); - $log->setContentType ($event->getRequest()->headers->get('Content-Type')); - $log->setContent ($event->getRequest()->getContent()); - $log->setSession ($session->getId()); - $log->setLoggedAt (new \DateTime() ); - - $this->em->persist($log); - $this->em->flush($log); - - // $authorization = $this->params->get('nlx.components.authorization.'); - // We need to do serveral things for nlx - - // First of all we need to log this request to our audit trial, where at minimal level we need to log who (application) asked what (data) for wich reasons (goal). We also need to consider that the requestee might have used the field query parmeter. So we need to log what fields of the object where actually returned. - - // Then we need to authenticate the request against a common ground authentication component - - // In the current common ground we dont bother with authorization (every one may do anything as long as we know who it is) - - return $result; - } + private $params; + private $em; + private $serializer; + private $nlxLogService; + + public function __construct(ParameterBagInterface $params, EntityManagerInterface $em, SerializerInterface $serializer, NLXLogService $nlxLogService) + { + $this->params = $params; + $this->em = $em; + $this->serializer = $serializer; + $this->nlxLogService = $nlxLogService; + } + + public static function getSubscribedEvents() + { + return [ + KernelEvents::VIEW => ['NLXLog', EventPriorities::PRE_VALIDATE], + KernelEvents::VIEW => ['NLXAudit', EventPriorities::PRE_SERIALIZE], + ]; + } + + public function NLXAudit(GetResponseForControllerResultEvent $event) + { + $result = $event->getControllerResult(); + $auditTrail = $event->getRequest()->query->get('auditTrail'); + + // Only do somthing if we are on te log route and the entity is logable + /* @todo we should trhow errors here foruser feedback */ + if (!$auditTrail) { + return $result; + } + + $repo = $this->em->getRepository('App\Entity\NLXRequestLog'); + $logs = $repo->getLogEntries($result); + + // now we need to overide the normal subscriber + $json = $this->serializer->serialize( + $logs, + 'jsonhal', ['enable_max_depth' => true] + ); + + $response = new Response( + $json, + Response::HTTP_OK, + ['content-type' => 'application/json+hal'] + ); + + $event->setResponse($response); + } + + public function NLXLog(GetResponseForControllerResultEvent $event) + { + $result = $event->getControllerResult(); + + $session = new Session(); + $session->start(); + // See: https://docs.nlx.io/further-reading/transaction-logs/ + + $log = new NLXRequestLog(); + $log->setApplicationId($event->getRequest()->headers->get('X-NLX-Application-Id')); + $log->setRequestId($event->getRequest()->headers->get('X-NLX-Request-Id')); + $log->setUserId($event->getRequest()->headers->get('X-NLX-Request-User-Id')); + $log->setSubjectId($event->getRequest()->headers->get('X-NLX-Request-Subject-Identifier')); + $log->setProcessId($event->getRequest()->headers->get('X-NLX-Request-Process-Id')); + $log->setDataElements($event->getRequest()->headers->get('X-NLX-Request-Data-Elements')); + $log->setDataSubjects($event->getRequest()->headers->get('X-NLX-Request-Data-Subject')); + $log->setObjectId($result->getid()); + $log->setObjectClass($this->em->getMetadataFactory()->getMetadataFor(get_class($result))->getName()); + $log->setRoute($event->getRequest()->attributes->get('_route')); + $log->setEndpoint($event->getRequest()->getPathInfo()); + $log->setMethod($event->getRequest()->getMethod()); + $log->setContentType($event->getRequest()->headers->get('Content-Type')); + $log->setContent($event->getRequest()->getContent()); + $log->setSession($session->getId()); + $log->setLoggedAt(new \DateTime()); + + $this->em->persist($log); + $this->em->flush($log); + + // $authorization = $this->params->get('nlx.components.authorization.'); + // We need to do serveral things for nlx + + // First of all we need to log this request to our audit trial, where at minimal level we need to log who (application) asked what (data) for wich reasons (goal). We also need to consider that the requestee might have used the field query parmeter. So we need to log what fields of the object where actually returned. + + // Then we need to authenticate the request against a common ground authentication component + + // In the current common ground we dont bother with authorization (every one may do anything as long as we know who it is) + + return $result; + } } diff --git a/api/src/Subscriber/ValidOnSubscriber.php b/api/src/Subscriber/ValidOnSubscriber.php index 616d66ef..4aac9f15 100644 --- a/api/src/Subscriber/ValidOnSubscriber.php +++ b/api/src/Subscriber/ValidOnSubscriber.php @@ -2,106 +2,96 @@ namespace App\Subscriber; -use ApiPlatform\Core\Exception\InvalidArgumentException; use ApiPlatform\Core\EventListener\EventPriorities; +use Doctrine\Common\Annotations\Reader; +use Doctrine\ORM\EntityManagerInterface; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Serializer\SerializerInterface; -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\Common\Annotations\Reader; -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; - -use App\Service\RequestService; class ValidOnSubscriber implements EventSubscriberInterface { - private $params; - private $em; - private $serializer; - private $annotationReader; - - public function __construct(ParameterBagInterface $params, EntityManagerInterface $em, SerializerInterface $serializer, Reader $annotationReader) - { - $this->params = $params; - $this->em= $em; - $this->serializer= $serializer; - $this->annotationReader = $annotationReader; - } - - public static function getSubscribedEvents() - { - return [ - KernelEvents::VIEW => ['validOn', EventPriorities::PRE_SERIALIZE], - ]; - - } - - public function validOn(GetResponseForControllerResultEvent $event) - { - $result = $event->getControllerResult(); - - // Lets get validOn from the query but deafult back to geldig op (for backward compatibality with api standaard) - $geldigOp = $event->getRequest()->query->get('geldigOp', false); - $validOn = $event->getRequest()->query->get('validOn', $geldigOp); - - - // Only do somthing if fields is query supplied - if (!$validOn) { - return $result; - } - - - // Lets see if this class has a Loggableannotation - $loggable = false; - $reflClass = new \ReflectionClass($result); - $annotations = $this->annotationReader->getClassAnnotations($reflClass); - - foreach($annotations as $annotation ){ - if(get_class($annotation) == "Gedmo\Mapping\Annotation\Loggable"){ - $loggable = true; - } - } - /* @todo propper error handling */ - if(!$loggable){ - throw new \Exception('This enity is not loggable therefore no previus versions can be obtained'); - } - - // Lets turn valid on into a date - try{ - $date = strtotime($validOn); - $date = date("Y-m-d H:i:s", $date); - - } catch (Exception $e) { - /* @todo thow propper exeption */ - throw new \Exception('Caught exception: ', $e->getMessage(), "\n"); - } - - // Lets try to get an version valid on that date - $queryBuilder= $this->em->getRepository('Gedmo\Loggable\Entity\LogEntry')->createQueryBuilder('l') - ->where('l.objectClass = :objectClass') - ->setParameter('objectClass', $this->em->getMetadataFactory()->getMetadataFor(get_class($result))->getName()) - ->andWhere('l.objectId = :objectId') - ->setParameter('objectId', $result->getId()) - ->andWhere('l.loggedAt <= :loggedAt') - ->setParameter('loggedAt', $date) - ->setMaxResults(1) - ->orderBy('l.loggedAt', 'DESC'); - - $version = $queryBuilder->getQuery()->getOneOrNullResult(); - - /* @todo propper error handling */ - if(!$version){ - throw new \Exception('Could not find a valid version for date: '.$date); - } - - // Lets use the found version to rewind the object and return is - $repo = $this->em->getRepository('\Gedmo\Loggable\Entity\LogEntry'); // we use default log entry class - $repo->revert($result, $version->getVersion()); - - return $result; - } + private $params; + private $em; + private $serializer; + private $annotationReader; + + public function __construct(ParameterBagInterface $params, EntityManagerInterface $em, SerializerInterface $serializer, Reader $annotationReader) + { + $this->params = $params; + $this->em = $em; + $this->serializer = $serializer; + $this->annotationReader = $annotationReader; + } + + public static function getSubscribedEvents() + { + return [ + KernelEvents::VIEW => ['validOn', EventPriorities::PRE_SERIALIZE], + ]; + } + + public function validOn(GetResponseForControllerResultEvent $event) + { + $result = $event->getControllerResult(); + + // Lets get validOn from the query but deafult back to geldig op (for backward compatibality with api standaard) + $geldigOp = $event->getRequest()->query->get('geldigOp', false); + $validOn = $event->getRequest()->query->get('validOn', $geldigOp); + + // Only do somthing if fields is query supplied + if (!$validOn) { + return $result; + } + + // Lets see if this class has a Loggableannotation + $loggable = false; + $reflClass = new \ReflectionClass($result); + $annotations = $this->annotationReader->getClassAnnotations($reflClass); + + foreach ($annotations as $annotation) { + if (get_class($annotation) == "Gedmo\Mapping\Annotation\Loggable") { + $loggable = true; + } + } + /* @todo propper error handling */ + if (!$loggable) { + throw new \Exception('This enity is not loggable therefore no previus versions can be obtained'); + } + + // Lets turn valid on into a date + try { + $date = strtotime($validOn); + $date = date('Y-m-d H:i:s', $date); + } catch (Exception $e) { + /* @todo thow propper exeption */ + throw new \Exception('Caught exception: ', $e->getMessage(), "\n"); + } + + // Lets try to get an version valid on that date + $queryBuilder = $this->em->getRepository('Gedmo\Loggable\Entity\LogEntry')->createQueryBuilder('l') + ->where('l.objectClass = :objectClass') + ->setParameter('objectClass', $this->em->getMetadataFactory()->getMetadataFor(get_class($result))->getName()) + ->andWhere('l.objectId = :objectId') + ->setParameter('objectId', $result->getId()) + ->andWhere('l.loggedAt <= :loggedAt') + ->setParameter('loggedAt', $date) + ->setMaxResults(1) + ->orderBy('l.loggedAt', 'DESC'); + + $version = $queryBuilder->getQuery()->getOneOrNullResult(); + + /* @todo propper error handling */ + if (!$version) { + throw new \Exception('Could not find a valid version for date: '.$date); + } + + // Lets use the found version to rewind the object and return is + $repo = $this->em->getRepository('\Gedmo\Loggable\Entity\LogEntry'); // we use default log entry class + $repo->revert($result, $version->getVersion()); + + return $result; + } } diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index 8a6edbd6..045ef50c 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -1,479 +1,481 @@ decorated = $decorated; - $this->params = $params; - $this->cash = $cache; - $this->em = $em; - $this->annotationReader = $annotationReader; - $this->camelCaseToSnakeCaseNameConverter= $camelCaseToSnakeCaseNameConverter; - } - - public function normalize($object, $format = null, array $context = []) - { - $docs = $this->decorated->normalize($object, $format, $context); - - /* The we need to enrich al the entities and add the autoated routes */ - - //var_dump($docs); - - // Lets make sure that we have definitions - if(!array_key_exists ('definitions',$docs)){$docs['definitions']=[];} - - // Lets make sure that we have tags - if(!array_key_exists ('tags',$docs)){$docs['tags']=[];} - - // Lets make sure that we have security and JWT-Claims - if(!array_key_exists ('securityDefinitions',$docs)){$docs['securityDefinitions']=[];} - - // Lets add JWT-Oauth - $docs['securityDefinitions']['JWT-Oauth'] = [ - "type"=>"oauth2", - "authorizationUrl"=>"http://petstore.swagger.io/api/oauth/dialog", - "flow"=>"implicit", - "scopes"=>[] #scopes will be filled later autmaticly - ]; - - $docs['securityDefinitions']['JWT-Token'] = [ - "type"=>"apiKey", - "in"=> "header", # can be "header", "query" or "cookie" - "name"=> "Authorization", # name of the header, query parameter or cookie - "scopes"=>[] #scopes will be filled later autmaticly - ]; - - - // Lets get al the entities known to doctrine - $entities = $this->em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames(); - - $additionalDocs = []; - - // Then we loop trough the entities to find the api platform entities - foreach($entities as $entity){ - //$reflector = new \ReflectionClass($entity); - $metadata = $this->em->getClassMetadata($entity); - $reflector = $metadata->getReflectionClass(); - - $properties = $metadata->getReflectionProperties(); - $annotations = $this->annotationReader->getClassAnnotations($reflector); - - foreach($annotations as $annotation){ - $annotationReflector = new \ReflectionClass($annotation); - if($annotationReflector->name == "ApiPlatform\Core\Annotation\ApiResource"){ - - // Lets add the class info to the tag - $shortName = $reflector->getShortName (); - - $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); - $docblock = $factory->create($reflector->getDocComment()); - $summary = $docblock->getSummary(); - $description = $docblock->getDescription()->render(); - $description = $summary."\n\n".$description; - - $tag = []; - $tag['name'] = $shortName; - $tag['description'] = $description; - - $docs['tags'][] = $tag; - - // And lets add the aditional docs - - //$additionalEntityDocs = $this->getAdditionalEntityDocs($entity); - $entityDocs = $this->getAdditionalEntityDocs($entity); - $additionalDocs= array_merge($additionalDocs,$entityDocs['properties']); - - // Security - $docs['securityDefinitions']['JWT-Oauth']['scopes']= array_merge($docs['securityDefinitions']['JWT-Oauth']['scopes'],$entityDocs['security']); - $docs['securityDefinitions']['JWT-Token']['scopes']= array_merge($docs['securityDefinitions']['JWT-Token']['scopes'],$entityDocs['security']); - - break; - } - } - } - - // Oke dit is echt but lelijk - $schemas = (array) $docs['definitions']; - foreach($schemas as $schemaName => $schema){ - - $additionalDocs[$schemaName] = array_merge( (array) $schema, $additionalDocs[$schemaName]); - - $properties = (array) $schema['properties']; - foreach($properties as $propertyName => $property){ - $additionalDocs[$schemaName]['properties'][$propertyName] = array_merge( (array) $property, $additionalDocs[$schemaName]['properties'][$propertyName] ); - } - } - $docs['definitions'] = $additionalDocs; - - // Lest add an host - if($this->params->get('common_ground.oas.host')){ - $docs['host']= $this->params->get('common_ground.oas.host'); - } - - // Lets set the servers - if(array_key_exists ('servers',$docs)){$docs['servers']=[];} - foreach($this->params->get('common_ground.oas.servers') as $key => $value){ - $docs['servers'][$key] = $value; - - } - - // Lets set the external documentation - if(array_key_exists ('externalDocs',$docs)){$docs['externalDocs']=[];} - foreach($this->params->get('common_ground.oas.externalDocs') as $key => $value){ - $docs['externalDocs'][$key] = $value; - - } - - // Lets add the commonground codes - if(array_key_exists ('x-commonground',$docs)){$docs['x-commonground']=[];} - - // Lets set the component type - $docs['x-commonground']['type'] = $this->params->get('common_ground.oas.type'); - - // Lets set the devolopers - if(array_key_exists ('developers',$docs['x-commonground'])){$docs['developers']=[];} - foreach($this->params->get('common_ground.oas.developers') as $key => $value){ - $docs['x-commonground']['developers'][$key] = $value; - - } - - // Lets set the build checks - if(array_key_exists ('builds',$docs['x-commonground'])){$docs['builds']=[];} - foreach($this->params->get('common_ground.oas.builds') as $key => $value){ - $docs['x-commonground']['builds'][$key] = $value; - } - - /*todo a loop within a lopo is butt ugly */ - foreach($docs['paths'] as $path => $calls){ - - foreach($calls as $method => $call){ - - // NLX loging headers - $call['parameters'][] = [ - 'name' => 'Authorization', - 'description' => 'The JWT of the entity performing the request', - 'in' => 'header', - ]; - // NLX loging headers - $call['parameters'][] = [ - 'name' => 'API-Version', - 'description' => 'The version of the API conform [Landelijke API-strategie.](https://geonovum.github.io/KP-APIs/#versioning)', - 'example'=>'1.0.1', - 'in' => 'header', - ]; - /* - // NLX loging headers - $call['parameters'][] = [ - 'name' => 'X-NLX-Request-Application-Id', - 'description' => 'The id of the application performing the request', - 'in' => 'header', - ]; - // NLX loging headers - $call['parameters'][] = [ - 'name' => 'X-NLX-Request-Subject-Identifier', - 'description' => 'An subject identifier for purpose registration (doelbinding)', - 'in' => 'header', - ]; - */ - // NLX loging headers - $call['parameters'][] = [ - 'name' => 'X-NLX-Logrecord-ID', - 'description' => 'A globally unique id of the request, which makes a request traceable throughout the network.', - 'in' => 'header', - ]; - // NLX loging headers - $call['parameters'][] = [ - 'name' => 'X-NLX-Request-Process-Id', - 'description' => 'A process id for purpose registration (doelbinding)', - 'in' => 'header', - ]; - // NLX loging headers - $call['parameters'][] = [ - 'name' => 'X-NLX-Request-Data-Elements', - 'description' => 'A list of requested data elements', - 'in' => 'header', - ]; - // NLX loging headers - $call['parameters'][] = [ - 'name' => 'X-NLX-Request-Data-Subject', - 'description' => 'A key-value list of data subjects related to this request. e.g. `bsn=12345678, kenteken=ab-12-fg`', - 'in' => 'header', - ]; - // NLX loging headers - $call['parameters'][] = [ - 'name' => 'X-NLX-Audit-Clarification', - 'description' => 'A clarification as to why a request has been made (doelbinding)', - 'in' => 'header', - ]; - - - if($method == "get"){ - - - // Health JSON - $call['produces'][] = 'application/health+json'; - - // WEBSUB header - $call['parameters'][] = [ - 'name' => 'Link', - 'description' => 'A [websub](https://www.w3.org/TR/websub/#discovery) header like ; rel="hub"', - 'in' => 'header', - ]; - - // Lets add the extend functionality - $call['parameters'][] = [ - 'name' => 'extend[]', - 'required' => false, - 'description' => 'An array of nested objects to include in the return object', - 'in' => 'query', - 'schema'=>['type'=>'array'] - ]; - // Lets add the fields functionality - $call['parameters'][] = [ - 'name' => 'fields[]', - 'required' => false, - 'description' => 'An array of fields to return in output, wil return all fields is not supplied', - 'in' => 'query', - 'schema'=>['type'=>'array'] - ]; - // Lets add some time travel - $call['parameters'][] = [ - 'name' => 'validOn', - 'required' => false, - 'description' => 'Returns object as valid on a given date time', - 'schema'=>['type'=>'string', 'format' => 'date-time'], - 'in' => 'query', - ]; - $call['parameters'][] = [ - 'name' => 'validFrom', - 'required' => false, - 'description' => 'Returns objects valid from a given date time', - 'schema'=>['type'=>'string', 'format' => 'date-time'], - 'in' => 'query', - ]; - $call['parameters'][] = [ - 'name' => 'validUntil', - 'required' => false, - 'description' => 'Returns objects valid until a given date time', - 'schema'=>['type'=>'string', 'format' => 'date-time'], - 'in' => 'query', - ]; - } - } - } - - /* @todo dit afbouwen */ - - /* - if(config heltchecks is true){ - $tag=[]; - $tag['name']=''; - $tag['description']=''; - array_unshift($fruits_list, $tag); - - } - - if(config audittrail is true){ - $tag=[]; - $tag['name']=''; - $tag['description']=''; - array_unshift($fruits_list, $tag); - - } - - if(config notifications is true){ - $tag=[]; - $tag['name']=''; - $tag['description']=''; - array_unshift($fruits_list, $tag); - - } - - if(config authorization is true){ - $tag=[]; - $tag['name']=''; - $tag['description']=''; - array_unshift($fruits_list, $tag); - } - */ - //var_dump($docs); - - - // Aditional tags - - - // Security tag - if(getenv('HEALTH_ENABLED')=="true"){ - $tag = []; - $tag['name'] = 'Health Checks'; - $tag['description'] = 'Authorization'; - $tag['externalDocs'] = []; - $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; - array_unshift($docs['tags'], $tag); - } - - // Security tag - if(getenv('NOTIFICATION_ENABLED')=="true"){ - $tag = []; - $tag['name'] = 'Notifications'; - $tag['description'] = 'Authorization'; - $tag['externalDocs'] = []; - $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; - array_unshift($docs['tags'], $tag); - } - - - // Security tag - if(getenv('AUDITTRAIL_ENABLED')=="true"){ - $tag = []; - $tag['name'] = 'Audit trail'; - $tag['description'] = 'Authorization'; - $tag['externalDocs'] = []; - $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; - array_unshift($docs['tags'], $tag); - } - - // Security tag - if(getenv('AUTH_ENABLED')=="true"){ - $tag = []; - $tag['name'] = 'Authorization'; - $tag['description'] = 'Authorization'; - $tag['externalDocs'] = []; - $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; - array_unshift($docs['tags'], $tag); - } - - - //var_dump($docs); - return $docs; - } - - public function supportsNormalization($data, $format = null) - { - return $this->decorated->supportsNormalization($data, $format); - } - - private function getAdditionalEntityDocs($entity){ - - $metadata = $this->em->getClassMetadata($entity); - $reflector = $metadata->getReflectionClass(); - $properties = $metadata->getReflectionProperties(); - $annotations = $this->annotationReader->getClassAnnotations($reflector); - $additionalDocs = ['properties','security'=>[]]; - $required = []; - - // Add audittrail - // Add healthcheck - - $class = $reflector->getShortName(); - $path = '/'.$this->camelCaseToSnakeCaseNameConverter->normalize($class); - - - // Lets take a look at the properties an annotions, - foreach($properties as $property){ - - // The dockBlocks for thie property - $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); - $docblock = $factory->create($property->getDocComment()); - $tags = $docblock->getTags(); - $atributes = []; - - foreach($tags as $tag){ - $name = $tag->getName(); - $description = $tag->getDescription(); - // - //$description = (string) $description; - - switch ($name) { - // Docblocks - case "example": - $atributes['example'] = (string) $description; - break; - - // Groups - case "Groups": - $propertyAnnotation = $this->annotationReader->getPropertyAnnotation($property, "Symfony\Component\Serializer\Annotation\Groups"); - $groups = $propertyAnnotation->getGroups(); - break; - - // Constrainds (Validation) - case "Assert\Uuid": - $atributes['format'] = 'uuid'; - break; - case "Assert\Email": - $atributes['format'] = 'email'; - break; - case "Assert\Url": - $atributes['format'] = 'url'; - break; - case "Assert\Regex": - $atributes['format'] = 'regex'; - break; - case "Assert\Ip": - $atributes['format'] = 'ip'; - break; - case "Assert\Json": - $atributes['format'] = 'json'; - break; - case "Assert\Choice": - //@todo - //$atributes['format'] = 'json'; - break; - - case "Assert\NotNull": - $required[] = $property->name; - break; - case "Assert\Length": - $propertyAnnotation = $this->annotationReader->getPropertyAnnotation($property, "Symfony\Component\Validator\Constraints\Length"); - if($propertyAnnotation->max){$atributes['maxLength'] = $propertyAnnotation->max;} - if($propertyAnnotation->min){$atributes['minLength'] = $propertyAnnotation->min;} - break; - } - - } - // Lets write everything to the docs - foreach($groups as $group){ - //$additionalDocs["components"]['schemas'][$class."-".$group] = $atributes; - $additionalDocs['properties'][$class."-".$group]["properties"][$property->name]= $atributes; - $additionalDocs['properties'][$class."-".$group]["required"] = $required; - - - if(!array_key_exists ($group,$additionalDocs['security'])){$additionalDocs['security'][$group] = $group.' right to the '.$class.' resource'; } - } - - } - - - - - return $additionalDocs; - } -} \ No newline at end of file + private $metadataFactory; + private $documentationNormalizer; + private $decorated; + private $params; + private $cash; + private $em; + private $annotationReader; + private $camelCaseToSnakeCaseNameConverter; + + public function __construct( + NormalizerInterface $decorated, + ParameterBagInterface $params, + CacheInterface $cache, + EntityManagerInterface $em, + AnnotationReader $annotationReader, + CamelCaseToSnakeCaseNameConverter $camelCaseToSnakeCaseNameConverter + ) { + $this->decorated = $decorated; + $this->params = $params; + $this->cash = $cache; + $this->em = $em; + $this->annotationReader = $annotationReader; + $this->camelCaseToSnakeCaseNameConverter = $camelCaseToSnakeCaseNameConverter; + } + + public function normalize($object, $format = null, array $context = []) + { + $docs = $this->decorated->normalize($object, $format, $context); + + /* The we need to enrich al the entities and add the autoated routes */ + + //var_dump($docs); + + // Lets make sure that we have definitions + if (!array_key_exists('definitions', $docs)) { + $docs['definitions'] = []; + } + + // Lets make sure that we have tags + if (!array_key_exists('tags', $docs)) { + $docs['tags'] = []; + } + + // Lets make sure that we have security and JWT-Claims + if (!array_key_exists('securityDefinitions', $docs)) { + $docs['securityDefinitions'] = []; + } + + // Lets add JWT-Oauth + $docs['securityDefinitions']['JWT-Oauth'] = [ + 'type' => 'oauth2', + 'authorizationUrl'=> 'http://petstore.swagger.io/api/oauth/dialog', + 'flow' => 'implicit', + 'scopes' => [], //scopes will be filled later autmaticly + ]; + + $docs['securityDefinitions']['JWT-Token'] = [ + 'type' => 'apiKey', + 'in' => 'header', // can be "header", "query" or "cookie" + 'name' => 'Authorization', // name of the header, query parameter or cookie + 'scopes'=> [], //scopes will be filled later autmaticly + ]; + + // Lets get al the entities known to doctrine + $entities = $this->em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames(); + + $additionalDocs = []; + + // Then we loop trough the entities to find the api platform entities + foreach ($entities as $entity) { + //$reflector = new \ReflectionClass($entity); + $metadata = $this->em->getClassMetadata($entity); + $reflector = $metadata->getReflectionClass(); + + $properties = $metadata->getReflectionProperties(); + $annotations = $this->annotationReader->getClassAnnotations($reflector); + + foreach ($annotations as $annotation) { + $annotationReflector = new \ReflectionClass($annotation); + if ($annotationReflector->name == "ApiPlatform\Core\Annotation\ApiResource") { + + // Lets add the class info to the tag + $shortName = $reflector->getShortName(); + + $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); + $docblock = $factory->create($reflector->getDocComment()); + $summary = $docblock->getSummary(); + $description = $docblock->getDescription()->render(); + $description = $summary."\n\n".$description; + + $tag = []; + $tag['name'] = $shortName; + $tag['description'] = $description; + + $docs['tags'][] = $tag; + + // And lets add the aditional docs + + //$additionalEntityDocs = $this->getAdditionalEntityDocs($entity); + $entityDocs = $this->getAdditionalEntityDocs($entity); + $additionalDocs = array_merge($additionalDocs, $entityDocs['properties']); + + // Security + $docs['securityDefinitions']['JWT-Oauth']['scopes'] = array_merge($docs['securityDefinitions']['JWT-Oauth']['scopes'], $entityDocs['security']); + $docs['securityDefinitions']['JWT-Token']['scopes'] = array_merge($docs['securityDefinitions']['JWT-Token']['scopes'], $entityDocs['security']); + + break; + } + } + } + + // Oke dit is echt but lelijk + $schemas = (array) $docs['definitions']; + foreach ($schemas as $schemaName => $schema) { + $additionalDocs[$schemaName] = array_merge((array) $schema, $additionalDocs[$schemaName]); + + $properties = (array) $schema['properties']; + foreach ($properties as $propertyName => $property) { + $additionalDocs[$schemaName]['properties'][$propertyName] = array_merge((array) $property, $additionalDocs[$schemaName]['properties'][$propertyName]); + } + } + $docs['definitions'] = $additionalDocs; + + // Lest add an host + if ($this->params->get('common_ground.oas.host')) { + $docs['host'] = $this->params->get('common_ground.oas.host'); + } + + // Lets set the servers + if (array_key_exists('servers', $docs)) { + $docs['servers'] = []; + } + foreach ($this->params->get('common_ground.oas.servers') as $key => $value) { + $docs['servers'][$key] = $value; + } + + // Lets set the external documentation + if (array_key_exists('externalDocs', $docs)) { + $docs['externalDocs'] = []; + } + foreach ($this->params->get('common_ground.oas.externalDocs') as $key => $value) { + $docs['externalDocs'][$key] = $value; + } + + // Lets add the commonground codes + if (array_key_exists('x-commonground', $docs)) { + $docs['x-commonground'] = []; + } + + // Lets set the component type + $docs['x-commonground']['type'] = $this->params->get('common_ground.oas.type'); + + // Lets set the devolopers + if (array_key_exists('developers', $docs['x-commonground'])) { + $docs['developers'] = []; + } + foreach ($this->params->get('common_ground.oas.developers') as $key => $value) { + $docs['x-commonground']['developers'][$key] = $value; + } + + // Lets set the build checks + if (array_key_exists('builds', $docs['x-commonground'])) { + $docs['builds'] = []; + } + foreach ($this->params->get('common_ground.oas.builds') as $key => $value) { + $docs['x-commonground']['builds'][$key] = $value; + } + + /*todo a loop within a lopo is butt ugly */ + foreach ($docs['paths'] as $path => $calls) { + foreach ($calls as $method => $call) { + + // NLX loging headers + $call['parameters'][] = [ + 'name' => 'Authorization', + 'description' => 'The JWT of the entity performing the request', + 'in' => 'header', + ]; + // NLX loging headers + $call['parameters'][] = [ + 'name' => 'API-Version', + 'description' => 'The version of the API conform [Landelijke API-strategie.](https://geonovum.github.io/KP-APIs/#versioning)', + 'example' => '1.0.1', + 'in' => 'header', + ]; + /* + // NLX loging headers + $call['parameters'][] = [ + 'name' => 'X-NLX-Request-Application-Id', + 'description' => 'The id of the application performing the request', + 'in' => 'header', + ]; + // NLX loging headers + $call['parameters'][] = [ + 'name' => 'X-NLX-Request-Subject-Identifier', + 'description' => 'An subject identifier for purpose registration (doelbinding)', + 'in' => 'header', + ]; + */ + // NLX loging headers + $call['parameters'][] = [ + 'name' => 'X-NLX-Logrecord-ID', + 'description' => 'A globally unique id of the request, which makes a request traceable throughout the network.', + 'in' => 'header', + ]; + // NLX loging headers + $call['parameters'][] = [ + 'name' => 'X-NLX-Request-Process-Id', + 'description' => 'A process id for purpose registration (doelbinding)', + 'in' => 'header', + ]; + // NLX loging headers + $call['parameters'][] = [ + 'name' => 'X-NLX-Request-Data-Elements', + 'description' => 'A list of requested data elements', + 'in' => 'header', + ]; + // NLX loging headers + $call['parameters'][] = [ + 'name' => 'X-NLX-Request-Data-Subject', + 'description' => 'A key-value list of data subjects related to this request. e.g. `bsn=12345678, kenteken=ab-12-fg`', + 'in' => 'header', + ]; + // NLX loging headers + $call['parameters'][] = [ + 'name' => 'X-NLX-Audit-Clarification', + 'description' => 'A clarification as to why a request has been made (doelbinding)', + 'in' => 'header', + ]; + + if ($method == 'get') { + + // Health JSON + $call['produces'][] = 'application/health+json'; + + // WEBSUB header + $call['parameters'][] = [ + 'name' => 'Link', + 'description' => 'A [websub](https://www.w3.org/TR/websub/#discovery) header like ; rel="hub"', + 'in' => 'header', + ]; + + // Lets add the extend functionality + $call['parameters'][] = [ + 'name' => 'extend[]', + 'required' => false, + 'description' => 'An array of nested objects to include in the return object', + 'in' => 'query', + 'schema' => ['type'=>'array'], + ]; + // Lets add the fields functionality + $call['parameters'][] = [ + 'name' => 'fields[]', + 'required' => false, + 'description' => 'An array of fields to return in output, wil return all fields is not supplied', + 'in' => 'query', + 'schema' => ['type'=>'array'], + ]; + // Lets add some time travel + $call['parameters'][] = [ + 'name' => 'validOn', + 'required' => false, + 'description' => 'Returns object as valid on a given date time', + 'schema' => ['type'=>'string', 'format' => 'date-time'], + 'in' => 'query', + ]; + $call['parameters'][] = [ + 'name' => 'validFrom', + 'required' => false, + 'description' => 'Returns objects valid from a given date time', + 'schema' => ['type'=>'string', 'format' => 'date-time'], + 'in' => 'query', + ]; + $call['parameters'][] = [ + 'name' => 'validUntil', + 'required' => false, + 'description' => 'Returns objects valid until a given date time', + 'schema' => ['type'=>'string', 'format' => 'date-time'], + 'in' => 'query', + ]; + } + } + } + + /* @todo dit afbouwen */ + + /* + if(config heltchecks is true){ + $tag=[]; + $tag['name']=''; + $tag['description']=''; + array_unshift($fruits_list, $tag); + + } + + if(config audittrail is true){ + $tag=[]; + $tag['name']=''; + $tag['description']=''; + array_unshift($fruits_list, $tag); + + } + + if(config notifications is true){ + $tag=[]; + $tag['name']=''; + $tag['description']=''; + array_unshift($fruits_list, $tag); + + } + + if(config authorization is true){ + $tag=[]; + $tag['name']=''; + $tag['description']=''; + array_unshift($fruits_list, $tag); + } + */ + //var_dump($docs); + + // Aditional tags + + // Security tag + if (getenv('HEALTH_ENABLED') == 'true') { + $tag = []; + $tag['name'] = 'Health Checks'; + $tag['description'] = 'Authorization'; + $tag['externalDocs'] = []; + $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; + array_unshift($docs['tags'], $tag); + } + + // Security tag + if (getenv('NOTIFICATION_ENABLED') == 'true') { + $tag = []; + $tag['name'] = 'Notifications'; + $tag['description'] = 'Authorization'; + $tag['externalDocs'] = []; + $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; + array_unshift($docs['tags'], $tag); + } + + // Security tag + if (getenv('AUDITTRAIL_ENABLED') == 'true') { + $tag = []; + $tag['name'] = 'Audit trail'; + $tag['description'] = 'Authorization'; + $tag['externalDocs'] = []; + $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; + array_unshift($docs['tags'], $tag); + } + + // Security tag + if (getenv('AUTH_ENABLED') == 'true') { + $tag = []; + $tag['name'] = 'Authorization'; + $tag['description'] = 'Authorization'; + $tag['externalDocs'] = []; + $tag['externalDocs'][] = ['url'=>'http://docs.my-api.com/pet-operations.htm']; + array_unshift($docs['tags'], $tag); + } + + //var_dump($docs); + return $docs; + } + + public function supportsNormalization($data, $format = null) + { + return $this->decorated->supportsNormalization($data, $format); + } + + private function getAdditionalEntityDocs($entity) + { + $metadata = $this->em->getClassMetadata($entity); + $reflector = $metadata->getReflectionClass(); + $properties = $metadata->getReflectionProperties(); + $annotations = $this->annotationReader->getClassAnnotations($reflector); + $additionalDocs = ['properties', 'security'=>[]]; + $required = []; + + // Add audittrail + // Add healthcheck + + $class = $reflector->getShortName(); + $path = '/'.$this->camelCaseToSnakeCaseNameConverter->normalize($class); + + // Lets take a look at the properties an annotions, + foreach ($properties as $property) { + + // The dockBlocks for thie property + $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); + $docblock = $factory->create($property->getDocComment()); + $tags = $docblock->getTags(); + $atributes = []; + + foreach ($tags as $tag) { + $name = $tag->getName(); + $description = $tag->getDescription(); + // + //$description = (string) $description; + + switch ($name) { + // Docblocks + case 'example': + $atributes['example'] = (string) $description; + break; + + // Groups + case 'Groups': + $propertyAnnotation = $this->annotationReader->getPropertyAnnotation($property, "Symfony\Component\Serializer\Annotation\Groups"); + $groups = $propertyAnnotation->getGroups(); + break; + + // Constrainds (Validation) + case "Assert\Uuid": + $atributes['format'] = 'uuid'; + break; + case "Assert\Email": + $atributes['format'] = 'email'; + break; + case "Assert\Url": + $atributes['format'] = 'url'; + break; + case "Assert\Regex": + $atributes['format'] = 'regex'; + break; + case "Assert\Ip": + $atributes['format'] = 'ip'; + break; + case "Assert\Json": + $atributes['format'] = 'json'; + break; + case "Assert\Choice": + //@todo + //$atributes['format'] = 'json'; + break; + + case "Assert\NotNull": + $required[] = $property->name; + break; + case "Assert\Length": + $propertyAnnotation = $this->annotationReader->getPropertyAnnotation($property, "Symfony\Component\Validator\Constraints\Length"); + if ($propertyAnnotation->max) { + $atributes['maxLength'] = $propertyAnnotation->max; + } + if ($propertyAnnotation->min) { + $atributes['minLength'] = $propertyAnnotation->min; + } + break; + } + } + // Lets write everything to the docs + foreach ($groups as $group) { + //$additionalDocs["components"]['schemas'][$class."-".$group] = $atributes; + $additionalDocs['properties'][$class.'-'.$group]['properties'][$property->name] = $atributes; + $additionalDocs['properties'][$class.'-'.$group]['required'] = $required; + + if (!array_key_exists($group, $additionalDocs['security'])) { + $additionalDocs['security'][$group] = $group.' right to the '.$class.' resource'; + } + } + } + + return $additionalDocs; + } +} diff --git a/api/src/Types/IncompleteDateType.php b/api/src/Types/IncompleteDateType.php index 8badbc8e..88f66c3c 100644 --- a/api/src/Types/IncompleteDateType.php +++ b/api/src/Types/IncompleteDateType.php @@ -2,54 +2,58 @@ namespace App\Types; -use Doctrine\DBAL\Types\Type; -use Doctrine\DBAL\Platforms\AbstractPlatform; - use App\ValueObject\IncompleteDate; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Types\Type; class IncompleteDateType extends Type { - const INCOMPLETEDATE = 'incompleteDate'; - - public function getName() - { - return self::INCOMPLETEDATE; - } - - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) - { - return 'INTEGER'; - } - - public function convertToPHPValue($value, AbstractPlatform $platform) - { - // Lets make this nullable - if(!$value){ - return null; - } - // We save incomplete date's as YYYYMMDD integer values so that we can easily index and order on them - list($year, $month, $day) = sscanf($value, '%04u%02u%02u'); - - return new IncompleteDate($year, $month, $day); - } - - public function convertToDatabaseValue($value, AbstractPlatform $platform) - { - // Lets make this nullable - if(!$value){ - return null; - } - // We save incomplete date's as YYYYMMDD integer values so that we can easily index and order on them - if ($value instanceof IncompleteDate) { - $value = sprintf('%04u%02u%02u', $value->getYear(), $value->getMonth(), $value->getDay()); - } - else{ - if(!array_key_exists("year",$value)){ $value['year']=0;} - if(!array_key_exists("month",$value)){ $value['month']=0;} - if(!array_key_exists("day",$value)){ $value['day']=0;} - $value = sprintf('%04u%02u%02u', (int) $value['year'], (int) $value['month'], (int) $value['day']); - } - - return $value; - } -} \ No newline at end of file + const INCOMPLETEDATE = 'incompleteDate'; + + public function getName() + { + return self::INCOMPLETEDATE; + } + + public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + { + return 'INTEGER'; + } + + public function convertToPHPValue($value, AbstractPlatform $platform) + { + // Lets make this nullable + if (!$value) { + return; + } + // We save incomplete date's as YYYYMMDD integer values so that we can easily index and order on them + list($year, $month, $day) = sscanf($value, '%04u%02u%02u'); + + return new IncompleteDate($year, $month, $day); + } + + public function convertToDatabaseValue($value, AbstractPlatform $platform) + { + // Lets make this nullable + if (!$value) { + return; + } + // We save incomplete date's as YYYYMMDD integer values so that we can easily index and order on them + if ($value instanceof IncompleteDate) { + $value = sprintf('%04u%02u%02u', $value->getYear(), $value->getMonth(), $value->getDay()); + } else { + if (!array_key_exists('year', $value)) { + $value['year'] = 0; + } + if (!array_key_exists('month', $value)) { + $value['month'] = 0; + } + if (!array_key_exists('day', $value)) { + $value['day'] = 0; + } + $value = sprintf('%04u%02u%02u', (int) $value['year'], (int) $value['month'], (int) $value['day']); + } + + return $value; + } +} diff --git a/api/src/Types/UnderInvestigationType.php b/api/src/Types/UnderInvestigationType.php index e66e7e7c..4717bf51 100644 --- a/api/src/Types/UnderInvestigationType.php +++ b/api/src/Types/UnderInvestigationType.php @@ -2,66 +2,69 @@ namespace App\Types; -use Doctrine\DBAL\Types\Type; -use Doctrine\DBAL\Platforms\AbstractPlatform; - use App\ValueObject\UnderInvestigation; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Types\Type; class UnderInvestigationType extends Type { - const UNDERINVESTIGATION = 'underInvestigation'; - - public function getName() - { - return self::UNDERINVESTIGATION; - } - - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) - { - return 'JSON'; - } - - public function convertToPHPValue($value, AbstractPlatform $platform) - { - // Lets make this nullable - if(!$value){ - return null; - } - //list($longitude, $latitude) = sscanf($value, 'JSON(%s)'); - $value= json_decode ($value, true); - //var_dump($data); - $date = $value['date']; - $properties = $value['properties']; - return new UnderInvestigation($properties, $date); - } - - public function convertToDatabaseValue($value, AbstractPlatform $platform) - { - // Lets make this nullable - if(!$value){ - return null; - } - if ($value instanceof UnderInvestigation) { - /* @todo throw an error ir the property isn't a boolean*/ - $value= ["properties"=> $value->getProperties(),"date"=> $value->getDate()]; - $value = json_encode($value); - } - else{ - // lets make sure we have a properties array - if(!array_key_exists("properties",$value)){ $value['properties']=[];} - // Lets analyse this dataset - foreach ($value as $key => $property){ - // lets skip the date and propertieskeys - if($key=='date' || $key=='properties'){continue;} - /* @todo throw an error ir the property isn't a boolean*/ - - // lets add the property to the stack - $value['properties'][$key] = $property; - unset($value[$key]); - } - $value = json_encode($value); - } - - return $value; - } -} \ No newline at end of file + const UNDERINVESTIGATION = 'underInvestigation'; + + public function getName() + { + return self::UNDERINVESTIGATION; + } + + public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + { + return 'JSON'; + } + + public function convertToPHPValue($value, AbstractPlatform $platform) + { + // Lets make this nullable + if (!$value) { + return; + } + //list($longitude, $latitude) = sscanf($value, 'JSON(%s)'); + $value = json_decode($value, true); + //var_dump($data); + $date = $value['date']; + $properties = $value['properties']; + + return new UnderInvestigation($properties, $date); + } + + public function convertToDatabaseValue($value, AbstractPlatform $platform) + { + // Lets make this nullable + if (!$value) { + return; + } + if ($value instanceof UnderInvestigation) { + /* @todo throw an error ir the property isn't a boolean*/ + $value = ['properties'=> $value->getProperties(), 'date'=> $value->getDate()]; + $value = json_encode($value); + } else { + // lets make sure we have a properties array + if (!array_key_exists('properties', $value)) { + $value['properties'] = []; + } + // Lets analyse this dataset + foreach ($value as $key => $property) { + // lets skip the date and propertieskeys + if ($key == 'date' || $key == 'properties') { + continue; + } + /* @todo throw an error ir the property isn't a boolean*/ + + // lets add the property to the stack + $value['properties'][$key] = $property; + unset($value[$key]); + } + $value = json_encode($value); + } + + return $value; + } +} diff --git a/api/src/ValueObject/IncompleteDate.php b/api/src/ValueObject/IncompleteDate.php index 97149fc6..c9fbb072 100644 --- a/api/src/ValueObject/IncompleteDate.php +++ b/api/src/ValueObject/IncompleteDate.php @@ -2,64 +2,72 @@ namespace App\ValueObject; - /* * Incomplomplete data class - * + * * This doctrine value object is designd to work in tendem with the incompleteData mapping type to provide doctrine support for the working with incomplete date objects - * - * + * + * */ -class IncompleteDate +class IncompleteDate { - /** - * @param integer $day - * @param integer $month - * @param integer $year - */ - public function __construct($year, $month, $day) - { - $this->day = $day; - $this->month= $month; - $this->year = $year; - } - - /** - * @return integer - */ - public function getDay() - { - // If the day is missing we return zero - if(!$this->day){return 0;} - return $this->day; - } - - /** - * @return integer - */ - public function getMonth() - { - // If the month is missing we return zero - if(!$this->month){return 0;} - return $this->month; - } - - /** - * @return integer - */ - public function getYear() - { - // If the year is missing we return zero - if(!$this->year){return 0;} - return $this->year; - } - - /** - * @return string - */ - public function getDate() - { - return sprintf('%04u-%02u-%02u', $this->getYear(), $this->getMonth(), $this->getDay()); - } -} \ No newline at end of file + /** + * @param int $day + * @param int $month + * @param int $year + */ + public function __construct($year, $month, $day) + { + $this->day = $day; + $this->month = $month; + $this->year = $year; + } + + /** + * @return int + */ + public function getDay() + { + // If the day is missing we return zero + if (!$this->day) { + return 0; + } + + return $this->day; + } + + /** + * @return int + */ + public function getMonth() + { + // If the month is missing we return zero + if (!$this->month) { + return 0; + } + + return $this->month; + } + + /** + * @return int + */ + public function getYear() + { + // If the year is missing we return zero + if (!$this->year) { + return 0; + } + + return $this->year; + } + + /** + * @return string + */ + public function getDate() + { + return sprintf('%04u-%02u-%02u', $this->getYear(), $this->getMonth(), $this->getDay()); + } +} diff --git a/api/src/ValueObject/UnderInvestigation.php b/api/src/ValueObject/UnderInvestigation.php index 63912361..bbbb98f1 100644 --- a/api/src/ValueObject/UnderInvestigation.php +++ b/api/src/ValueObject/UnderInvestigation.php @@ -2,32 +2,31 @@ namespace App\ValueObject; - -class UnderInvestigation +class UnderInvestigation { - /** - * @param array $properties - * @param string $date - */ - public function __construct($properties, $date) - { - $this->properties= $properties; - $this->date= $date; - } - - /** - * @return array - */ - public function getProperties() - { - return $this->properties; - } - - /** - * @return string - */ - public function getDate() - { - return $this->date; - } -} \ No newline at end of file + /** + * @param array $properties + * @param string $date + */ + public function __construct($properties, $date) + { + $this->properties = $properties; + $this->date = $date; + } + + /** + * @return array + */ + public function getProperties() + { + return $this->properties; + } + + /** + * @return string + */ + public function getDate() + { + return $this->date; + } +} From 8c49648e3effd79880d6709915b92bcf3a03ea31 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 13:27:44 +0100 Subject: [PATCH 035/125] Test voor helm version --- .github/workflows/dockerimage.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index e73dbdf9..81cf4025 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -72,7 +72,13 @@ jobs: echo "##[set-output name=success]true" else echo "##[set-output name=success]false" - fi + fi + - name: Set correct helm version + if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' + run: | + brew unlink kubernetes-helm + brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/78d64252f30a12b6f4b3ce29686ab5e262eea812/Formula/kubernetes-helm.rb + brew switch kubernetes-helm 2.12.3 - name: Deploy through helm if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true From 909269ffae6d7dd2a7d200f166bd0d41b5727fe0 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 13:27:44 +0100 Subject: [PATCH 036/125] Test voor helm version --- .github/workflows/dockerimage.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index e73dbdf9..11736f5e 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -19,6 +19,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 + - name: Set correct helm version + if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' + run: ./get_helm.sh -v v2.12.3 - name: Pulling old images, if any run: docker-compose pull --ignore-pull-failures - name: Setting APP_ENV to dev @@ -72,7 +75,7 @@ jobs: echo "##[set-output name=success]true" else echo "##[set-output name=success]false" - fi + fi - name: Deploy through helm if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true From 5dfe8ea64203e4da57f8ef0d457a91df03a3c403 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 27 Nov 2019 14:01:44 +0100 Subject: [PATCH 037/125] Removing problematic condition from code --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 11736f5e..f5087182 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Set correct helm version - if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' + if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) run: ./get_helm.sh -v v2.12.3 - name: Pulling old images, if any run: docker-compose pull --ignore-pull-failures From aedb339c2cf2f7f67096ff2e518f4437cffa3e8f Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 27 Nov 2019 15:10:45 +0100 Subject: [PATCH 038/125] Adding conditional upgrade instead of install --- .github/workflows/dockerimage.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 66b6eb8c..f1521ee7 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -77,5 +77,13 @@ jobs: if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' run: helm init --upgrade --kubeconfig="kubeconfig.yaml" - name: Deploy through helm + - name: Deploy through helm + id: helm-install if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' + run: | + helm install pc-$APP_ENV ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true + echo "##[set-output name=status-code]$?" + continue-on-error: true + - name: Deploy through helm upgrade + if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' && steps.helm-install.ouputs.status-code!=0 run: helm upgrade pc-$APP_ENV ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true From 93143d94af4fd2dacde15ce1ffec09d3c39bfb2d Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 27 Nov 2019 15:14:47 +0100 Subject: [PATCH 039/125] Some fixes --- .github/workflows/dockerimage.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index f1521ee7..a39144e6 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -76,14 +76,13 @@ jobs: - name: Set correct helm version if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' run: helm init --upgrade --kubeconfig="kubeconfig.yaml" - - name: Deploy through helm - name: Deploy through helm id: helm-install if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' run: | - helm install pc-$APP_ENV ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true + helm install pc-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true echo "##[set-output name=status-code]$?" continue-on-error: true - name: Deploy through helm upgrade if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' && steps.helm-install.ouputs.status-code!=0 - run: helm upgrade pc-$APP_ENV ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true + run: helm upgrade pc-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true From d9d1e2fecfc8b33dbc8967468baa6212340f704b Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 20:20:27 +0100 Subject: [PATCH 040/125] Test for helm install backup --- .github/workflows/dockerimage.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 529514cf..254b6999 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -79,3 +79,6 @@ jobs: - name: Deploy through helm if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' run: helm upgrade pc-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true + - name: Install through helm + if: failure() + run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 From 0ef9cce5577c7391761061f8a4959dee60fa7112 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 20:32:46 +0100 Subject: [PATCH 041/125] Fix on APP_NAME --- .github/workflows/dockerimage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 254b6999..4adbce8d 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -78,7 +78,7 @@ jobs: run: helm init --upgrade --kubeconfig="kubeconfig.yaml" - name: Deploy through helm if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' - run: helm upgrade pc-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true + run: helm upgrade ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true - name: Install through helm if: failure() - run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 + run: helm install --name ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=APP_ENV,settings.debug=1 From 97905f565e2f344044e7b83c58dbb412941dd083 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 20:39:40 +0100 Subject: [PATCH 042/125] Added rolling restart --- .github/workflows/dockerimage.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 4adbce8d..d5ff70ad 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -82,3 +82,6 @@ jobs: - name: Install through helm if: failure() run: helm install --name ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=APP_ENV,settings.debug=1 + - name: Rollout new containers + if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' + run: kubectl rollout restart --kubeconfig="kubeconfig.yaml" From 97c28bbd8c84b98ad3944e648d124a8cc57fdf20 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 20:40:26 +0100 Subject: [PATCH 043/125] bugfix --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index d5ff70ad..17c833da 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -81,7 +81,7 @@ jobs: run: helm upgrade ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true - name: Install through helm if: failure() - run: helm install --name ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=APP_ENV,settings.debug=1 + run: helm install --name ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=APP_ENV,settings.debug=1 - name: Rollout new containers if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' run: kubectl rollout restart --kubeconfig="kubeconfig.yaml" From 2b01afe1f0a0820a482ad84fcd6dba0d50ae2815 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 27 Nov 2019 20:40:26 +0100 Subject: [PATCH 044/125] bugfix --- .github/workflows/dockerimage.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index d5ff70ad..d2c5a329 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -81,7 +81,7 @@ jobs: run: helm upgrade ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true - name: Install through helm if: failure() - run: helm install --name ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=APP_ENV,settings.debug=1 - - name: Rollout new containers - if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' - run: kubectl rollout restart --kubeconfig="kubeconfig.yaml" + run: helm install --name ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=APP_ENV,settings.debug=1 + # - name: Rollout new containers + # if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' + # run: kubectl rollout restart --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV From 8ebae01e6e962201d95735f88d52fd84e4f3b5ab Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Thu, 28 Nov 2019 07:08:16 +0100 Subject: [PATCH 045/125] Removed default load balancer --- .github/workflows/dockerimage.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 4818c59c..ffb94a4e 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -79,10 +79,10 @@ jobs: - name: Deploy through helm id: helm-install if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' - run: helm upgrade ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true + run: helm upgrade ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - name: Install through helm if: failure() run: helm install --name ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=APP_ENV,settings.debug=1 - # - name: Rollout new containers - # if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' - # run: kubectl rollout restart --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV + - name: Rollout new containers + if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' + run: kubectl rollout restart --kubeconfig="kubeconfig.yaml" From b2e78533efb43804b0fbcac8dc4c860f49496975 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Thu, 28 Nov 2019 15:37:09 +0100 Subject: [PATCH 046/125] Added rollout --- .github/workflows/dockerimage.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index ffb94a4e..4ee3a2c6 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -85,4 +85,7 @@ jobs: run: helm install --name ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=APP_ENV,settings.debug=1 - name: Rollout new containers if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' - run: kubectl rollout restart --kubeconfig="kubeconfig.yaml" + run: | + kubectl rollout restart deployment/${{ secrets.APP_NAME }}-php --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV + kubectl rollout restart deployment/${{ secrets.APP_NAME }}-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV + kubectl rollout restart deployment/${{ secrets.APP_NAME }}-varnish --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV From eedca34c3769bfe31eb6c1bf17ec494dde078f11 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Thu, 28 Nov 2019 15:41:33 +0100 Subject: [PATCH 047/125] bug fix --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 4ee3a2c6..ded88c92 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -82,7 +82,7 @@ jobs: run: helm upgrade ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - name: Install through helm if: failure() - run: helm install --name ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=APP_ENV,settings.debug=1 + run: helm install --name ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - name: Rollout new containers if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' run: | From d7eee6f8930da95eb9a6bb7d317d40bc4e947245 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Thu, 28 Nov 2019 16:51:41 +0100 Subject: [PATCH 048/125] Changes to docs --- api/src/Entity/Property.php | 413 +-------------------------------- api/src/Entity/RequestType.php | 51 +--- 2 files changed, 7 insertions(+), 457 deletions(-) diff --git a/api/src/Entity/Property.php b/api/src/Entity/Property.php index a1fc67f1..0acc3a0d 100644 --- a/api/src/Entity/Property.php +++ b/api/src/Entity/Property.php @@ -34,19 +34,8 @@ class Property /** * @var \Ramsey\Uuid\UuidInterface $id The UUID identifier of this object * @example e2984465-190a-4562-829e-a8cca81aa35d - * - * @ApiProperty( - * identifier=true, - * attributes={ - * "swagger_context"={ - * "description" = "The UUID identifier of this object", - * "type"="string", - * "format"="uuid", - * "example"="e2984465-190a-4562-829e-a8cca81aa35d" - * } - * } - * ) - * + * + * @Groups({"read"}) * @Assert\Uuid * @ORM\Id * @ORM\Column(type="uuid", unique=true) @@ -69,20 +58,7 @@ class Property /** * @var string $title The title of this property * @example My Property - * - * @ApiProperty( - * iri="http://schema.org/name", - * attributes={ - * "swagger_context"={ - * "description" = "The title of this property", - * "type"="string", - * "example"="My Property", - * "maxLength"="15", - * "maxLength"="255", - * "required" = true - * } - * } - * ) + * * @Assert\NotBlank * @Assert\Length(min = 15, max = 255) * @Groups({"read", "write"}) @@ -90,23 +66,10 @@ class Property */ private $title; - /** * + /** * @var string $name The name of the property as used in api calls, extracted from title on snake_case basis * @example my_property - * - * @ApiProperty( - * iri="http://schema.org/name", - * attributes={ - * "swagger_context"={ - * "description" = "The name of the property as used in api calls, extracted from title on snake_case basis", - * "type"="string", - * "example"="my_property", - * "maxLength"="15", - * "maxLength"="255", - * "required" = true - * } - * } - * ) + * * @Groups({"read"}) */ private $name; @@ -114,19 +77,6 @@ class Property /** * @var string $type The type of this property * @example string - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "The type of this property", - * "type"="string", - * "example"="string", - * "enum"={"string", "integer", "boolean", "number","array"}, - * "maxLength"="255", - * "required" = true - * } - * } - * ) * * @Assert\NotBlank * @Assert\Length(max = 255) @@ -139,19 +89,6 @@ class Property /** * @var string $type The swagger type of the property as used in api calls * @example string - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "The swagger type of the property as used in api calls", - * "type"="string", - * "example"="string", - * "enum"={"int32","int64","float","double","byte","binary","date","duration","date-time","password","boolean","string","uuid","uri","email","rsin","bag","bsn","iban","challenge","service","assent"}, - * "maxLength"="255", - * "required" = true - * } - * } - * ) * * @Assert\NotBlank * @Assert\Length(max = 255) @@ -164,17 +101,6 @@ class Property /** * @var string $multipleOf *Can only be used in combination with type integer* Specifies a number where the value should be a multiple of, e.g. a multiple of 2 would validate 2,4 and 6 but would prevent 5 * @example 2 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*Can only be used in combination with type integer* Specifies a number where the value should be a multiple of, e.g. a multiple of 2 would validate 2,4 and 6 but would prevent 5", - * "type"="integer", - * "example"="2", - * "maxLength"="255" - * } - * } - * ) * * @Assert\Type("integer") * @Groups({"read", "write"}) @@ -185,17 +111,6 @@ class Property /** * @var string $multipleOf *Can only be used in combination with type integer* The maximum allowed value * @example 2 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*Can only be used in combination with type integer* The maximum allowed value", - * "type"="integer", - * "example"="2", - * "maxLength"="255" - * } - * } - * ) * * @Assert\Type("integer") * @Groups({"read", "write"}) @@ -206,16 +121,6 @@ class Property /** * @var string $exclusiveMaximum *Can only be used in combination with type integer* Defines if the maximum is exclusive, e.g. a exclusive maximum of 5 would invalidate 5 but validate 4 * @example true - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*Can only be used in combination with type integer* Defines if the maximum is exclusive, e.g. a exclusive maximum of 5 would invalidate 5 but validate 4", - * "type"="boolean", - * "example"=true - * } - * } - * ) * * @Assert\Type("bool") * @Groups({"read", "write"}) @@ -226,17 +131,6 @@ class Property /** * @var string $minimum *Can only be used in combination with type integer* The minimum allowed value * @example 2 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*Can only be used in combination with type integer* The minimum allowed value", - * "type"="integer", - * "example"="2", - * "maxLength"="255" - * } - * } - * ) * * @Assert\Type("integer") * @Groups({"read", "write"}) @@ -248,16 +142,6 @@ class Property * * @var string $exclusiveMinimum *Can only be used in combination with type integer* Defines if the minimum is exclusive, e.g. a exclusive minimum of 5 would invalidate 5 but validate 6 * @example true - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*Can only be used in combination with type integer* Defines if the minimum is exclusive, e.g. a exclusive minimum of 5 would invalidate 5 but validate 4", - * "type"="boolean", - * "example"=true - * } - * } - * ) * * @Assert\Type("bool") * @Groups({"read", "write"}) @@ -268,16 +152,6 @@ class Property /** * @var string $maxLength The maximum amount of characters in the value * @example 2 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "The maximum amount of characters in the value", - * "type"="integer", - * "example"="2" - * } - * } - * ) * * @Assert\Type("integer") * @Groups({"read", "write"}) @@ -288,16 +162,6 @@ class Property /** * @var string $minLength The minimal amount of characters in the value * @example 2 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "The minimal amount of characters in the value", - * "type"="integer", - * "example"="2" - * } - * } - * ) * * @Assert\Type("integer") * @Groups({"read", "write"}) @@ -308,17 +172,6 @@ class Property /** * @var string $pattern A [regular expression](https://en.wikipedia.org/wiki/Regular_expression) that the value should comply to * @example [+-]?(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)? - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "A [regular expression](https://en.wikipedia.org/wiki/Regular_expression) that the value should comply to", - * "type"="string", - * "example"="[+-]?(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?", - * "maxLength"="255" - * } - * } - * ) * * @Assert\Length(max = 255) * @Groups({"read", "write"}) @@ -345,17 +198,6 @@ class Property /** * @var string $maxItems *Can only be used in combination with type array* The maximum array length * @example 2 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*Can only be used in combination with type array* The maximum array length ", - * "type"="integer", - * "example"="2", - * "maxLength"="255" - * } - * } - * ) * * @Assert\Type("integer") * @Groups({"read", "write"}) @@ -366,17 +208,6 @@ class Property /** * @var string $minItems *Can only be used in combination with type array* The minimum allowed value * @example 2 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*Can only be used in combination with type array* The minimum allowed value", - * "type"="integer", - * "example"="2", - * "maxLength"="255" - * } - * } - * ) * * @Assert\Type("integer") * @Groups({"read", "write"}) @@ -387,16 +218,6 @@ class Property /** * @var boolean $uniqueItems *Can only be used in combination with type array* Define whether or not values in an array should be unique * @example false - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*Can only be used in combination with type array* Define whether or not values in an array should be unique", - * "type"="boolean", - * "example"=false - * } - * } - * ) * * @Assert\Type("bool") * @Groups({"read", "write"}) @@ -407,17 +228,6 @@ class Property /** * @var string $maxProperties *Can only be used in combination with type integer* The maximum amount of properties an object should contain * @example 2 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*Can only be used in combination with type integer* The maximum amount of properties an object should contain", - * "type"="integer", - * "example"="2", - * "maxLength"="255" - * } - * } - * ) * * @Assert\Type("integer") * @Groups({"read", "write"}) @@ -428,17 +238,6 @@ class Property /** * @var string $minProperties *Can only be used in combination with type object* The minimum amount of properties an object should contain * @example 2 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*Can only be used in combination with type object* The minimum amount of properties an object should contain", - * "type"="integer", - * "example"="2", - * "maxLength"="255" - * } - * } - * ) * * @Assert\Type("integer") * @Groups({"read", "write"}) @@ -449,16 +248,6 @@ class Property /** * @var boolean $required Only whether or not this property is required * @example false - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "Whether or not this property is required", - * "type"="boolean", - * "example"=false - * } - * } - * ) * * @Assert\Type("bool") * @Groups({"read", "write"}) @@ -493,16 +282,6 @@ class Property /** * @var array $enum An array of possible values, input is limited to this array * @example ['first','second] - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "An array of possible values, input is limited to this array", - * "type"="array", - * "example"="['first','second]'" - * } - * } - * ) * * @Groups({"read", "write"}) * @ORM\Column(type="array", nullable=true) @@ -512,16 +291,6 @@ class Property /** * @var array $allOf *mutually exclusive with using type* An array of possible types that an property should confirm to * @example ['string','boolean'] - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*mutually exclusive with using type* An array of possible types that an property should confirm to", - * "type"="array", - * "example"="['string','boolean']" - * } - * } - * ) * * @ORM\Column(type="array", nullable=true) */ @@ -530,16 +299,6 @@ class Property /** * @var array $anyOf *mutually exclusive with using type* An array of possible types that an property might confirm to * @example ['string','boolean'] - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*mutually exclusive with using type* An array of possible types that an property might confirm to", - * "type"="array", - * "example"="['string','boolean']" - * } - * } - * ) * * @ORM\Column(type="array", nullable=true) */ @@ -548,16 +307,6 @@ class Property /** * @var array $oneOf *mutually exclusive with using type* An array of possible types that an property must confirm to * @example ['string','boolean'] - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*mutually exclusive with using type* An array of possible types that an property must confirm to", - * "type"="array", - * "example"="['string','boolean']" - * } - * } - * ) * * @ORM\Column(type="array", nullable=true) */ @@ -573,17 +322,6 @@ class Property /** * @var string $description An description of the value asked, supports markdown syntax as described by [CommonMark 0.27.](https://spec.commonmark.org/0.27/) * @example My value - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "An description of the value asked, supports markdown syntax as described by [CommonMark 0.27.](https://spec.commonmark.org/0.27/)", - * "type"="string", - * "example"="My value", - * "maxLength"="2555" - * } - * } - * ) * * @Groups({"read", "write"}) * @ORM\Column(type="text", nullable=true) @@ -593,17 +331,6 @@ class Property /** * @var string $defaultValue An default value for this value that will be used if a user doesn't supply a value * @example My value - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "An default value for this value that will be used if a user doesn't supply a value", - * "type"="string", - * "example"="My value", - * "maxLength"="255" - * } - * } - * ) * * @Assert\Length(max = 255) * @Groups({"read", "write"}) @@ -615,16 +342,6 @@ class Property /** * @var boolean $nullable Whether or not this property can be left empty * @example false - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "Whether or not this property can be left empty", - * "type"="boolean", - * "example"=false - * } - * } - * ) * * @Assert\Type("bool") * @Groups({"read", "write"}) @@ -635,17 +352,6 @@ class Property /** * @var string $discriminator To help API consumers detect the object type, you can add the discriminator/propertyName keyword to model definitions. This keyword points to the property that specifies the data type name * @example name - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "To help API consumers detect the object type, you can add the discriminator/propertyName keyword to model definitions. This keyword points to the property that specifies the data type name", - * "type"="string", - * "example"="name", - * "maxLength"="255" - * } - * } - * ) * * @Assert\Length(max = 255) * @Groups({"read", "write"}) @@ -656,16 +362,6 @@ class Property /** * @var boolean $readOnly Whether or not this property is read only * @example false - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "Whether or not this property is read only", - * "type"="boolean", - * "example"=false - * } - * } - * ) * * @Assert\Type("bool") * @Groups({"read", "write"}) @@ -676,16 +372,6 @@ class Property /** * @var boolean $writeOnly Whether or not this property is write only * @example false - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "Whether or not this property is wite only", - * "type"="boolean", - * "example"=false - * } - * } - * ) * * @Assert\Type("bool") * @Groups({"read", "write"}) @@ -696,18 +382,6 @@ class Property /** * @var string $xml An XML representation of the swagger docs * @example - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "An XML representation of the swagger docs", - * "type"="string", - * "format"="xml", - * "example"="", - * "maxLength"="255" - * } - * } - * ) * * @Groups({"read", "write"}) * @ORM\Column(type="text", nullable=true) @@ -717,18 +391,6 @@ class Property /** * @var string $externalDoc An link to any external documentation for the value * @example https://www.w3.org/TR/NOTE-datetime - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "An link to any external documentation for the value", - * "type"="string", - * "format"="url", - * "example"="https://www.w3.org/TR/NOTE-datetime", - * "maxLength"="255" - * } - * } - * ) * * @Assert\Length(max = 255) * @Groups({"read", "write"}) @@ -739,17 +401,6 @@ class Property /** * @var string $example An example of the value that should be supplied * @example My value - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "An example of the value that should be supplied", - * "type"="string", - * "example"="My value", - * "maxLength"="255" - * } - * } - * ) * * @Assert\Length(max = 255) * @Groups({"read", "write"}) @@ -760,16 +411,6 @@ class Property /** * @var boolean $deprecated Whether or not this property has been deprecated and wil be removed in the future * @example false - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "Whether or not this property has been deprecated and wil be removed in the future", - * "type"="boolean", - * "example"=false - * } - * } - * ) * * @Assert\Type("bool") * @Groups({"read", "write"}) @@ -780,17 +421,6 @@ class Property /** * @var string $availableUntil The moment from which this value is available * @example 2019-09-16T14:26:51+00:00 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "The moment from which this value is available", - * "type"="string", - * "format"="date-time", - * "example"="2019-09-16T14:26:51+00:00" - * } - * } - * ) * * @Groups({"read", "write"}) * @Assert\DateTime @@ -801,17 +431,6 @@ class Property /** * @var string $availableUntil *should be used in combination with deprecated* The moment where until this value is available * @example 2019-09-16T14:26:51+00:00 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "*should be used in combination with deprecated* The moment where until this value is available", - * "type"="string", - * "format"="date-time", - * "example"="2019-09-16T14:26:51+00:00" - * } - * } - * ) * * @Groups({"read", "write"}) * @Assert\DateTime @@ -822,17 +441,6 @@ class Property /** * @var string $minDate The minimal date for value, either a date, datetime or duration (ISO_8601) * @example 2019-09-16T14:26:51+00:00 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "The minimal date for value, either a date, datetime or duration (ISO_8601)", - * "type"="string", - * "example"="2019-09-16T14:26:51+00:00", - * "maxLength"="255" - * } - * } - * ) * * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255, nullable=true) @@ -842,17 +450,6 @@ class Property /** * @var string $maxDate The maximum date for value, either a date, datetime or duration (ISO_8601) * @example 2019-09-16T14:26:51+00:00 - * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "The maximum date for value, either a date, datetime or duration (ISO_8601)", - * "type"="string", - * "example"="2019-09-16T14:26:51+00:00", - * "maxLength"="255" - * } - * } - * ) * * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255, nullable=true) diff --git a/api/src/Entity/RequestType.php b/api/src/Entity/RequestType.php index bbebd23c..70779215 100644 --- a/api/src/Entity/RequestType.php +++ b/api/src/Entity/RequestType.php @@ -48,19 +48,8 @@ class RequestType /** * @var \Ramsey\Uuid\UuidInterface $id The UUID identifier of this object * @example e2984465-190a-4562-829e-a8cca81aa35d - * - * @ApiProperty( - * identifier=true, - * attributes={ - * "swagger_context"={ - * "description" = "The UUID identifier of this object", - * "type"="string", - * "format"="uuid", - * "example"="e2984465-190a-4562-829e-a8cca81aa35d" - * } - * } - * ) - * + * + * @Groups({"read"}) * @Assert\Uuid * @ORM\Id * @ORM\Column(type="uuid", unique=true) @@ -73,17 +62,6 @@ class RequestType * @var string $sourceOrganization The RSIN of the organization that owns this process * @example 002851234 * - * @ApiProperty( - * attributes={ - * "swagger_context"={ - * "description" = "The RSIN of the organization that owns this process", - * "type"="string", - * "example"="002851234", - * "maxLength"="255" - * } - * } - * ) - * * @Assert\NotNull * @Assert\Length( * min = 8, @@ -98,19 +76,6 @@ class RequestType /** * @var string $name The name of this RequestType * @example My RequestType - * - * @ApiProperty( - * iri="http://schema.org/name", - * attributes={ - * "swagger_context"={ - * "description" = "The name of this RequestType", - * "type"="string", - * "example"="My RequestType", - * "maxLength"="255", - * "required" = true - * } - * } - * ) * * @Assert\NotNull * @Assert\Length( @@ -124,18 +89,6 @@ class RequestType /** * @var string $description An short description of this RequestType * @example This is the best request ever - * - * @ApiProperty( - * iri="https://schema.org/description", - * attributes={ - * "swagger_context"={ - * "description" = "An short description of this RequestType", - * "type"="string", - * "example"="This is the best request ever", - * "maxLength"="2550" - * } - * } - * ) * * @Assert\Length( * max = 2550 From 2c133d71ef99ce81045c6c4b6690367c7a2cc2e3 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Thu, 28 Nov 2019 16:53:44 +0100 Subject: [PATCH 049/125] Bug fix for when a property has no groups --- api/src/Swagger/SwaggerDecorator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index 045ef50c..02e872d2 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -407,6 +407,7 @@ private function getAdditionalEntityDocs($entity) $docblock = $factory->create($property->getDocComment()); $tags = $docblock->getTags(); $atributes = []; + $groups = []; foreach ($tags as $tag) { $name = $tag->getName(); From 0a9ffab394142144abf8676f73d206fa6b534375 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Fri, 29 Nov 2019 11:40:11 +0100 Subject: [PATCH 050/125] Attempt to revising examples for property. First steps to conform to StyleCI --- api/src/Entity/Property.php | 175 ++++++++++++++++++------------------ 1 file changed, 86 insertions(+), 89 deletions(-) diff --git a/api/src/Entity/Property.php b/api/src/Entity/Property.php index 0acc3a0d..50daa05b 100644 --- a/api/src/Entity/Property.php +++ b/api/src/Entity/Property.php @@ -10,6 +10,7 @@ use Doctrine\Common\Collections\Collection; use Gedmo\Mapping\Annotation as Gedmo; use Doctrine\ORM\Mapping as ORM; +use Ramsey\Uuid\UuidInterface; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Serializer\Annotation\MaxDepth; @@ -19,10 +20,10 @@ /** * This property follows the following schemes (in order of importance) - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md + * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md * https://tools.ietf.org/html/draft-wright-json-schema-validation-00 * http://json-schema.org/ - * + * * @ApiResource( * normalizationContext={"groups"={"read"}, "enable_max_depth"=true}, * denormalizationContext={"groups"={"write"}, "enable_max_depth"=true} @@ -32,10 +33,10 @@ class Property { /** - * @var \Ramsey\Uuid\UuidInterface $id The UUID identifier of this object + * @var UuidInterface The UUID identifier of this object * @example e2984465-190a-4562-829e-a8cca81aa35d - * - * @Groups({"read"}) + * + * @Groups({"read"}) * @Assert\Uuid * @ORM\Id * @ORM\Column(type="uuid", unique=true) @@ -45,37 +46,37 @@ class Property private $id; /** - * @var Object $requestType The requestType that this property belongs to - * + * @var RequestType The requestType that this property belongs to + * * @Assert\NotBlank * @MaxDepth(1) * @Groups({"read", "write"}) * @ORM\ManyToOne(targetEntity="App\Entity\RequestType", inversedBy="properties",cascade={"persist"}) * @ORM\JoinColumn(nullable=false) */ - private $requestType; - + private $requestType; + /** - * @var string $title The title of this property + * @var string The title of this property * @example My Property - * + * * @Assert\NotBlank * @Assert\Length(min = 15, max = 255) * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255) */ private $title; - - /** - * @var string $name The name of the property as used in api calls, extracted from title on snake_case basis + + /** + * @var string The name of the property as used in api calls, extracted from title on snake_case basis * @example my_property - * + * * @Groups({"read"}) */ private $name; - - /** - * @var string $type The type of this property + + /** + * @var string The type of this property * @example string * * @Assert\NotBlank @@ -84,12 +85,12 @@ class Property * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255) */ - private $type; - - /** - * @var string $type The swagger type of the property as used in api calls + private $type; + + /** + * @var string The swagger type of the property as used in api calls * @example string - * + * * @Assert\NotBlank * @Assert\Length(max = 255) * @Assert\Choice({"int32","int64","float","double","byte","binary","date","date-time","duration","password","boolean","string","uuid","uri","email","rsin","bag","bsn","iban","challenge","service","assent"}) @@ -99,9 +100,9 @@ class Property private $format; /** - * @var string $multipleOf *Can only be used in combination with type integer* Specifies a number where the value should be a multiple of, e.g. a multiple of 2 would validate 2,4 and 6 but would prevent 5 + * @var int *Can only be used in combination with type integer* Specifies a number where the value should be a multiple of, e.g. a multiple of 2 would validate 2,4 and 6 but would prevent 5 * @example 2 - * + * * @Assert\Type("integer") * @Groups({"read", "write"}) * @ORM\Column(type="integer", nullable=true) @@ -109,9 +110,9 @@ class Property private $multipleOf; /** - * @var string $multipleOf *Can only be used in combination with type integer* The maximum allowed value + * @var int *Can only be used in combination with type integer* The maximum allowed value * @example 2 - * + * * @Assert\Type("integer") * @Groups({"read", "write"}) * @ORM\Column(type="integer", nullable=true) @@ -121,7 +122,7 @@ class Property /** * @var string $exclusiveMaximum *Can only be used in combination with type integer* Defines if the maximum is exclusive, e.g. a exclusive maximum of 5 would invalidate 5 but validate 4 * @example true - * + * * @Assert\Type("bool") * @Groups({"read", "write"}) * @ORM\Column(type="boolean", nullable=true) @@ -129,9 +130,9 @@ class Property private $exclusiveMaximum; /** - * @var string $minimum *Can only be used in combination with type integer* The minimum allowed value + * @var string $minimum *Can only be used in combination with type integer* The minimum allowed value * @example 2 - * + * * @Assert\Type("integer") * @Groups({"read", "write"}) * @ORM\Column(type="integer", nullable=true) @@ -139,10 +140,10 @@ class Property private $minimum; /** - * - * @var string $exclusiveMinimum *Can only be used in combination with type integer* Defines if the minimum is exclusive, e.g. a exclusive minimum of 5 would invalidate 5 but validate 6 + * + * @var bool *Can only be used in combination with type integer* Defines if the minimum is exclusive, e.g. a exclusive minimum of 5 would invalidate 5 but validate 6 * @example true - * + * * @Assert\Type("bool") * @Groups({"read", "write"}) * @ORM\Column(type="boolean", nullable=true) @@ -150,9 +151,9 @@ class Property private $exclusiveMinimum; /** - * @var string $maxLength The maximum amount of characters in the value + * @var int $maxLength The maximum amount of characters in the value * @example 2 - * + * * @Assert\Type("integer") * @Groups({"read", "write"}) * @ORM\Column(type="integer", nullable=true) @@ -160,9 +161,9 @@ class Property private $maxLength; /** - * @var string $minLength The minimal amount of characters in the value + * @var int $minLength The minimal amount of characters in the value * @example 2 - * + * * @Assert\Type("integer") * @Groups({"read", "write"}) * @ORM\Column(type="integer", nullable=true) @@ -170,9 +171,9 @@ class Property private $minLength; /** - * @var string $pattern A [regular expression](https://en.wikipedia.org/wiki/Regular_expression) that the value should comply to - * @example [+-]?(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)? - * + * @var string A [regular expression](https://en.wikipedia.org/wiki/Regular_expression) that the value should comply to + * @example '[+-]?(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?' + * * @Assert\Length(max = 255) * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255, nullable=true) @@ -181,14 +182,14 @@ class Property /** * Not yet supported by business logic - * + * * @ORM\ManyToMany(targetEntity="App\Entity\Property") */ private $items; /** * Not yet supported by business logic - * + * * @Assert\Type("bool") * @Groups({"read", "write"}) * @ORM\Column(type="boolean", nullable=true) @@ -196,9 +197,9 @@ class Property private $additionalItems; /** - * @var string $maxItems *Can only be used in combination with type array* The maximum array length + * @var int $maxItems *Can only be used in combination with type array* The maximum array length * @example 2 - * + * * @Assert\Type("integer") * @Groups({"read", "write"}) * @ORM\Column(type="integer", nullable=true) @@ -206,9 +207,9 @@ class Property private $maxItems; /** - * @var string $minItems *Can only be used in combination with type array* The minimum allowed value + * @var int $minItems *Can only be used in combination with type array* The minimum allowed value * @example 2 - * + * * @Assert\Type("integer") * @Groups({"read", "write"}) * @ORM\Column(type="integer", nullable=true) @@ -216,9 +217,9 @@ class Property private $minItems; /** - * @var boolean $uniqueItems *Can only be used in combination with type array* Define whether or not values in an array should be unique + * @var boolean *Can only be used in combination with type array* Define whether or not values in an array should be unique * @example false - * + * * @Assert\Type("bool") * @Groups({"read", "write"}) * @ORM\Column(type="boolean", nullable=true) @@ -226,9 +227,9 @@ class Property private $uniqueItems; /** - * @var string $maxProperties *Can only be used in combination with type integer* The maximum amount of properties an object should contain + * @var int $maxProperties *Can only be used in combination with type integer* The maximum amount of properties an object should contain * @example 2 - * + * * @Assert\Type("integer") * @Groups({"read", "write"}) * @ORM\Column(type="integer", nullable=true) @@ -236,9 +237,9 @@ class Property private $maxProperties; /** - * @var string $minProperties *Can only be used in combination with type object* The minimum amount of properties an object should contain + * @var int $minProperties *Can only be used in combination with type object* The minimum amount of properties an object should contain * @example 2 - * + * * @Assert\Type("integer") * @Groups({"read", "write"}) * @ORM\Column(type="integer", nullable=true) @@ -248,7 +249,7 @@ class Property /** * @var boolean $required Only whether or not this property is required * @example false - * + * * @Assert\Type("bool") * @Groups({"read", "write"}) * @ORM\Column(type="boolean", nullable=true) @@ -257,7 +258,7 @@ class Property /** * Not yet supported by business logic - * + * * @Groups({"read", "write"}) * @ORM\Column(type="object", nullable=true) */ @@ -265,7 +266,7 @@ class Property /** * Not yet supported by business logic - * + * * @Groups({"read", "write"}) * @ORM\Column(type="object", nullable=true) */ @@ -273,48 +274,44 @@ class Property /** * Not yet supported by business logic - * + * * @Groups({"read", "write"}) * @ORM\Column(type="object", nullable=true) */ private $object; /** - * @var array $enum An array of possible values, input is limited to this array - * @example ['first','second] - * + * @var array An array of possible values, input is limited to this array + * * @Groups({"read", "write"}) * @ORM\Column(type="array", nullable=true) */ private $enum = []; /** - * @var array $allOf *mutually exclusive with using type* An array of possible types that an property should confirm to - * @example ['string','boolean'] - * + * @var array *mutually exclusive with using type* An array of possible types that an property should confirm to + * * @ORM\Column(type="array", nullable=true) */ private $allOf = []; /** - * @var array $anyOf *mutually exclusive with using type* An array of possible types that an property might confirm to - * @example ['string','boolean'] - * + * @var array *mutually exclusive with using type* An array of possible types that an property might confirm to + * * @ORM\Column(type="array", nullable=true) */ private $anyOf = []; /** - * @var array $oneOf *mutually exclusive with using type* An array of possible types that an property must confirm to - * @example ['string','boolean'] - * + * @var array *mutually exclusive with using type* An array of possible types that an property must confirm to + * * @ORM\Column(type="array", nullable=true) */ private $oneOf = []; /** * Not yet supported by business logic - * + * * @ORM\Column(type="object", nullable=true) */ private $definitions; @@ -322,7 +319,7 @@ class Property /** * @var string $description An description of the value asked, supports markdown syntax as described by [CommonMark 0.27.](https://spec.commonmark.org/0.27/) * @example My value - * + * * @Groups({"read", "write"}) * @ORM\Column(type="text", nullable=true) */ @@ -331,7 +328,7 @@ class Property /** * @var string $defaultValue An default value for this value that will be used if a user doesn't supply a value * @example My value - * + * * @Assert\Length(max = 255) * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255, nullable=true) @@ -342,7 +339,7 @@ class Property /** * @var boolean $nullable Whether or not this property can be left empty * @example false - * + * * @Assert\Type("bool") * @Groups({"read", "write"}) * @ORM\Column(type="boolean", nullable=true) @@ -352,7 +349,7 @@ class Property /** * @var string $discriminator To help API consumers detect the object type, you can add the discriminator/propertyName keyword to model definitions. This keyword points to the property that specifies the data type name * @example name - * + * * @Assert\Length(max = 255) * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255, nullable=true) @@ -362,7 +359,7 @@ class Property /** * @var boolean $readOnly Whether or not this property is read only * @example false - * + * * @Assert\Type("bool") * @Groups({"read", "write"}) * @ORM\Column(type="boolean", nullable=true) @@ -372,7 +369,7 @@ class Property /** * @var boolean $writeOnly Whether or not this property is write only * @example false - * + * * @Assert\Type("bool") * @Groups({"read", "write"}) * @ORM\Column(type="boolean", nullable=true) @@ -381,8 +378,8 @@ class Property /** * @var string $xml An XML representation of the swagger docs - * @example - * + * @example '' + * * @Groups({"read", "write"}) * @ORM\Column(type="text", nullable=true) */ @@ -391,7 +388,7 @@ class Property /** * @var string $externalDoc An link to any external documentation for the value * @example https://www.w3.org/TR/NOTE-datetime - * + * * @Assert\Length(max = 255) * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255, nullable=true) @@ -401,7 +398,7 @@ class Property /** * @var string $example An example of the value that should be supplied * @example My value - * + * * @Assert\Length(max = 255) * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255, nullable=true) @@ -411,7 +408,7 @@ class Property /** * @var boolean $deprecated Whether or not this property has been deprecated and wil be removed in the future * @example false - * + * * @Assert\Type("bool") * @Groups({"read", "write"}) * @ORM\Column(type="boolean", nullable=true) @@ -421,7 +418,7 @@ class Property /** * @var string $availableUntil The moment from which this value is available * @example 2019-09-16T14:26:51+00:00 - * + * * @Groups({"read", "write"}) * @Assert\DateTime * @ORM\Column(type="datetime", nullable=true) @@ -431,7 +428,7 @@ class Property /** * @var string $availableUntil *should be used in combination with deprecated* The moment where until this value is available * @example 2019-09-16T14:26:51+00:00 - * + * * @Groups({"read", "write"}) * @Assert\DateTime * @ORM\Column(type="datetime", nullable=true) @@ -441,7 +438,7 @@ class Property /** * @var string $minDate The minimal date for value, either a date, datetime or duration (ISO_8601) * @example 2019-09-16T14:26:51+00:00 - * + * * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255, nullable=true) */ @@ -450,7 +447,7 @@ class Property /** * @var string $maxDate The maximum date for value, either a date, datetime or duration (ISO_8601) * @example 2019-09-16T14:26:51+00:00 - * + * * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255, nullable=true) */ @@ -465,11 +462,11 @@ public function getId() { return $this->id; } - + public function setId(string $id): self { $this->id = $id; - + return $this; } @@ -491,12 +488,12 @@ public function getTitle(): ?string } public function setTitle(string $title): self - { + { $this->title = $title; return $this; } - + public function getName(): ?string { // titles wil be used as strings so lets convert the to camelcase @@ -504,7 +501,7 @@ public function getName(): ?string $string = trim($string); //removes whitespace at begin and ending $string = preg_replace('/\s+/', '_', $string); // replaces other whitespaces with _ $string = strtolower($string); - + return $string; } From 835c73b2192858f12a4d3c95f1d0c1eaf55967fb Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Fri, 29 Nov 2019 11:41:04 +0100 Subject: [PATCH 051/125] More StyleCI --- api/src/Entity/Property.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/api/src/Entity/Property.php b/api/src/Entity/Property.php index 50daa05b..c4f040db 100644 --- a/api/src/Entity/Property.php +++ b/api/src/Entity/Property.php @@ -317,7 +317,7 @@ class Property private $definitions; /** - * @var string $description An description of the value asked, supports markdown syntax as described by [CommonMark 0.27.](https://spec.commonmark.org/0.27/) + * @var string An description of the value asked, supports markdown syntax as described by [CommonMark 0.27.](https://spec.commonmark.org/0.27/) * @example My value * * @Groups({"read", "write"}) @@ -326,7 +326,7 @@ class Property private $description; /** - * @var string $defaultValue An default value for this value that will be used if a user doesn't supply a value + * @var string An default value for this value that will be used if a user doesn't supply a value * @example My value * * @Assert\Length(max = 255) @@ -337,7 +337,7 @@ class Property /** - * @var boolean $nullable Whether or not this property can be left empty + * @var boolean Whether or not this property can be left empty * @example false * * @Assert\Type("bool") @@ -347,7 +347,7 @@ class Property private $nullable; /** - * @var string $discriminator To help API consumers detect the object type, you can add the discriminator/propertyName keyword to model definitions. This keyword points to the property that specifies the data type name + * @var string To help API consumers detect the object type, you can add the discriminator/propertyName keyword to model definitions. This keyword points to the property that specifies the data type name * @example name * * @Assert\Length(max = 255) @@ -357,7 +357,7 @@ class Property private $discriminator; /** - * @var boolean $readOnly Whether or not this property is read only + * @var boolean Whether or not this property is read only * @example false * * @Assert\Type("bool") @@ -367,7 +367,7 @@ class Property private $readOnly; /** - * @var boolean $writeOnly Whether or not this property is write only + * @var boolean Whether or not this property is write only * @example false * * @Assert\Type("bool") @@ -377,7 +377,7 @@ class Property private $writeOnly; /** - * @var string $xml An XML representation of the swagger docs + * @var string An XML representation of the swagger docs * @example '' * * @Groups({"read", "write"}) @@ -386,7 +386,7 @@ class Property private $xml; /** - * @var string $externalDoc An link to any external documentation for the value + * @var string An link to any external documentation for the value * @example https://www.w3.org/TR/NOTE-datetime * * @Assert\Length(max = 255) @@ -396,7 +396,7 @@ class Property private $externalDoc; /** - * @var string $example An example of the value that should be supplied + * @var string An example of the value that should be supplied * @example My value * * @Assert\Length(max = 255) @@ -406,7 +406,7 @@ class Property private $example; /** - * @var boolean $deprecated Whether or not this property has been deprecated and wil be removed in the future + * @var boolean Whether or not this property has been deprecated and wil be removed in the future * @example false * * @Assert\Type("bool") @@ -416,7 +416,7 @@ class Property private $deprecated; /** - * @var string $availableUntil The moment from which this value is available + * @var string The moment from which this value is available * @example 2019-09-16T14:26:51+00:00 * * @Groups({"read", "write"}) @@ -426,7 +426,7 @@ class Property private $availableFrom; /** - * @var string $availableUntil *should be used in combination with deprecated* The moment where until this value is available + * @var string *should be used in combination with deprecated* The moment where until this value is available * @example 2019-09-16T14:26:51+00:00 * * @Groups({"read", "write"}) @@ -436,7 +436,7 @@ class Property private $availableUntil; /** - * @var string $minDate The minimal date for value, either a date, datetime or duration (ISO_8601) + * @var string The minimal date for value, either a date, datetime or duration (ISO_8601) * @example 2019-09-16T14:26:51+00:00 * * @Groups({"read", "write"}) @@ -445,7 +445,7 @@ class Property private $minDate; /** - * @var string $maxDate The maximum date for value, either a date, datetime or duration (ISO_8601) + * @var string The maximum date for value, either a date, datetime or duration (ISO_8601) * @example 2019-09-16T14:26:51+00:00 * * @Groups({"read", "write"}) From e9feaa3e15dd283a5c2523bba4016c0c10d71f43 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 10:41:02 +0100 Subject: [PATCH 052/125] Testing with setting environment variable from .env --- .github/workflows/test.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..0455bf49 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,21 @@ +name: Test + +on: + pull_request: + branches: + - dev-robert + push: + branches: + - dev-robert + +jobs: + + build: + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - run: | + echo ::set-env name APP_BUILD::$(grep APP_VERSION= .env | cut -d '=' -f2) + echo echo "set APP_BUILD to $APP_BUILD" + From dc47c2731175eaa37a9338e1c5ef844c35d7b2ae Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 10:42:28 +0100 Subject: [PATCH 053/125] Fix on syntax --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0455bf49..5456956d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,6 +16,6 @@ jobs: steps: - uses: actions/checkout@v1 - run: | - echo ::set-env name APP_BUILD::$(grep APP_VERSION= .env | cut -d '=' -f2) + echo ::set-env name=APP_BUILD::$(grep APP_VERSION= .env | cut -d '=' -f2) echo echo "set APP_BUILD to $APP_BUILD" From 1e7f393e1ccf9fe11ebc3dd8ffc8f7e35b65ee15 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 10:47:47 +0100 Subject: [PATCH 054/125] More testing with GREP --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5456956d..8ffbed08 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 + - run: grep APP_VERSION= .env - run: | echo ::set-env name=APP_BUILD::$(grep APP_VERSION= .env | cut -d '=' -f2) echo echo "set APP_BUILD to $APP_BUILD" From d7c4b61ddab17e2a9b834661d38f8fafaa3f10e8 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 10:49:41 +0100 Subject: [PATCH 055/125] Even more testing --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8ffbed08..1416c067 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - run: grep APP_VERSION= .env + - run: grep APP_VERSION= .env | cut -d '=' -f2 - run: | echo ::set-env name=APP_BUILD::$(grep APP_VERSION= .env | cut -d '=' -f2) echo echo "set APP_BUILD to $APP_BUILD" From f22b4064a6db25bdc10c47fdef72478661e43d56 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 10:53:05 +0100 Subject: [PATCH 056/125] Export instead of set:: --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1416c067..37b67f81 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,6 @@ jobs: - uses: actions/checkout@v1 - run: grep APP_VERSION= .env | cut -d '=' -f2 - run: | - echo ::set-env name=APP_BUILD::$(grep APP_VERSION= .env | cut -d '=' -f2) + export APP_BUILD=$(grep APP_VERSION= .env | cut -d '=' -f2) echo echo "set APP_BUILD to $APP_BUILD" From e73549da0a70acd4a4f6cd9531a99f023a429238 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 10:54:25 +0100 Subject: [PATCH 057/125] Passing between steps? --- .github/workflows/dockerimage.yml | 2 +- .github/workflows/test.yml | 1 + .idea/workspace.xml | 39 ++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index ded88c92..77feb89b 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -38,7 +38,7 @@ jobs: - name: Print definitive APP_ENV run: echo "APP_ENV is now $APP_ENV" - name: Build the Docker image - run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV + run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV APP_BUILD=$APP_BUILD - name: Run the docker image run: docker-compose up -d - name: Taking some sleep diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 37b67f81..8736609f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,4 +19,5 @@ jobs: - run: | export APP_BUILD=$(grep APP_VERSION= .env | cut -d '=' -f2) echo echo "set APP_BUILD to $APP_BUILD" + - run: echo "APP_BUILD is now $APP_BUILD" diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 63cda310..8f27ec44 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,8 +1,9 @@ - + + @@ -226,6 +255,10 @@ - \ No newline at end of file From 8a0bb6983e88b8d51c19679343bd83dbbdc1b45d Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 11:05:41 +0100 Subject: [PATCH 058/125] export to set-env --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8736609f..73e2c532 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,8 @@ jobs: - uses: actions/checkout@v1 - run: grep APP_VERSION= .env | cut -d '=' -f2 - run: | - export APP_BUILD=$(grep APP_VERSION= .env | cut -d '=' -f2) - echo echo "set APP_BUILD to $APP_BUILD" + export VERSION=$(grep APP_VERSION= .env | cut -d '=' -f2) + echo ::set-env name=APP_BUILD::$VERSION + echo "set APP_BUILD to $APP_BUILD" - run: echo "APP_BUILD is now $APP_BUILD" From 8066e7afb597da94d2b8fc3a95fe56d46ee69d28 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Mon, 2 Dec 2019 11:22:16 +0100 Subject: [PATCH 059/125] Updates on the design desicions --- DESIGN.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 34ff5696..01221282 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -36,7 +36,7 @@ Welcome, you are currently viewing the design decisions for the proto component. The European factor ------- -The proto-component isn't just a Dutch Component, it is in essence a Dutch translation of European components, nowhere is this more obvious than in the core code. Our component is based on [API Platform](https://api-platform.com/) an API specific version of the symfony framework. This framework is build by the lovely people of []() and is build with support of the European Commission trough the [EU-FOSSA Hackathon](https://ec.europa.eu/info/news/first-eu-fossa-hackathon-it-happened-2019-may-03_en) and Digital Ocean trough [Hacktoberfest](https://hacktoberfest.digitalocean.com/). +The proto-component isn't just a Dutch Component, it is in essence a Dutch translation of European components, nowhere is this more obvious than in the core code. Our component is based on [API Platform](https://api-platform.com/) an API specific version of the symfony framework. This framework is build by the lovely people of [Les Tilleuls](https://les-tilleuls.coop/en) and is build with support of the European Commission trough the [EU-FOSSA Hackathon](https://ec.europa.eu/info/news/first-eu-fossa-hackathon-it-happened-2019-may-03_en) and Digital Ocean trough [Hacktoberfest](https://hacktoberfest.digitalocean.com/). But it doesn't just end there. The [varnish container](https://hub.docker.com/r/eeacms/varnish/) that we use to speed up the API response is build and maintained by [EEA]() (The European Environment Agency) and the development team at conduction itself is attached to the [Odyssey program](https://www.odyssey.org/) and originated from the [startupinresidence](https://startupinresidence.com/) program. @@ -46,11 +46,13 @@ On standards and standardization ------- The specific goal of the proto component (which this current code base is a version of) is to provide a common architecture for common ground components. As such the common ground principles are leading in design choices, and within those principles international compliancy and technological invocation is deemed most important. **We do not want to make concessions to the current infrastructure.** As such the component might differ on [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie), [NORA](https://www.noraonline.nl/wiki/Standaarden), [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/index) and or other standards if they are deemed incompatible or out of line with (inter)national standards and or good practices. -Unfortunatly (inter)national standards standards can be conflicting. We therefore prioritize standards on two grounds +Unfortunatly (inter)national standards standards can be conflicting. We therefore prioritize standards on sevarl grounds -- International standards are put before local standards +- International is put before local - Standards caried by a standard organisation (like ISO, W3C etc) at put before floating standards (like RFC's) wichs are put before industraty standards, good practices and so on. +So if for instance a **local** standard is out of line with an **internation** good practice we follow the international good practice. + ### Commonground specific standards This component was designed in line with the [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie), [NORA](https://www.noraonline.nl/wiki/Standaarden), [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/index), [commonground principles](https://vng.nl/onderwerpenindex/bestuur/samen-organiseren-2019/common-ground). From 30f752eb1358d80056a98eb4919dcde550219887 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 11:23:54 +0100 Subject: [PATCH 060/125] Set APP_BUILD --- .github/workflows/dockerimage.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 77feb89b..df6a1ae8 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -24,16 +24,24 @@ jobs: - name: Setting APP_ENV to dev run: | echo ::set-env name=APP_ENV::dev + echo ::set-env name=APP_BUILD::dev echo "set APP_ENV to $APP_ENV" - name: Setting APP_ENV to prod if: contains( github.ref, 'master' ) || contains( github.base_ref, 'master' ) run: | echo ::set-env name=APP_ENV::prod echo "set APP_ENV to $APP_ENV" + - name: Set APP_BUILD to APP_VERSION + if: contains( github.ref, 'master' ) + run: | + export VERSION=$(grep APP_VERSION= .env | cut -d '=' -f2) + echo ::set-env name=APP_BUILD::$VERSION + echo "set APP_BUILD to $APP_BUILD" - name: Setting APP_ENV to stag if: contains( github.ref, 'staging' ) || contains( github.base_ref, 'staging' ) run: | echo ::set-env name=APP_ENV::stag + echo ::set-env name=APP_BUILD::stag echo "set APP_ENV to $APP_ENV" - name: Print definitive APP_ENV run: echo "APP_ENV is now $APP_ENV" From 764b61a0a0d073cbec16d9725256955f7dc144fa Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 11:25:56 +0100 Subject: [PATCH 061/125] APP NAME testen --- .github/workflows/dockerimage.yml | 5 +++++ .github/workflows/test.yml | 4 ++++ .idea/workspace.xml | 15 +++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index df6a1ae8..35a1ff59 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -21,6 +21,11 @@ jobs: - uses: actions/checkout@v1 - name: Pulling old images, if any run: docker-compose pull --ignore-pull-failures + - name: Setting APP_NAME + run: | + export NAME=$(grep APP_NAME= .env | cut -d '=' -f2) + echo ::set-env name=APP_NAME::$NAME + echo "set APP_NAME to $APP_NAME" - name: Setting APP_ENV to dev run: | echo ::set-env name=APP_ENV::dev diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73e2c532..f7f59574 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,4 +21,8 @@ jobs: echo ::set-env name=APP_BUILD::$VERSION echo "set APP_BUILD to $APP_BUILD" - run: echo "APP_BUILD is now $APP_BUILD" + - run: | + export NAME=$(grep APP_NAME= .env | cut -d '=' -f2) + echo ::set-env name=APP_NAME::$NAME + echo "set APP_NAME to $APP_NAME" diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 8f27ec44..1797973c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,9 +1,8 @@ - + - @@ -259,6 +265,7 @@ - \ No newline at end of file From 435a44df66fe03e354d0107ea73726cda6d06efd Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 11:26:26 +0100 Subject: [PATCH 062/125] Passing to next? --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f7f59574..23273fc5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,4 +25,4 @@ jobs: export NAME=$(grep APP_NAME= .env | cut -d '=' -f2) echo ::set-env name=APP_NAME::$NAME echo "set APP_NAME to $APP_NAME" - + - run: echo "APP_NAME is now $APP_NAME" From e375777dde08c3ade0e0a43b42d542e067a43ac0 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Mon, 2 Dec 2019 11:27:33 +0100 Subject: [PATCH 063/125] Docker compose update --- .env | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.env b/.env index 0380f3ac..66007731 100644 --- a/.env +++ b/.env @@ -18,6 +18,8 @@ APP_VERSION=V.0.1 APP_DEBUG=1 # What is the enviroment type you want to use for local production? (choose between dec,stag,prod, acce or test) APP_ENV=dev +# We use a build to tag images, this is swithced to the version on master and to env on other branches +APP_BUILD=dev # The description for this api APP_DESCRIPTION='Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.' From 402e180413964b24ac0cab03a935e015d5b42245 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 11:36:37 +0100 Subject: [PATCH 064/125] removing test workflow --- .github/workflows/test.yml | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 23273fc5..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Test - -on: - pull_request: - branches: - - dev-robert - push: - branches: - - dev-robert - -jobs: - - build: - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - run: grep APP_VERSION= .env | cut -d '=' -f2 - - run: | - export VERSION=$(grep APP_VERSION= .env | cut -d '=' -f2) - echo ::set-env name=APP_BUILD::$VERSION - echo "set APP_BUILD to $APP_BUILD" - - run: echo "APP_BUILD is now $APP_BUILD" - - run: | - export NAME=$(grep APP_NAME= .env | cut -d '=' -f2) - echo ::set-env name=APP_NAME::$NAME - echo "set APP_NAME to $APP_NAME" - - run: echo "APP_NAME is now $APP_NAME" From ada871a5c173fd45042339b1aa0681617a68c16a Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Mon, 2 Dec 2019 11:37:46 +0100 Subject: [PATCH 065/125] Added automatic release creation --- .github/workflows/dockerimage.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 35a1ff59..9bda97aa 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -102,3 +102,14 @@ jobs: kubectl rollout restart deployment/${{ secrets.APP_NAME }}-php --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/${{ secrets.APP_NAME }}-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/${{ secrets.APP_NAME }}-varnish --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV + - name: Create Release + if: contains( github.ref, 'master' ) + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: $APP_BUILD + release_name: $APP_BUILD + draft: false + prerelease: false From 8ed7e764c604862c0340fb66ed4a31f3fa1ae002 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 11:46:02 +0100 Subject: [PATCH 066/125] fix on build args --- .github/workflows/dockerimage.yml | 2 +- .idea/workspace.xml | 36 +++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 35a1ff59..f4111e45 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -51,7 +51,7 @@ jobs: - name: Print definitive APP_ENV run: echo "APP_ENV is now $APP_ENV" - name: Build the Docker image - run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV APP_BUILD=$APP_BUILD + run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV --build-arg APP_BUILD=$APP_BUILD - name: Run the docker image run: docker-compose up -d - name: Taking some sleep diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1797973c..86564d40 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -237,7 +237,35 @@ @@ -266,6 +294,10 @@ - \ No newline at end of file From fa9f508a376a432efd6ff0c1659589b029c6c564 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 11:49:07 +0100 Subject: [PATCH 067/125] Removed APP_NAME from secrets, added continue-on-error --- .github/workflows/dockerimage.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index f4111e45..1ef45dfa 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -92,10 +92,11 @@ jobs: - name: Deploy through helm id: helm-install if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' - run: helm upgrade ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 + run: helm upgrade $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 + continue-on-error: true - name: Install through helm if: failure() - run: helm install --name ${{ secrets.APP_NAME }}-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 + run: helm install --name $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - name: Rollout new containers if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' run: | From 227514cbdc8a5d70be4fe5f244a55b563df4ee68 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 11:51:58 +0100 Subject: [PATCH 068/125] Issue with APP_NAME --- .github/workflows/dockerimage.yml | 1 + .idea/workspace.xml | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 1ef45dfa..379a3255 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -26,6 +26,7 @@ jobs: export NAME=$(grep APP_NAME= .env | cut -d '=' -f2) echo ::set-env name=APP_NAME::$NAME echo "set APP_NAME to $APP_NAME" + - run: echo "APP_NAME = $APP_NAME" - name: Setting APP_ENV to dev run: | echo ::set-env name=APP_ENV::dev diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 86564d40..ffac64a7 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,7 +3,6 @@ - @@ -298,6 +311,8 @@ - \ No newline at end of file From d6d0a1f50dc5be9b8029edbc8b36e1cd201af296 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Mon, 2 Dec 2019 11:56:23 +0100 Subject: [PATCH 069/125] Error fix --- DESIGN.md | 12 ++++++------ api/src/Swagger/SwaggerDecorator.php | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 01221282..7cc0df69 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -71,14 +71,14 @@ api-01, api-02, api-03, api-05, api-06, api-10, api-11, api-12, api-13,api-14, a ** We do not implement ** - [api-04](https://docs.geostandaarden.nl/api/API-Strategie/#api-04) Define interfaces in Dutch unless there is an official English glossary (see [english](#english)) -- [api-09](https://docs.geostandaarden.nl/api/API-Strategie/#api-09) Implement custom representation if supported see [fields](#fields)) +- [api-09](https://docs.geostandaarden.nl/api/API-Strategie/#api-09) Implement custom representation if supported (see [fields](#fields)) - [api-17](https://docs.geostandaarden.nl/api/API-Strategie/#api-17) Publish documentation in Dutch unless there is existing documentation in English or there is an official English glossary (see [english](#english)) - [api-31](https://docs.geostandaarden.nl/api/API-Strategie/#api-31) Use the query parameter sorteer to sort (see [ordering](#ordering)) - [api-32](https://docs.geostandaarden.nl/api/API-Strategie/#api-32) Use the query parameter zoek for full-text search (see [search](#search)) - [api-36](https://docs.geostandaarden.nl/api/API-Strategie/#api-36) Provide a POST endpoint for GEO queries (see [queries](#queries)) - [api-37](https://docs.geostandaarden.nl/api/API-Strategie/#api-37) Support mixed queries at POST endpoints available (see [queries](#queries)) -*[api-38](https://docs.geostandaarden.nl/api/API-Strategie/#api-38) Put results of a global spatial query in the relevant geometric context (see [queries](#queries)) -- +- [api-38](https://docs.geostandaarden.nl/api/API-Strategie/#api-38) Put results of a global spatial query in the relevant geometric context (see [queries](#queries)) + ** We doubt or havn't made a choice yet about** @@ -90,12 +90,12 @@ api-01, api-02, api-03, api-05, api-06, api-10, api-11, api-12, api-13,api-14, a NLX ------- We implement the [NLX system](https://docs.nlx.io/understanding-the-basics/introduction/) as part of the basic commonground infrastructure, as such nlx headers are used in the internal logging. -The following X-NLX headers have been implemented for that reason `X-NLX-Logrecord-ID`,`X-NLX-Request-Process-Id`,`X-NLX-Request-Data-Elements` and `X-NLX-Request-Data-Subject`, these are tied to the internal audit trail (see audit trail for more information), and `X-Audit-Toelichting` (from the ZGW APIs) is implemented as `X-Audit-Clarification` - -We do not use other NLX headers since they (conform to the [NLX schema](https://docs.nlx.io/further-reading/transaction-logs/))wil not reach the provider. Please note that the use of nlx is optional. The component can be used without NLX. In that case the `X-NLX` header should be set to false, the `X-NLX-Logrecord-ID` should be provided with an log record designd by the client application to be retracable to a unique user and action. Other headers still aplly. +The following X-NLX headers have been implemented for that reason `X-NLX-Logrecord-ID`,`X-NLX-Request-Process-Id`,`X-NLX-Request-Data-Elements` and `X-NLX-Request-Data-Subject`, these are tied to the internal audit trail (see audit trail for more information), and `X-Audit-Toelichting` (from the ZGW APIs) is implemented as `X-Audit-Clarification`. We do not use other NLX headers since they (conform to the [NLX schema](https://docs.nlx.io/reference-information/transaction-log-headers/)) wil not reach the provider. We strongly discourage the use of the `X-NLX-Request-Data-Subject` header as it might allow private data (such as BSNs) to show up in logging. +Please note that the use of nlx is optional. The component can be used without NLX. In that case do not provide an `X-NLX-Logrecord-ID` but instead do + English ------- The [NL API Standard](https://geonovum.github.io/KP-APIs/#api-04-define-interfaces-in-dutch-unless-there-is-an-official-english-glossary) describes that there is a preference for Dutch in API documentation. diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index 02e872d2..3287c7eb 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -127,6 +127,12 @@ public function normalize($object, $format = null, array $context = []) // Oke dit is echt but lelijk $schemas = (array) $docs['definitions']; foreach ($schemas as $schemaName => $schema) { + + // We can only merge if we actually have content + if(!in_array ($schemaName, $additionalDocs)){ + continue; + } + $additionalDocs[$schemaName] = array_merge((array) $schema, $additionalDocs[$schemaName]); $properties = (array) $schema['properties']; From aecf399b8951abe1864e6b20a4ea922ce9932bcf Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 12:00:21 +0100 Subject: [PATCH 070/125] Housekeeping --- .github/workflows/dockerimage.yml | 4 ++-- .idea/workspace.xml | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 379a3255..89ac99eb 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -25,8 +25,8 @@ jobs: run: | export NAME=$(grep APP_NAME= .env | cut -d '=' -f2) echo ::set-env name=APP_NAME::$NAME - echo "set APP_NAME to $APP_NAME" - - run: echo "APP_NAME = $APP_NAME" + - name: Print app name + run: echo "APP_NAME = $APP_NAME" - name: Setting APP_ENV to dev run: | echo ::set-env name=APP_ENV::dev diff --git a/.idea/workspace.xml b/.idea/workspace.xml index ffac64a7..980cc0cb 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -278,7 +278,14 @@ @@ -313,6 +320,7 @@ - \ No newline at end of file From aa3457430956a394e40bca9a388f9c88ec49baa4 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Mon, 2 Dec 2019 13:02:25 +0100 Subject: [PATCH 071/125] Changes and spelling fixes --- DESIGN.md | 115 +++++++++++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 7cc0df69..cffb8595 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -14,10 +14,10 @@ Welcome, you are currently viewing the design decisions for the proto component. - [Search](#search) - [Queries](#queries) - [Extending](#extending) -- [Timetravel](#timetravel) +- [Time travel](#timetravel) - [Archivation](#archivation) -- [Audittrail](#audittrail) -- [Healthchecks](#healthchecks) +- [Audit trail](#audittrail) +- [Health checks](#healthchecks) - [Notifications](#notifications) - [Authentication](#authentication) - [Authorization](#authorization) @@ -29,7 +29,7 @@ Welcome, you are currently viewing the design decisions for the proto component. *Implementation choices* - [Api Versioning](#api-versioning) -- [Environments and namespacing](#environments-and-namespacing) +- [Environments and name spacing](#environments-and-namespacing) - [Domain Build-up and routing](#domain-build-up-and-routing) - [Container Setup](#container-setup) @@ -46,12 +46,12 @@ On standards and standardization ------- The specific goal of the proto component (which this current code base is a version of) is to provide a common architecture for common ground components. As such the common ground principles are leading in design choices, and within those principles international compliancy and technological invocation is deemed most important. **We do not want to make concessions to the current infrastructure.** As such the component might differ on [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie), [NORA](https://www.noraonline.nl/wiki/Standaarden), [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/index) and or other standards if they are deemed incompatible or out of line with (inter)national standards and or good practices. -Unfortunatly (inter)national standards standards can be conflicting. We therefore prioritize standards on sevarl grounds +Unfortunately (inter)national standards can be conflicting. We therefore prioritize standards on several grounds - International is put before local -- Standards caried by a standard organisation (like ISO, W3C etc) at put before floating standards (like RFC's) wichs are put before industraty standards, good practices and so on. +- Standards carried by a standard organization (like ISO, W3C etc) at put before floating standards (like RFC's) wichs are put before industry standards, good practices and so on. -So if for instance a **local** standard is out of line with an **internation** good practice we follow the international good practice. +So if for instance a **local** standard is out of line with an **international** good practice we follow the international good practice. ### Commonground specific standards @@ -59,14 +59,14 @@ This component was designed in line with the [NL API Strategie](https://docs.geo ## NL API Strategie -The [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie) takes a special place in this component, it is designed as a set of guidelines for API's for the dutch landscape. As such we follow it as close as posible. It dos however contains inconsistenies with both international standards and good practices. On those items we do not follow the norm but consider it our duty to try to change the norm. +The [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie) takes a special place in this component, it is designed as a set of guidelines for API's for the Dutch landscape. As such we follow it as close as possible. It dos however contains inconsistencies with both international standards and good practices. On those items we do not follow the norm but consider it our duty to try to change the norm. ** We implement ** api-01, api-02, api-03, api-05, api-06, api-10, api-11, api-12, api-13,api-14, api-16, api-18, api-19, api-20, api-21, api-22, api-23, api-24, api-25, api-26, api-27, api-28, api-29, api-30, api-33, api-34, api-35, api-42 ** We want to implement ** -- [api-14](https://docs.geostandaarden.nl/api/API-Strategie/#api-14) Use OAuth 2.0 for authorisation +- [api-14](https://docs.geostandaarden.nl/api/API-Strategie/#api-14) Use OAuth 2.0 for authorization ** We do not implement ** @@ -80,9 +80,9 @@ api-01, api-02, api-03, api-05, api-06, api-10, api-11, api-12, api-13,api-14, a - [api-38](https://docs.geostandaarden.nl/api/API-Strategie/#api-38) Put results of a global spatial query in the relevant geometric context (see [queries](#queries)) -** We doubt or havn't made a choice yet about** +** We doubt or haven’t made a choice yet about** -- [api-15](https://docs.geostandaarden.nl/api/API-Strategie/#api-15) Use PKIoverheid certificates for access-restricted or purpose-limited API authentication +- [api-15](https://docs.geostandaarden.nl/api/API-Strategie/#api-15) Use PKI overheid certificates for access-restricted or purpose-limited API authentication - [api-39](https://docs.geostandaarden.nl/api/API-Strategie/#api-39) Use ETRS89 as the preferred coordinate reference system (CRS) - [api-40](https://docs.geostandaarden.nl/api/API-Strategie/#api-40) Pass the coordinate reference system (CRS) of the request and the response in the headers - [api-41](https://docs.geostandaarden.nl/api/API-Strategie/#api-41) Use content negotiation to serve different CRS @@ -94,7 +94,7 @@ The following X-NLX headers have been implemented for that reason `X-NLX-Logreco We strongly discourage the use of the `X-NLX-Request-Data-Subject` header as it might allow private data (such as BSNs) to show up in logging. -Please note that the use of nlx is optional. The component can be used without NLX. In that case do not provide an `X-NLX-Logrecord-ID` but instead do +Please note that the use of nlx is optional. The component can be used without NLX. In that case set `X-NLX-Logrecord-ID` to false and provide (the normaly ignored) fields `X-NLX-Requester-User-Id`, `X-NLX-Request-Application-Id`, `X-NLX-Request-Subject-Identifier`, `X-NLX-Requester-Claims` and `X-NLX-Request-User` as if you are making an NLX call. This provides the API with enough credentials to make an complete audit trail. It also provides an easy implementation route to NLX since the only thing that would need to be changed at a later time is making you call to an nlx outway instead of the API directly. English ------- @@ -102,7 +102,7 @@ The [NL API Standard](https://geonovum.github.io/KP-APIs/#api-04-define-interfac > Define resources and the underlying entities, fields and so on (the information model ad the external interface) in Dutch. English is allowed in case there is an official English glossary. -We view this as a breach with good coding practice and international coding standards, all documentation and code is therefore supplied in English. We do however provide transaltion (or i18n) support. +We view this as a breach with good coding practice and international coding standards, all documentation and code is therefore supplied in English. We do however provide translation (or i18n) support. Fields ------- @@ -110,49 +110,24 @@ A part of the [haal centraal](https://raw.githubusercontent.com/VNG-Realisatie/H Search ------- -As part of [api-32](https://docs.geostandaarden.nl/api/API-Strategie/#api-32) a `zoeken` query has been itroduced that can handle wildcards. This breaks best practice, first of allest practice is a `search` query parameter (see also the nodes on [English](#english)). Secondly wildcards are a sql concept, not a webconcept, they are also a rather old concept severly limiting the search options provided. Instead the [regeular expresion standard](https://en.wikipedia.org/wiki/Regular_expression) should be used. +As part of [api-32](https://docs.geostandaarden.nl/api/API-Strategie/#api-32) a `zoeken` query has been introduced that can handle wildcards. This breaks best practice, first of allest practice is a `search` query parameter (see also the nodes on [English](#english)). Secondly wildcards are a sql concept, not a webconcept, they are also a rather old concept severely limiting the search options provided. Instead the [regular expression standard](https://en.wikipedia.org/wiki/Regular_expression) should be used. __solution__ We implement a `search` query parameter on resource collections, that filters with regex. Queries ------- -In several examples of the nl apistrategie we see query parameters being atached to post requests. This is unusual in the sence that sending query strings allong with a post is ocnsiderd bad practice (becouse query parameters end up as part of an url and are therfore logged by servers). But is is technically posile folowing RFC 3986. The real pain is that in the NL api-stratgie the POST requests seems to be used to search, ot in other words GET data. This is where compliance with HTTP (1.1) breaks. +In several examples of the nl api strategie we see query parameters being attached to post requests. This is unusual in the sence that sending query strings along with a post is considered bad practice (because query parameters end up as part of an url and are therefore logged by servers). But it is technically possible folowing RFC 3986. The real pain is that in the NL api-stratgie the POST requests seems to be used to search, ot in other words GET data. This is where compliance with HTTP (1.1) breaks. __solution__ We do not implement a query endpoint on post requests. - -Domain Build-up and routing -------- -By convention the component assumes that you follow the common ground domain name build up, meaning {environment}.{component}.{rest of domain}. That means that only the first two url parts are used for routing. It is also assumed that when no environment is supplied the production environment should be offered E.g. a proper domain for the production API of the verzoeken registratie component would be prod.vrc.zaakonline.nl but it should also be reachable under vrc.zaakonline.nl. The proper location for the development environment should always be dev.vrc.zaakonlin.nl - -Environments and namespacing -------- -We assume that for that you want to run several environments for development purposes. We identify the following namespaces for support. -- prod (Production) -- acce (Acceptation) -- stag (Staging) -- test (Testing) -- dev (Development) - -Because we base the common ground infrastructure on kubernetes, and we want to keep a hard separation between environment we also assume that you are using your environment as a namespace - -Symfony library management gives us the option to define the libraries on a per environment base, you can find that definition in the [bundle config](api/config/bundles.php) - -Besides the API environments the component also ships with additional tools/environments but those are not meant to be deployed -- client (An react client frontend) -- admin (An read admin interface) - -On the local development docker deploy the client environment is used as default instead of the production version of the api. - Api Versioning ------- -As per [landelijke API-strategie.](https://geonovum.github.io/KP-APIs/#versioning) major versions in endpoint minor versions in header, for this the `API-Version` is used (instead of the `api-version` header used in haal centraal) - +As per [landelijke API-strategie.](https://geonovum.github.io/KP-APIs/#versioning) we provide/ask major versions in the endpoint and minor versions in header, for this the `API-Version` is used (instead of the `api-version` header used in haal centraal) __solution__ -The fields parameter and functionality has been implemented as an array, and should be used that way. We do howver support an comma separted value list. +We implement both endpoint and header versioning Extending ------- @@ -163,7 +138,7 @@ The extend parameter has been implemented as an array Archivation ------- -There is a need (by law) for archivation, meaning that we should only keep resources for a fixed amount of time and delete them there afther. In line with the extending and fields principle whereby we only want resource properties that we need when we needid, it is deemded good practice make a sub resource of the archivation properties. For the archivation proterties the [zgw](https://zaken-api.vng.cloud/api/v1/schema/#operation/zaak_list) is followed and translated to englisch. +There is a need (by law) for archivation, meaning that we should only keep resources for a fixed amount of time and delete them thereafter. In line with the extending and fields principle whereby we only want resource properties that we need when we needed, it is deemed good practice make a sub resource of the archivation properties. For the archivation properties the [zgw](https://zaken-api.vng.cloud/api/v1/schema/#operation/zaak_list) is followed and translated to englisch. ```json @@ -175,15 +150,15 @@ There is a need (by law) for archivation, meaning that we should only keep resou } ``` -This gives us an intresting thought, acording to [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie/#api-10-implement-operations-that-do-not-fit-the-crud-model-as-sub-resources) subresources should have there own endpoint. Therefore we could use a archive sub of a difrend object for archivation rules e.g. /zaken/{uuid}/archivation for a verzoek. This in itself leads credence to the thought that archivation should have its own central crud api. +This gives us an interesting thought, according to [NL API Strategie](https://docs.geostandaarden.nl/api/API-Strategie/#api-10-implement-operations-that-do-not-fit-the-crud-model-as-sub-resources) sub resources should have their own endpoint. Therefore we could use a archive sub of a different resource for archivation rules e.g. /zaken/{uuid}/archivation for a verzoek. This in itself leads credence to the thought that archivation should have its own central crud api. Audittrail ------- For audittrail we use the base mechanism as provided by [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/audit-trail), we do however diver on some key point, -- Personal data schould never be part of a log, therefore only the user id with the client should be logged (insted of the name) +- Personal data should never be part of a log, therefore only the user id with the client should be logged (instead of the name) - Besides an endpoint per resource there should be a general enpoint to search all audit trials of a component -- [Timetravel](#timetravel) in combinaition with objects versioning makes the return of complete objects unnecesary. But an auditrail endpoint should support the [extend](#extending) functionalitiy to provide the option of obtaining complete objects. +- [Time travel](#timetravel) in combination with objects versioning makes the return of complete objects unnecessary. But an audit rail endpoint should support the [extend](#extending) functionality to provide the option of obtaining complete objects. __solution__ @@ -193,17 +168,18 @@ Healthchecks ------- From [issue 154](https://github.com/VNG-Realisatie/huwelijksplanner/issues/154) -For healthc +For healthchecks we use the health-json principle (or json-health to stay in line with json-ld and json-hal). This means the any endpoint `should` be capable of providing health information concerning that endpoint and services behind it. __solution__ +The use of a `Content-Type: application/health+json` header returns an health json schema. Notifications ------- -For notifications we do not YET use the current [ZGW standard](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/notificaties) since there is an [dicusion](https://github.com/VNG-Realisatie/gemma-zaken/issues/1427#issuecomment-549272696) about the posible insecurity of sending properties or data objects along with a notification. It also dosn't follow the [web standard](https://www.w3.org/TR/websub/). We wait for the conclusion of that discusion before making an implementation. +For notifications we do not YET use the current [ZGW standard](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/notificaties) since there is an [dicusion](https://github.com/VNG-Realisatie/gemma-zaken/issues/1427#issuecomment-549272696) about the possible insecurity of sending properties or data objects along with a notification. It also doesn’t follow the [web standard](https://www.w3.org/TR/websub/). We wait for the conclusion of that discussion before making an implementation. __solution__ -In compliance with [w3.org](https://www.w3.org/TR/websub/) each endpoint returns an header containing an subscribtion url. That can be used in acordanse with the application to subscribe to both individual objects as collections. whereby collections serve as 'kanalen'. We aim to implement the ZGW notificatie component, but feel that further features on that component would be required to make to be fully suported. We will suply feature requests per issue to support this effort. +In compliance with [w3.org](https://www.w3.org/TR/websub/) each endpoint `should` returns an header containing an subscription url. That can be used in accordance with the application to subscribe to both individual objects as collections whereby collections serve as 'kanalen'. We aim to implement the ZGW notificatie component, but feel that further features on that component would be required to make to be fully supported. We will supply feature requests per issue to support this effort. Authentication ------- @@ -212,17 +188,18 @@ __solution__ Authorization ------- -We implement user scopes as per [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/autorisatie-scopes) standard. But see problems with how the scopes are defined and named, and consider the general setup to be to focused on ZGW (including Dutch naming, zgw specific fields like maxVertrouwlijkheid and a lack of CRUD thinking). There is a further document concerning [Authentication and Authorization](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/authenticatie-autorisatie) that details how we should authenticate users and give them scopes. We agree with the principles of the document on application based authorization and the use of JWT tokens. But disagree on some key technical aspect. Most important being that the architecture doesn't take into consideration the use of one component by several organizations at once. Or scopese per property. +We implement user scopes as per [vng.cloud](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/autorisatie-scopes) standard. But see problems with how the scopes are defined and named, and consider the general setup to be to focused on ZGW (including Dutch naming, zgw specific fields like maxVertrouwlijkheid and a lack of CRUD thinking). There is a further document concerning [Authentication and Authorization](https://zaakgerichtwerken.vng.cloud/themas/achtergronddocumentatie/authenticatie-autorisatie) that details how we should authenticate users and give them scopes. We agree with the principles of the document on application based authorization and the use of JWT tokens. But disagree on some key technical aspect. Most important being that the architecture doesn't take into consideration the use of one component by several organizations at once. Or scopes per property. __solution__ -No solution as of yet, so there is no implementation of Authorization or Scopes. We aim to implement the ZGW authorisatie component, but feel that further features on that component would be required to make to be fully suported. We will suply feature requests per issue to support this effort. +No solution as of yet, so there is no implementation of Authorization or Scopes. We aim to implement the ZGW authorisatie component, but feel that further features on that component would be required to make to be fully supported. We will supply feature requests per issue to support this effort. Timetravel ------- A part of the [haal centraal](https://raw.githubusercontent.com/VNG-Realisatie/Haal-Centraal-BRP-bevragen/master/api-specificatie/Bevraging-Ingeschreven-Persoon/openapi.yaml) the concept of timetravel has been introduced, as in getting the version of an object as it was on a given date. For this the `geldigop` [see the docs](file:///C:/Users/ruben/Desktop/doc_gba_historie.html#operation/getBewoningen) header is used. In addition the `geldigvan` and `geldigtot` are introduced as collection filters. -The commonground proto componant natively supports time traveling on all entities that are annotaded with the @Gedmo\Loggable, this is done by adding the ?validOn=[date] query to a request, date can either be a datetime or datedatime string. Any value supported by php's [strtotime()](https://www.php.net/manual/en/function.strtotime.php) is supported. Keep in mind that this returns the entity a as it was valid on that time or better put, the last changed version BEFORE that moment. To get a complete list of all changes on a item the /audittrail endpoint can be used. +The commonground proto componant natively supports time traveling on all resources that are annotaded with the @Gedmo\Loggable, this is done by adding the ?validOn=[date] query to a request, date can either be a datetime or datedatime string. Any value supported by php's [strtotime()](https://www.php.net/manual/en/function.strtotime.php) is supported. Keep in mind that this returns the entity a as it was valid on that time or better put, the last changed version BEFORE that moment. To get a complete list of all changes on an item the [/audittrail](#Audittrail +) endpoint can be used. __solution__ In compliance with [schema.org](https://schema.org/validFrom) `geldigop`,`geldigvan` and `geldigtot` are implemented as `validOn`,`validFrom` and `validUntil`. And can be used a query parameters on collection operations/ @@ -236,7 +213,7 @@ In the [zaak-api](https://zaken-api.vng.cloud/api/v1/schema/#operation/zaak_list Translations ------- -We support translations trough the `Accept-Language` header (read the [docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language)), the fallback langouge for all messages is englisch +We support translations trough the `Accept-Language` header (read the [docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language)), the fallback language for all messages is English Errors ------- @@ -258,7 +235,7 @@ We support both comma and bracket notation on array's, but only document bracket Container Setup ------- - https://medium.com/shiphp/building-a-custom-nginx-docker-image-with-environment-variables-in-the-config-4a0c36c4a617 +https://medium.com/shiphp/building-a-custom-nginx-docker-image-with-environment-variables-in-the-config-4a0c36c4a617 Filtering @@ -270,7 +247,7 @@ __Regex Exact__ __Regex Contains__ __Like___ -The like filters is used to search for enities with the traditional sql LIKE operator. If pattern does not contain percent signs or underscores, then the pattern only represents the string itself; in that case LIKE acts like the equals operator. An underscore (_) in pattern stands for (matches) any single character; a percent sign (%) matches any sequence of zero or more characters. +The like filters is used to search for resources with the traditional sql LIKE operator. If pattern does not contain percent signs or underscores, then the pattern only represents the string itself; in that case LIKE acts like the equals operator. An underscore (_) in pattern stands for (matches) any single character; a percent sign (%) matches any sequence of zero or more characters. Some examples: @@ -278,6 +255,7 @@ Some examples: 'abc' LIKE 'a%' true 'abc' LIKE '_b_' true 'abc' LIKE 'c' false + LIKE pattern matching always covers the entire string. Therefore, if it's desired to match a sequence anywhere within a string, the pattern must start and end with a percent sign. To match a literal underscore or percent sign without matching other characters, the respective character in pattern must be preceded by a backlash. @@ -285,10 +263,32 @@ To match a literal underscore or percent sign without matching other characters, ## Kubernetes ### Loadbalancers -We no longer provide a load balancer per component, since this would require a ip per component. Draining ip's on mult component kubernetes clusters. In stead we make componentes available as an interner service +We no longer provide a load balancer per component, since this would require a IP address per component (and ipv 4 addresses are in short supply). Instead we make components available as an internal service. A central load balancer could then be used to provide several api’s in one ### server naming -A component is (speaking in kubernetes terms) a service that is available at +A component is (speaking in kubernetes terms) a service that is available at a name corresponding to its designation + +### Domain Build-up and routing +By convention the component assumes that you follow the common ground domain name build up, meaning {environment}.{component}.{rest of domain}. That means that only the first two url parts are used for routing. It is also assumed that when no environment is supplied the production environment should be offered E.g. a proper domain for the production API of the verzoeken registratie component would be prod.vrc.zaakonline.nl but it should also be reachable under vrc.zaakonline.nl. The proper location for the development environment should always be dev.vrc.zaakonlin.nl + +### Environments and namespacing +We assume that for that you want to run several environments for development purposes. We identify the following namespaces for support. +- prod (Production) +- acce (Acceptation) +- stag (Staging) +- test (Testing) +- dev (Development) + +Because we base the common ground infrastructure on kubernetes, and we want to keep a hard separation between environment we also assume that you are using your environment as a namespace + +Symfony library management gives us the option to define the libraries on a per environment base, you can find that definition in the [bundle config](api/config/bundles.php) + +Besides the API environments the component also ships with additional tools/environments but those are not meant to be deployed +- client (An react client frontend) +- admin (An read admin interface) + +On the local development docker deploy the client environment is used as default instead of the production version of the api. + ## Data types @@ -327,3 +327,4 @@ A component is (speaking in kubernetes terms) a service that is available at | string | iban | | | | | | | | | | | | + From a42c9db7f1486b6de7ba7eb87b06a4e9faa7dfb8 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 13:21:50 +0100 Subject: [PATCH 072/125] Fix on container rollout --- .github/workflows/dockerimage.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 89ac99eb..0bacadc6 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -101,6 +101,6 @@ jobs: - name: Rollout new containers if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' run: | - kubectl rollout restart deployment/${{ secrets.APP_NAME }}-php --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV - kubectl rollout restart deployment/${{ secrets.APP_NAME }}-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV - kubectl rollout restart deployment/${{ secrets.APP_NAME }}-varnish --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV + kubectl rollout restart deployment/$APP_NAME-php --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV + kubectl rollout restart deployment/$APP_NAME-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV + kubectl rollout restart deployment/$APP_NAME-varnish --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV From 986f549c7ac38371e5ba706842be76d785020b30 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 13:31:24 +0100 Subject: [PATCH 073/125] Style fix on swaggerdecorator --- api/src/Swagger/SwaggerDecorator.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index 3287c7eb..28b4d3e5 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -127,12 +127,12 @@ public function normalize($object, $format = null, array $context = []) // Oke dit is echt but lelijk $schemas = (array) $docs['definitions']; foreach ($schemas as $schemaName => $schema) { - - // We can only merge if we actually have content - if(!in_array ($schemaName, $additionalDocs)){ - continue; - } - + + // We can only merge if we actually have content + if (!in_array($schemaName, $additionalDocs)) { + continue; + } + $additionalDocs[$schemaName] = array_merge((array) $schema, $additionalDocs[$schemaName]); $properties = (array) $schema['properties']; From 0f151ff22111dd986bdac02c7a7cfaaedfeaece7 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Mon, 2 Dec 2019 13:59:21 +0100 Subject: [PATCH 074/125] Tsja --- api/src/Swagger/SwaggerDecorator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index 3287c7eb..51b2169c 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -127,12 +127,12 @@ public function normalize($object, $format = null, array $context = []) // Oke dit is echt but lelijk $schemas = (array) $docs['definitions']; foreach ($schemas as $schemaName => $schema) { - + // We can only merge if we actually have content if(!in_array ($schemaName, $additionalDocs)){ continue; } - + $additionalDocs[$schemaName] = array_merge((array) $schema, $additionalDocs[$schemaName]); $properties = (array) $schema['properties']; From 353ad00515ebd5b76e2eb9a903d50760fee13b02 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 15:10:32 +0100 Subject: [PATCH 075/125] Trying to fix issue caused by continue-on-error --- .github/workflows/dockerimage.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 01f711b8..610fe32c 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -93,11 +93,14 @@ jobs: - name: Deploy through helm id: helm-install if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' - run: helm upgrade $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 + run: | + echo "##[set-output name=success]false" + helm upgrade $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 + echo "##[set-output name=success]true" continue-on-error: true - name: Install through helm if: failure() - run: helm install --name $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 + run: helm install --name $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - name: Rollout new containers if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' run: | From bbd8b61ca6926e231232872a9d6ee3c00e88bf6c Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 15:27:00 +0100 Subject: [PATCH 076/125] Adding conition for helm install and rollout --- .github/workflows/dockerimage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 610fe32c..cf7dbbdf 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -99,10 +99,10 @@ jobs: echo "##[set-output name=success]true" continue-on-error: true - name: Install through helm - if: failure() + if: steps.helm-install.success == 'false' run: helm install --name $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - name: Rollout new containers - if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' + if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' && steps.helm-install.success == 'true' run: | kubectl rollout restart deployment/$APP_NAME-php --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/$APP_NAME-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV From f394cee1fc974e1af641c7e8d704e60bd48db79d Mon Sep 17 00:00:00 2001 From: bbrands02 <57346398+bbrands02@users.noreply.github.com> Date: Mon, 2 Dec 2019 16:17:03 +0100 Subject: [PATCH 077/125] APIProperty removed --- TUTORIAL.md | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/TUTORIAL.md b/TUTORIAL.md index 74aad7ba..4107e573 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -224,18 +224,7 @@ with //... /** * @var \Ramsey\Uuid\UuidInterface - * - * @ApiProperty( - * identifier=true, - * attributes={ - * "openapi_context"={ - * "description" = "The UUID identifier of this object", - * "type"="string", - * "format"="uuid", - * "example"="e2984465-190a-4562-829e-a8cca81aa35d" - * } - * } - * ) + * @example e2984465-190a-4562-829e-a8cca81aa35d * * @Groups({"read"}) * @ORM\Id From ecb9c64c37ab2a3f3b3d1f9c24e74692e61448a5 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Mon, 2 Dec 2019 16:26:37 +0100 Subject: [PATCH 078/125] Tekstuele aanpassingen --- TUTORIAL.md | 49 ++++++++++++++++--------------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/TUTORIAL.md b/TUTORIAL.md index 74aad7ba..e736be4d 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -350,36 +350,33 @@ When using Github. To set up a webhook, go to the settings page of your reposito Now every time you update your repository the commonground dev page will alerted, rescan your repository and do al the appropriate platform actions. It just as easy as that. -Automated Testing and Deployment (continues integration) +Continues integration ------- -The following bit of the tutorial requires two additional accounts -- [https://hub.docker.com/](https://hub.docker.com/) (You might already have this for docker for desktop) -- [https://travis-ci.org](https://travis-ci.org) (You can use you github account) +> The following bit of the tutorial requires an additional accounts +> - [https://hub.docker.com/](https://hub.docker.com/) (You might already have this for docker for desktop) -The proto component ships with a pre-fab continues integration script based on travis. What does this mean you ask? Continuous integration (or CI for short) is an optimized and automated way for your code to become part of your projects. In the case of your commonground component that means that we will automatically validate new code commits or pushes and (if everything checks out) build that code and deploy the containers thereof to docker hub. Making is possible to update al the environments that use those components. +The proto component ships with a pre-fab continues integration script based on github action (there is also a travis script in here if you want it). What does this mean you ask? Continuous integration (or CI for short) is an optimized and automated way for your code to become part of your projects. In the case of your commonground component that means that we will automatically validate new code commits or pushes and (if everything checks out) build that code and deploy the containers thereof to docker hub. Making is possible to update al the environments that use those components. Whats even better is that we check your code for known security issues, so whenever a dependency or libary has a security issue you will be notified to take action. -Okay, that's nice, but how do we do that? Actually it is very simple. First of all make sure you have a docker account, log into [docker hub](https://hub.docker.com/) and have a look around. We don't need to create anything just yet, but it is nice to get a feeling of the place. As you can see docker hub also uses repositories etc. So that recognizable. +Okay, that's nice, but how do we do that? Actually it is very simple. You do nothing. The scripts are already enabled by default. Just go to the actions tab of your github repository to see the results whenever you push code. -Next we need to prepare our github repository that holds our code. For the travis script to work as intended we need to create a couple of branches(if we don't have those already) open up your git interface and create a branch called 'development' and a branch called 'staging'. Don't forget to push the branches so that they are present on github (and not just on your local machine). - -Oke just one more place to go and that is travis, head over to [https://travis-ci.org](https://travis-ci.org) and login with your github account. If everything is alright you should see your repository there. Activate it by pressing 'activate repository' and then go to 'More options' -> 'Settings' and scroll down to environment variables. Here we can present travis wit the variables that it need to execute our build script. Lets first set the common variables that we need for all our branches: `DOCKER_PASSWORD` your docker password,`DOCKER_REGISTRY` docker.io/[your username] ,`DOCKER_USERNAME` your docker user name. This will be used by travis to push the completed containers into docker hub. Next we need to specify a couple of variables that are branch specific. Or to be more exact, set the same variable `APP_ENV` with different values for different branches. It needs to be 'staging'->stag,'master'->prod,'development'->dev. - -And all done! Head over back to the code on your computer and make a small change. Then commit push that change into github. Travis should automatically pick op your change and start a build. +There is however a bit of extra here that you can do and that is to insert your docker hub credentials into the repository. You can do that under the settings->secrets tab of yout repoistory by setting a `DOCKERHUB_USERNAME` and `DOCKERHUB_PASSWORD` secret containing (you might have guesed it) your dockerhub username and secret. And all done! Head over back to the code on your computer and make a small change. Then commit push that change into github. Wait for the action to complete and head over to your docker hub repository page. You should find your build containers ready for you. +Continues deployment +------- +> The following bit of the tutorial requires an additional accounts +> - [https://www.digitalocean.com/](https://www.digitalocean.com/) -### Unit / Behat +Actually the repository goes a bit further then just getting your containers ready to deploy, it can acctually deploy them for you! Again all the code is already there. The only thing that you need to do is add a kubeconfig file. You can get a kubeconfig file from a running kubernetes clusters, it provides your repositorie with both the credentials and endpoints it needs to deploy the application. How you get a Kubeconfig file difers a bit from provider to provider. But you can get more inforamtion on that here -TODO +- [Digitalocean](https://www.digitalocean.com/docs/kubernetes/how-to/connect-to-cluster/) +- [Google Cloud](https://cloud.google.com/sdk/gcloud/reference/container/clusters/get-credentials) +- [Amazone AWS](https://docs.aws.amazon.com/eks/latest/userguide/create-kubeconfig.html) -### Postman -TODO - -### Trouble shooting -Please make sure that your github repository is set to public, and keep in mind that a complex travis build (and certainly one that includes a pushing of containers can take up to 20 minutes). +Afther you have abtained a kuneconfig you need to save it to your repository as a secret (NEVER COMMIT A KUBECONFIG FILE), use the secret `KUBECONFIG` to save your cubeconfig file. Now simply commit and push your code to your repository and presto! You have a working common-ground component online. Documentation and dockblocks ------- -TODO +You want both your redoc documentation and your code to be readable and reausable to other developers. To this effect we use docblok annotation. You can read more about that [here](https://docs.phpdoc.org/references/phpdoc/basic-syntax.html) but the basic is this, we supply each class and propery with a docblock contained within /\* \* / characters. At the very least we want to describe our properties, the expected results and example data (see the example under [audittrail](#audittrail) Audittrail ------- @@ -440,17 +437,3 @@ class ExampleEntity ``` And now we have a fully nl api strategy integrated audit trail! - - -Setting up automated deployment (continues delivery) -------- -TODO - -## Commonground specific data types -TODO - -### incompleteDate - - -### underInvestigation - From c77e5086586462db1990d616589e7ee9751438c1 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Mon, 2 Dec 2019 15:27:41 +0000 Subject: [PATCH 079/125] Apply fixes from StyleCI --- api/src/Swagger/SwaggerDecorator.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index 51b2169c..28b4d3e5 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -128,10 +128,10 @@ public function normalize($object, $format = null, array $context = []) $schemas = (array) $docs['definitions']; foreach ($schemas as $schemaName => $schema) { - // We can only merge if we actually have content - if(!in_array ($schemaName, $additionalDocs)){ - continue; - } + // We can only merge if we actually have content + if (!in_array($schemaName, $additionalDocs)) { + continue; + } $additionalDocs[$schemaName] = array_merge((array) $schema, $additionalDocs[$schemaName]); From 89c072333612034560868b7a15eb896db25dfded Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Mon, 2 Dec 2019 16:45:57 +0100 Subject: [PATCH 080/125] Removed entity en object descriptions for resources --- TUTORIAL.md | 67 ++++++++++++++++++----------------------------------- 1 file changed, 22 insertions(+), 45 deletions(-) diff --git a/TUTORIAL.md b/TUTORIAL.md index e736be4d..ed149d7b 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -8,7 +8,7 @@ What do you need for this tutorial? * Docker for desktop ## Before you begin -For the steps considering the generation of entities an example entity a availale, feel free to [take a look](https://github.com/ConductionNL/Proto-component-commonground/blob/master/api/src/Entity/ExampleEntity.php) at it if you have trouble figuring out the code. +For the steps considering the generation of resources (or entities as symfony calls them) an example resource a availale, feel free to [take a look](https://github.com/ConductionNL/Proto-component-commonground/blob/master/api/src/Entity/ExampleEntity.php) at it if you have trouble figuring out the code. ## Setting up your enviroment @@ -57,10 +57,10 @@ $ docker volume prune **What are we looking at?** The Common Ground base component provides a bit more than just a development interface, it also includes an example application and a backend that automatically hooks into your api. For now we're just going to focus on our api, but is good to read up on all the features of the Common Ground base component here. -## Adding your own objects -You can now access your api at http://localhost:8080/, as you can see it's pre-loaded with some example objects. Let's replace them with your own objects! +## Adding your own resources +You can now access your api at http://localhost:8080/, as you can see it's pre-loaded with some example resources. Let's replace them with your own resources! -First let's remove the objects currently in the api, we can do that by just removing the entities form our code base, navigate to the folder where you stored your code and open the folder api/src/Entity , you can find the example entities (our name for objects) there. Just delete all the php files in that folder. +First let's remove the resources currently in the api, we can do that by just removing the resources form our code base, navigate to the folder where you stored your code and open the folder api/src/Entity , you can find the example entities (the symfony name for resources) there. Just delete all the php files in that folder. Next let's add our own entities, we can do this in two ways, we can do old fashioned coding, but we can also use the build in maker bundle of the proto component, to quickly generate our entities for us (without the fuss of actual coding). @@ -69,7 +69,7 @@ Let's open a new command line window and navigate to our root folder, exactly li ```CLI $ docker-compose exec php bin/console make:entity ``` -We should now see a wizard that allows us to either make new entities, or add parameters to existing entities (by supplying the name of an existing entity). +We should now see a wizard that allows us to either make new entities, or add parameters to existing entities (by supplying the name of an existing resource). ## Keeping your repository up to date with the Conduction Common Ground component @@ -107,7 +107,7 @@ git merge upstream --allow-unrelated-histories Keep in mind that you wil need to make sure to stay up to date about changes on the Common Ground component repository. ## Renaming your component -Right now the name of your component is 'commonground' that's that's fine while running it locally or in its own kubernetes cluster but wil get you in when running it with other components when it without using a name space. So its good practice to name your component distinctly. But besides al of these practical reasons its of course also just cool to name your child before you unleash it on the unsuspecting common ground community. +Right now the name of your component is `commonground component` and its unique id `cg` that's that's fine while running it locally or in its own kubernetes cluster but wil get you in when running it with other components when it without using a name space. So its good practice to name your component distinctly. But besides al of these practical reasons its of course also just cool to name your child before you unleash it on the unsuspecting common ground community. Oke, so before we can nae the component we need to come up with a name. There are a couple of conventions here. First of the name should tell us what the component does, or is supposed to do with one or two words. So we would normally call an component about dogs the DogComponent and one about cats te CatComponent. The second convention is that we don't usually actually name our component 'component' but indicate its position in de common ground architecture. For that we have the following options: * Catalogus @@ -116,34 +116,11 @@ Oke, so before we can nae the component we need to come up with a name. There ar * Application * Tool -The we need to touch te following files +The actual name change is rather simple doh, just head over to the .env that contains all our config and change the apropriate variables * .env -* dockercompose.yaml -* api/.env -* api/helm/values.yaml -* api/docker/nginx/ -## Adding more openapi documantation - -```php -//... - /** - * @ApiProperty( - * attributes={ - * "openapi_context"={ - * "description" = "The name of a organisation", - * "type"="string", - * "format"="string", - * "example"="My Organisation" - * } - * } - * ) - */ - private $name; -//... -``` - -## Setting up security and access (also helps with serialization) +## Setting up security and access +We want to secure our resources in such a way that only users or applications with propper right can acces and update properties. ```PHP // src/Entity/Organisation.php @@ -169,7 +146,7 @@ class Organisation ``` ## Using validation -Right now we are just accepting data and passing them on to the database, and in a mock or poc context this is fine. Most of the calls will end up being get requests anyway. But in case that we actually want our clients to make post to the api it would be wise to add some validation to the fields we are recieving. Luckely for us the component comes pre packed with a valdiation tool that we can configure from our entity through annotion. If we for example want to make a field required we could do so as follows: +Right now we are just accepting data and passing them on to the database, and in a mock or poc context this is fine. Most of the calls will end up being get requests anyway. But in case that we actually want our clients to make post to the api it would be wise to add some validation to the fields we are recieving. Luckely for us the component comes pre packed with a valdiation tool that we can configure from our resources through annotion. If we for example want to make a field required we could do so as follows: ```PHP // src/Entity/Organisation.php @@ -196,7 +173,7 @@ Keep in mind that we need to add the assert annotation to our class dependencies More inforation on using validation can be found at the [symfony website](https://symfony.com/doc/current/validation.html), but it is als worth nothing that tis component comes pre packed with some typical NL validators like BSN. You can find those [here](). ## Using UUID -As default doctrine uses auto increment integers as identifiers (1,2, etc). For modern web applications we however prefer the use of UUID's. (e.g. e2984465-190a-4562-829e-a8cca81aa35d). Why? Wel for one it is more secure integer id's are easily guessable and make it possible to "ask" endpoint about objects that you should not know about. But UUID's also have a benefit in future proofing the application. If we in the future want to merge a table with another table (for example because two organisations using a component perform a merger) then we would have to reassign al id's and relations if we where using int based id's (both tables would have a row 1,2 etc) with UUID's however the change of doubles range somewhere in the billions. Meaning that it is likely that we only need to either reidentify only a handful of rows or more likely none at al! Turning our entire migration into a copy paste action. +As default doctrine uses auto increment integers as identifiers (1,2, etc). For modern web applications we however prefer the use of UUID's. (e.g. e2984465-190a-4562-829e-a8cca81aa35d). Why? Wel for one it is more secure integer id's are easily guessable and make it possible to "ask" endpoint about resources that you should not know about. But UUID's also have a benefit in future proofing the application. If we in the future want to merge a table with another table (for example because two organisations using a component perform a merger) then we would have to reassign al id's and relations if we where using int based id's (both tables would have a row 1,2 etc) with UUID's however the change of doubles range somewhere in the billions. Meaning that it is likely that we only need to either reidentify only a handful of rows or more likely none at al! Turning our entire migration into a copy paste action. The proto component supports Ramsey's uuid objects strategy out of the box, so to use UUID's as identifier simply we need to add the ApiProperty as a dependency @@ -229,7 +206,7 @@ with * identifier=true, * attributes={ * "openapi_context"={ - * "description" = "The UUID identifier of this object", + * "description" = "The UUID identifier of this resource", * "type"="string", * "format"="uuid", * "example"="e2984465-190a-4562-829e-a8cca81aa35d" @@ -247,7 +224,7 @@ with //.. ``` -and remove the integer on the getter turning this: +and remove the : ?integer on the getter turning this: ```PHP //... @@ -272,7 +249,7 @@ into this and you're all done ### Trouble shooting -If you have already spun your component including your new entity your going to run into some trouble because doctrine is going to try changing your primary key column (id) from an integer to string (tables tend not to like that). In that case its best to just drop your database and reinstall it using the following commands: +If you have already spun your component including your new resource your going to run into some trouble because doctrine is going to try changing your primary key column (id) from an integer to string (tables tend not to like that). In that case its best to just drop your database and reinstall it using the following commands: ```CLI $ bin/console doctrine:schema:drop @@ -281,9 +258,9 @@ $ bin/console doctrine:schema:update --force ## Advanced data sets -Oke lets make it complex, until now we have just added some simple entities to our component, but what if we want to attaches one entity to another? Fortunately our build in database engine support rather complex scenarios called associations. So let [take a look](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/association-mapping.html) at that. +Oke lets make it complex, until now we have just added some simple entities to our component, but what if we want to attaches one resource to another? Fortunately our build in database engine support rather complex scenarios called associations. So let [take a look](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/association-mapping.html) at that. -Baffled? Wel its rather complex. But remember that Make:entity command that we used earlier? That actually accepts relations as a data type. Or to but it simply instead of using the default 'string' we could just type "ManyToOne" and it will just fire up some questions that will help it determine how you want your relations to be. +Baffled? Wel its rather complex. But remember that make:entity command that we used earlier? That actually accepts relations as a data type. Or to but it simply instead of using the default 'string' we could just type "ManyToOne" and it will just fire up some questions that will help it determine how you want your relations to be. ### Trouble shooting @@ -315,7 +292,7 @@ We can now prevent circular references by setting a max depth on the properties ```PHP //... /** - * @var ArrayCollection $stuffs Some stuff that is attached to this example object + * @var ArrayCollection $stuffs Some stuff that is attached to this example resource * * @MaxDepth(1) * @Groups({"read","write"}) @@ -326,7 +303,7 @@ We can now prevent circular references by setting a max depth on the properties ``` ## Data fixtures -For testing cases it can be useful to use data fixtures a predefined set of data that fills the database of your component at startup. Since we use php classes to describe our objects creating fixtures is easy (you can find an example in your project folder at api/src/DataFixtures). We simply go trough some classes assign values and persist them to the database. Once we have written our fixtures we can use a single command to load them +For testing cases it can be useful to use data fixtures a predefined set of data that fills the database of your component at startup. Since we use php classes to describe our resources creating fixtures is easy (you can find an example in your project folder at api/src/DataFixtures). We simply go trough some classes assign values and persist them to the database. Once we have written our fixtures we can use a single command to load them ```CLI $ bin/console doctrine:fixtures:load --env=dev @@ -352,7 +329,7 @@ Now every time you update your repository the commonground dev page will alerted Continues integration ------- -> The following bit of the tutorial requires an additional accounts +> The following bit of the tutorial requires an additional account > - [https://hub.docker.com/](https://hub.docker.com/) (You might already have this for docker for desktop) The proto component ships with a pre-fab continues integration script based on github action (there is also a travis script in here if you want it). What does this mean you ask? Continuous integration (or CI for short) is an optimized and automated way for your code to become part of your projects. In the case of your commonground component that means that we will automatically validate new code commits or pushes and (if everything checks out) build that code and deploy the containers thereof to docker hub. Making is possible to update al the environments that use those components. Whats even better is that we check your code for known security issues, so whenever a dependency or libary has a security issue you will be notified to take action. @@ -363,10 +340,10 @@ There is however a bit of extra here that you can do and that is to insert your Continues deployment ------- -> The following bit of the tutorial requires an additional accounts +> The following bit of the tutorial requires an additional account > - [https://www.digitalocean.com/](https://www.digitalocean.com/) -Actually the repository goes a bit further then just getting your containers ready to deploy, it can acctually deploy them for you! Again all the code is already there. The only thing that you need to do is add a kubeconfig file. You can get a kubeconfig file from a running kubernetes clusters, it provides your repositorie with both the credentials and endpoints it needs to deploy the application. How you get a Kubeconfig file difers a bit from provider to provider. But you can get more inforamtion on that here +Actually the repository goes a bit further then just getting your containers ready to deploy, it can acctually deploy them for you! Again all the code is already there. The only thing that you need to do is add a kubeconfig file. You can get a kubeconfig file from a running kubernetes clusters, it provides your repository with both the credentials and endpoints it needs to deploy the application. How you get a Kubeconfig file difers a bit from provider to provider. But you can get more information on that here - [Digitalocean](https://www.digitalocean.com/docs/kubernetes/how-to/connect-to-cluster/) - [Google Cloud](https://cloud.google.com/sdk/gcloud/reference/container/clusters/get-credentials) @@ -382,7 +359,7 @@ Audittrail ------- As you might expect the proto-component ships with a neat function for generating audit trails, that basically exist of three parts. -First we need to activate logging on the entities that we want logged (for obvious security reasons we don't log entity changes by default) to do that by adding the `@Gedmo\Loggable` annotation to our php class, which should then look something like: +First we need to activate logging on the entities that we want logged (for obvious security reasons we don't log resource changes by default) to do that by adding the `@Gedmo\Loggable` annotation to our php class, which should then look something like: ```PHP //... From e263f398274dbf608c0fd89674e33cc4a0c6ce73 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 2 Dec 2019 16:51:27 +0100 Subject: [PATCH 081/125] Rollback of continue on error --- .github/workflows/dockerimage.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index cf7dbbdf..9e8658ca 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -93,13 +93,9 @@ jobs: - name: Deploy through helm id: helm-install if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' - run: | - echo "##[set-output name=success]false" - helm upgrade $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - echo "##[set-output name=success]true" - continue-on-error: true + run: helm upgrade $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - name: Install through helm - if: steps.helm-install.success == 'false' + if: failure() run: helm install --name $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - name: Rollout new containers if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' && steps.helm-install.success == 'true' From 78057468b516a073c345049c943f066a4b535686 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2019 18:59:10 +0000 Subject: [PATCH 082/125] Bump symfony/cache from 4.3.4 to 4.3.9 in /api Bumps [symfony/cache](https://github.com/symfony/cache) from 4.3.4 to 4.3.9. - [Release notes](https://github.com/symfony/cache/releases) - [Changelog](https://github.com/symfony/cache/blob/master/CHANGELOG.md) - [Commits](https://github.com/symfony/cache/compare/v4.3.4...v4.3.9) Signed-off-by: dependabot[bot] --- api/composer.lock | 60 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/api/composer.lock b/api/composer.lock index cdf70a77..8f53d27f 100644 --- a/api/composer.lock +++ b/api/composer.lock @@ -2229,8 +2229,8 @@ "authors": [ { "name": "Luís Otávio Cobucci Oblonczyk", - "role": "Developer", - "email": "lcobucci@gmail.com" + "email": "lcobucci@gmail.com", + "role": "Developer" } ], "description": "A simple library to work with JSON Web Token and JSON Web Signature", @@ -3025,16 +3025,16 @@ }, { "name": "psr/log", - "version": "1.1.0", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" + "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", + "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", "shasum": "" }, "require": { @@ -3043,7 +3043,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { @@ -3068,7 +3068,7 @@ "psr", "psr-3" ], - "time": "2018-11-20T15:27:04+00:00" + "time": "2019-11-01T11:05:21+00:00" }, { "name": "ralouphie/getallheaders", @@ -3420,16 +3420,16 @@ }, { "name": "symfony/cache", - "version": "v4.3.4", + "version": "v4.3.9", "source": { "type": "git", "url": "https://github.com/symfony/cache.git", - "reference": "1d8f7fee990c586f275cde1a9fc883d6b1e2d43e" + "reference": "2a7bcc592adcaab9efc165bbced5a91fe905fad4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache/zipball/1d8f7fee990c586f275cde1a9fc883d6b1e2d43e", - "reference": "1d8f7fee990c586f275cde1a9fc883d6b1e2d43e", + "url": "https://api.github.com/repos/symfony/cache/zipball/2a7bcc592adcaab9efc165bbced5a91fe905fad4", + "reference": "2a7bcc592adcaab9efc165bbced5a91fe905fad4", "shasum": "" }, "require": { @@ -3494,20 +3494,20 @@ "caching", "psr6" ], - "time": "2019-08-26T08:26:39+00:00" + "time": "2019-12-01T10:50:31+00:00" }, { "name": "symfony/cache-contracts", - "version": "v1.1.5", + "version": "v1.1.7", "source": { "type": "git", "url": "https://github.com/symfony/cache-contracts.git", - "reference": "ec5524b669744b5f1dc9c66d3c2b091eb7e7f0db" + "reference": "af50d14ada9e4e82cfabfabdc502d144f89be0a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/ec5524b669744b5f1dc9c66d3c2b091eb7e7f0db", - "reference": "ec5524b669744b5f1dc9c66d3c2b091eb7e7f0db", + "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/af50d14ada9e4e82cfabfabdc502d144f89be0a1", + "reference": "af50d14ada9e4e82cfabfabdc502d144f89be0a1", "shasum": "" }, "require": { @@ -3552,7 +3552,7 @@ "interoperability", "standards" ], - "time": "2019-06-13T11:15:36+00:00" + "time": "2019-10-04T21:43:27+00:00" }, { "name": "symfony/config", @@ -6313,16 +6313,16 @@ }, { "name": "symfony/service-contracts", - "version": "v1.1.6", + "version": "v1.1.8", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "ea7263d6b6d5f798b56a45a5b8d686725f2719a3" + "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ea7263d6b6d5f798b56a45a5b8d686725f2719a3", - "reference": "ea7263d6b6d5f798b56a45a5b8d686725f2719a3", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ffc7f5692092df31515df2a5ecf3b7302b3ddacf", + "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf", "shasum": "" }, "require": { @@ -6367,7 +6367,7 @@ "interoperability", "standards" ], - "time": "2019-08-20T14:44:19+00:00" + "time": "2019-10-14T12:27:06+00:00" }, { "name": "symfony/stopwatch", @@ -6749,28 +6749,28 @@ }, { "name": "symfony/var-exporter", - "version": "v4.3.4", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "d5b4e2d334c1d80e42876c7d489896cfd37562f2" + "reference": "e566070effe60b8d16b99e958cdbd92aa2e470cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/d5b4e2d334c1d80e42876c7d489896cfd37562f2", - "reference": "d5b4e2d334c1d80e42876c7d489896cfd37562f2", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/e566070effe60b8d16b99e958cdbd92aa2e470cb", + "reference": "e566070effe60b8d16b99e958cdbd92aa2e470cb", "shasum": "" }, "require": { "php": "^7.1.3" }, "require-dev": { - "symfony/var-dumper": "^4.1.1" + "symfony/var-dumper": "^4.1.1|^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -6805,7 +6805,7 @@ "instantiate", "serialize" ], - "time": "2019-08-22T07:33:08+00:00" + "time": "2019-12-01T08:39:58+00:00" }, { "name": "symfony/web-link", From 17d2e31d35d09ef9672eb3aca08d5ab9abbe7873 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2019 20:09:32 +0000 Subject: [PATCH 083/125] Bump symfony/security-http from 4.3.4 to 4.3.9 in /api Bumps [symfony/security-http](https://github.com/symfony/security-http) from 4.3.4 to 4.3.9. - [Release notes](https://github.com/symfony/security-http/releases) - [Commits](https://github.com/symfony/security-http/compare/v4.3.4...v4.3.9) Signed-off-by: dependabot[bot] --- api/composer.lock | 230 +++++++++++++++++++++++----------------------- 1 file changed, 117 insertions(+), 113 deletions(-) diff --git a/api/composer.lock b/api/composer.lock index cdf70a77..71601ac8 100644 --- a/api/composer.lock +++ b/api/composer.lock @@ -2229,8 +2229,8 @@ "authors": [ { "name": "Luís Otávio Cobucci Oblonczyk", - "role": "Developer", - "email": "lcobucci@gmail.com" + "email": "lcobucci@gmail.com", + "role": "Developer" } ], "description": "A simple library to work with JSON Web Token and JSON Web Signature", @@ -3025,16 +3025,16 @@ }, { "name": "psr/log", - "version": "1.1.0", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" + "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", + "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", "shasum": "" }, "require": { @@ -3043,7 +3043,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { @@ -3068,7 +3068,7 @@ "psr", "psr-3" ], - "time": "2018-11-20T15:27:04+00:00" + "time": "2019-11-01T11:05:21+00:00" }, { "name": "ralouphie/getallheaders", @@ -3766,16 +3766,16 @@ }, { "name": "symfony/debug", - "version": "v4.3.4", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "afcdea44a2e399c1e4b52246ec8d54c715393ced" + "reference": "b8600a1d7d20b0e80906398bb1f50612fa074a8e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/afcdea44a2e399c1e4b52246ec8d54c715393ced", - "reference": "afcdea44a2e399c1e4b52246ec8d54c715393ced", + "url": "https://api.github.com/repos/symfony/debug/zipball/b8600a1d7d20b0e80906398bb1f50612fa074a8e", + "reference": "b8600a1d7d20b0e80906398bb1f50612fa074a8e", "shasum": "" }, "require": { @@ -3786,12 +3786,12 @@ "symfony/http-kernel": "<3.4" }, "require-dev": { - "symfony/http-kernel": "~3.4|~4.0" + "symfony/http-kernel": "^3.4|^4.0|^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -3818,7 +3818,7 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2019-08-20T14:27:59+00:00" + "time": "2019-11-28T13:33:56+00:00" }, { "name": "symfony/dependency-injection", @@ -4103,16 +4103,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v4.3.4", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "429d0a1451d4c9c4abe1959b2986b88794b9b7d2" + "reference": "b3c3068a72623287550fe20b84a2b01dcba2686f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/429d0a1451d4c9c4abe1959b2986b88794b9b7d2", - "reference": "429d0a1451d4c9c4abe1959b2986b88794b9b7d2", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b3c3068a72623287550fe20b84a2b01dcba2686f", + "reference": "b3c3068a72623287550fe20b84a2b01dcba2686f", "shasum": "" }, "require": { @@ -4128,12 +4128,12 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/expression-language": "~3.4|~4.0", - "symfony/http-foundation": "^3.4|^4.0", - "symfony/service-contracts": "^1.1", - "symfony/stopwatch": "~3.4|~4.0" + "symfony/config": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/expression-language": "^3.4|^4.0|^5.0", + "symfony/http-foundation": "^3.4|^4.0|^5.0", + "symfony/service-contracts": "^1.1|^2", + "symfony/stopwatch": "^3.4|^4.0|^5.0" }, "suggest": { "symfony/dependency-injection": "", @@ -4142,7 +4142,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -4169,20 +4169,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2019-08-26T08:55:16+00:00" + "time": "2019-11-28T13:33:56+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v1.1.5", + "version": "v1.1.7", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "c61766f4440ca687de1084a5c00b08e167a2575c" + "reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c61766f4440ca687de1084a5c00b08e167a2575c", - "reference": "c61766f4440ca687de1084a5c00b08e167a2575c", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c43ab685673fb6c8d84220c77897b1d6cdbe1d18", + "reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18", "shasum": "" }, "require": { @@ -4227,7 +4227,7 @@ "interoperability", "standards" ], - "time": "2019-06-20T06:46:26+00:00" + "time": "2019-09-17T09:54:03+00:00" }, { "name": "symfony/expression-language", @@ -4756,31 +4756,31 @@ }, { "name": "symfony/http-foundation", - "version": "v4.3.4", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "d804bea118ff340a12e22a79f9c7e7eb56b35adc" + "reference": "8bccc59e61b41963d14c3dbdb23181e5c932a1d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/d804bea118ff340a12e22a79f9c7e7eb56b35adc", - "reference": "d804bea118ff340a12e22a79f9c7e7eb56b35adc", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/8bccc59e61b41963d14c3dbdb23181e5c932a1d5", + "reference": "8bccc59e61b41963d14c3dbdb23181e5c932a1d5", "shasum": "" }, "require": { "php": "^7.1.3", - "symfony/mime": "^4.3", + "symfony/mime": "^4.3|^5.0", "symfony/polyfill-mbstring": "~1.1" }, "require-dev": { "predis/predis": "~1.0", - "symfony/expression-language": "~3.4|~4.0" + "symfony/expression-language": "^3.4|^4.0|^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -4807,20 +4807,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2019-08-26T08:55:16+00:00" + "time": "2019-11-28T13:33:56+00:00" }, { "name": "symfony/http-kernel", - "version": "v4.3.4", + "version": "v4.3.9", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "5e0fc71be03d52cd00c423061cfd300bd6f92a52" + "reference": "3feb99b01560f94173d8fbc5a203ea497d01d499" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/5e0fc71be03d52cd00c423061cfd300bd6f92a52", - "reference": "5e0fc71be03d52cd00c423061cfd300bd6f92a52", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/3feb99b01560f94173d8fbc5a203ea497d01d499", + "reference": "3feb99b01560f94173d8fbc5a203ea497d01d499", "shasum": "" }, "require": { @@ -4899,20 +4899,20 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2019-08-26T16:47:42+00:00" + "time": "2019-12-01T14:00:23+00:00" }, { "name": "symfony/inflector", - "version": "v4.3.4", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/symfony/inflector.git", - "reference": "b25a8dc15fada858432efa083c1ecd2cef5991a7" + "reference": "98581481d9ddabe4db3a66e10202fe1fa08d791b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/inflector/zipball/b25a8dc15fada858432efa083c1ecd2cef5991a7", - "reference": "b25a8dc15fada858432efa083c1ecd2cef5991a7", + "url": "https://api.github.com/repos/symfony/inflector/zipball/98581481d9ddabe4db3a66e10202fe1fa08d791b", + "reference": "98581481d9ddabe4db3a66e10202fe1fa08d791b", "shasum": "" }, "require": { @@ -4922,7 +4922,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -4957,7 +4957,7 @@ "symfony", "words" ], - "time": "2019-08-06T18:44:23+00:00" + "time": "2019-11-06T12:02:32+00:00" }, { "name": "symfony/intl", @@ -5226,16 +5226,16 @@ }, { "name": "symfony/mime", - "version": "v4.3.4", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "987a05df1c6ac259b34008b932551353f4f408df" + "reference": "010cc488e56cafe5f7494dea70aea93100c234df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/987a05df1c6ac259b34008b932551353f4f408df", - "reference": "987a05df1c6ac259b34008b932551353f4f408df", + "url": "https://api.github.com/repos/symfony/mime/zipball/010cc488e56cafe5f7494dea70aea93100c234df", + "reference": "010cc488e56cafe5f7494dea70aea93100c234df", "shasum": "" }, "require": { @@ -5243,14 +5243,17 @@ "symfony/polyfill-intl-idn": "^1.10", "symfony/polyfill-mbstring": "^1.0" }, + "conflict": { + "symfony/mailer": "<4.4" + }, "require-dev": { "egulias/email-validator": "^2.1.10", - "symfony/dependency-injection": "~3.4|^4.1" + "symfony/dependency-injection": "^3.4|^4.1|^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -5281,7 +5284,7 @@ "mime", "mime-type" ], - "time": "2019-08-22T08:16:11+00:00" + "time": "2019-11-30T08:27:26+00:00" }, { "name": "symfony/options-resolver", @@ -5397,16 +5400,16 @@ }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.12.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "6af626ae6fa37d396dc90a399c0ff08e5cfc45b2" + "reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6af626ae6fa37d396dc90a399c0ff08e5cfc45b2", - "reference": "6af626ae6fa37d396dc90a399c0ff08e5cfc45b2", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6f9c239e61e1b0c9229a28ff89a812dc449c3d46", + "reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46", "shasum": "" }, "require": { @@ -5420,7 +5423,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -5455,20 +5458,20 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2019-11-27T13:56:44+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.12.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", "shasum": "" }, "require": { @@ -5480,7 +5483,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -5514,20 +5517,20 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2019-11-27T14:18:11+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.12.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "04ce3335667451138df4307d6a9b61565560199e" + "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/04ce3335667451138df4307d6a9b61565560199e", - "reference": "04ce3335667451138df4307d6a9b61565560199e", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/66fea50f6cb37a35eea048d75a7d99a45b586038", + "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038", "shasum": "" }, "require": { @@ -5536,7 +5539,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -5569,20 +5572,20 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2019-11-27T13:56:44+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.12.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188" + "reference": "4b0e2222c55a25b4541305a053013d5647d3a25f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/2ceb49eaccb9352bff54d22570276bb75ba4a188", - "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/4b0e2222c55a25b4541305a053013d5647d3a25f", + "reference": "4b0e2222c55a25b4541305a053013d5647d3a25f", "shasum": "" }, "require": { @@ -5591,7 +5594,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -5627,7 +5630,7 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2019-11-27T16:25:15+00:00" }, { "name": "symfony/process", @@ -5680,24 +5683,24 @@ }, { "name": "symfony/property-access", - "version": "v4.3.4", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/symfony/property-access.git", - "reference": "bb0c302375ffeef60c31e72a4539611b7f787565" + "reference": "bafdc8c3a9d2671af4a81baec0fcc4687c0c17bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/property-access/zipball/bb0c302375ffeef60c31e72a4539611b7f787565", - "reference": "bb0c302375ffeef60c31e72a4539611b7f787565", + "url": "https://api.github.com/repos/symfony/property-access/zipball/bafdc8c3a9d2671af4a81baec0fcc4687c0c17bc", + "reference": "bafdc8c3a9d2671af4a81baec0fcc4687c0c17bc", "shasum": "" }, "require": { "php": "^7.1.3", - "symfony/inflector": "~3.4|~4.0" + "symfony/inflector": "^3.4|^4.0|^5.0" }, "require-dev": { - "symfony/cache": "~3.4|~4.0" + "symfony/cache": "^3.4|^4.0|^5.0" }, "suggest": { "psr/cache-implementation": "To cache access methods." @@ -5705,7 +5708,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -5743,7 +5746,7 @@ "property path", "reflection" ], - "time": "2019-08-26T08:26:39+00:00" + "time": "2019-12-01T10:50:45+00:00" }, { "name": "symfony/property-info", @@ -5983,35 +5986,36 @@ }, { "name": "symfony/security-core", - "version": "v4.3.4", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/symfony/security-core.git", - "reference": "a8c67a8bc6bd8012c5d6b70cb030ca3422476caa" + "reference": "312c91f90786fd7add89e8542cfc98543f0e60db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/security-core/zipball/a8c67a8bc6bd8012c5d6b70cb030ca3422476caa", - "reference": "a8c67a8bc6bd8012c5d6b70cb030ca3422476caa", + "url": "https://api.github.com/repos/symfony/security-core/zipball/312c91f90786fd7add89e8542cfc98543f0e60db", + "reference": "312c91f90786fd7add89e8542cfc98543f0e60db", "shasum": "" }, "require": { "php": "^7.1.3", - "symfony/event-dispatcher-contracts": "^1.1", - "symfony/service-contracts": "^1.1" + "symfony/event-dispatcher-contracts": "^1.1|^2", + "symfony/service-contracts": "^1.1.6|^2" }, "conflict": { - "symfony/event-dispatcher": "<4.3", + "symfony/event-dispatcher": "<4.3|>=5", + "symfony/ldap": "<4.4", "symfony/security-guard": "<4.3" }, "require-dev": { "psr/container": "^1.0", "psr/log": "~1.0", "symfony/event-dispatcher": "^4.3", - "symfony/expression-language": "~3.4|~4.0", - "symfony/http-foundation": "~3.4|~4.0", - "symfony/ldap": "~3.4|~4.0", - "symfony/validator": "^3.4.31|^4.3.4" + "symfony/expression-language": "^3.4|^4.0|^5.0", + "symfony/http-foundation": "^3.4|^4.0|^5.0", + "symfony/ldap": "^4.4|^5.0", + "symfony/validator": "^3.4.31|^4.3.4|^5.0" }, "suggest": { "psr/container-implementation": "To instantiate the Security class", @@ -6024,7 +6028,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -6051,7 +6055,7 @@ ], "description": "Symfony Security Component - Core Library", "homepage": "https://symfony.com", - "time": "2019-08-26T08:55:16+00:00" + "time": "2019-11-20T10:44:55+00:00" }, { "name": "symfony/security-csrf", @@ -6168,16 +6172,16 @@ }, { "name": "symfony/security-http", - "version": "v4.3.4", + "version": "v4.3.9", "source": { "type": "git", "url": "https://github.com/symfony/security-http.git", - "reference": "65281f9b7c7a77cccaa5b89026ef2a02940dc2cc" + "reference": "75e96df3a1b9b38c67e2fa208894f72dae5e1147" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/security-http/zipball/65281f9b7c7a77cccaa5b89026ef2a02940dc2cc", - "reference": "65281f9b7c7a77cccaa5b89026ef2a02940dc2cc", + "url": "https://api.github.com/repos/symfony/security-http/zipball/75e96df3a1b9b38c67e2fa208894f72dae5e1147", + "reference": "75e96df3a1b9b38c67e2fa208894f72dae5e1147", "shasum": "" }, "require": { @@ -6229,7 +6233,7 @@ ], "description": "Symfony Security Component - HTTP Integration", "homepage": "https://symfony.com", - "time": "2019-08-26T08:26:39+00:00" + "time": "2019-11-30T13:16:45+00:00" }, { "name": "symfony/serializer", @@ -6313,16 +6317,16 @@ }, { "name": "symfony/service-contracts", - "version": "v1.1.6", + "version": "v1.1.8", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "ea7263d6b6d5f798b56a45a5b8d686725f2719a3" + "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ea7263d6b6d5f798b56a45a5b8d686725f2719a3", - "reference": "ea7263d6b6d5f798b56a45a5b8d686725f2719a3", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ffc7f5692092df31515df2a5ecf3b7302b3ddacf", + "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf", "shasum": "" }, "require": { @@ -6367,7 +6371,7 @@ "interoperability", "standards" ], - "time": "2019-08-20T14:44:19+00:00" + "time": "2019-10-14T12:27:06+00:00" }, { "name": "symfony/stopwatch", From 5cf3c7029807a3c0fb443b726f58d62aa81162e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2019 23:27:35 +0000 Subject: [PATCH 084/125] Bump symfony/http-foundation from 4.3.4 to 4.4.1 in /api Bumps [symfony/http-foundation](https://github.com/symfony/http-foundation) from 4.3.4 to 4.4.1. - [Release notes](https://github.com/symfony/http-foundation/releases) - [Changelog](https://github.com/symfony/http-foundation/blob/master/CHANGELOG.md) - [Commits](https://github.com/symfony/http-foundation/compare/v4.3.4...v4.4.1) Signed-off-by: dependabot[bot] --- api/composer.lock | 73 ++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/api/composer.lock b/api/composer.lock index cdf70a77..ad43758d 100644 --- a/api/composer.lock +++ b/api/composer.lock @@ -2229,8 +2229,8 @@ "authors": [ { "name": "Luís Otávio Cobucci Oblonczyk", - "role": "Developer", - "email": "lcobucci@gmail.com" + "email": "lcobucci@gmail.com", + "role": "Developer" } ], "description": "A simple library to work with JSON Web Token and JSON Web Signature", @@ -4756,31 +4756,31 @@ }, { "name": "symfony/http-foundation", - "version": "v4.3.4", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "d804bea118ff340a12e22a79f9c7e7eb56b35adc" + "reference": "8bccc59e61b41963d14c3dbdb23181e5c932a1d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/d804bea118ff340a12e22a79f9c7e7eb56b35adc", - "reference": "d804bea118ff340a12e22a79f9c7e7eb56b35adc", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/8bccc59e61b41963d14c3dbdb23181e5c932a1d5", + "reference": "8bccc59e61b41963d14c3dbdb23181e5c932a1d5", "shasum": "" }, "require": { "php": "^7.1.3", - "symfony/mime": "^4.3", + "symfony/mime": "^4.3|^5.0", "symfony/polyfill-mbstring": "~1.1" }, "require-dev": { "predis/predis": "~1.0", - "symfony/expression-language": "~3.4|~4.0" + "symfony/expression-language": "^3.4|^4.0|^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -4807,7 +4807,7 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2019-08-26T08:55:16+00:00" + "time": "2019-11-28T13:33:56+00:00" }, { "name": "symfony/http-kernel", @@ -5226,16 +5226,16 @@ }, { "name": "symfony/mime", - "version": "v4.3.4", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "987a05df1c6ac259b34008b932551353f4f408df" + "reference": "010cc488e56cafe5f7494dea70aea93100c234df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/987a05df1c6ac259b34008b932551353f4f408df", - "reference": "987a05df1c6ac259b34008b932551353f4f408df", + "url": "https://api.github.com/repos/symfony/mime/zipball/010cc488e56cafe5f7494dea70aea93100c234df", + "reference": "010cc488e56cafe5f7494dea70aea93100c234df", "shasum": "" }, "require": { @@ -5243,14 +5243,17 @@ "symfony/polyfill-intl-idn": "^1.10", "symfony/polyfill-mbstring": "^1.0" }, + "conflict": { + "symfony/mailer": "<4.4" + }, "require-dev": { "egulias/email-validator": "^2.1.10", - "symfony/dependency-injection": "~3.4|^4.1" + "symfony/dependency-injection": "^3.4|^4.1|^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -5281,7 +5284,7 @@ "mime", "mime-type" ], - "time": "2019-08-22T08:16:11+00:00" + "time": "2019-11-30T08:27:26+00:00" }, { "name": "symfony/options-resolver", @@ -5397,16 +5400,16 @@ }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.12.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "6af626ae6fa37d396dc90a399c0ff08e5cfc45b2" + "reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6af626ae6fa37d396dc90a399c0ff08e5cfc45b2", - "reference": "6af626ae6fa37d396dc90a399c0ff08e5cfc45b2", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6f9c239e61e1b0c9229a28ff89a812dc449c3d46", + "reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46", "shasum": "" }, "require": { @@ -5420,7 +5423,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -5455,20 +5458,20 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2019-11-27T13:56:44+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.12.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", "shasum": "" }, "require": { @@ -5480,7 +5483,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -5514,20 +5517,20 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2019-11-27T14:18:11+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.12.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "04ce3335667451138df4307d6a9b61565560199e" + "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/04ce3335667451138df4307d6a9b61565560199e", - "reference": "04ce3335667451138df4307d6a9b61565560199e", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/66fea50f6cb37a35eea048d75a7d99a45b586038", + "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038", "shasum": "" }, "require": { @@ -5536,7 +5539,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -5569,7 +5572,7 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2019-11-27T13:56:44+00:00" }, { "name": "symfony/polyfill-php73", From ff2e87ed5cfef34ab16ebc85b7d63e5912bad9e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2019 23:28:00 +0000 Subject: [PATCH 085/125] Bump symfony/mime from 4.3.4 to 4.4.1 in /api Bumps [symfony/mime](https://github.com/symfony/mime) from 4.3.4 to 4.4.1. - [Release notes](https://github.com/symfony/mime/releases) - [Changelog](https://github.com/symfony/mime/blob/master/CHANGELOG.md) - [Commits](https://github.com/symfony/mime/compare/v4.3.4...v4.4.1) Signed-off-by: dependabot[bot] --- api/composer.lock | 57 +++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/api/composer.lock b/api/composer.lock index cdf70a77..de842e26 100644 --- a/api/composer.lock +++ b/api/composer.lock @@ -2229,8 +2229,8 @@ "authors": [ { "name": "Luís Otávio Cobucci Oblonczyk", - "role": "Developer", - "email": "lcobucci@gmail.com" + "email": "lcobucci@gmail.com", + "role": "Developer" } ], "description": "A simple library to work with JSON Web Token and JSON Web Signature", @@ -5226,16 +5226,16 @@ }, { "name": "symfony/mime", - "version": "v4.3.4", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "987a05df1c6ac259b34008b932551353f4f408df" + "reference": "010cc488e56cafe5f7494dea70aea93100c234df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/987a05df1c6ac259b34008b932551353f4f408df", - "reference": "987a05df1c6ac259b34008b932551353f4f408df", + "url": "https://api.github.com/repos/symfony/mime/zipball/010cc488e56cafe5f7494dea70aea93100c234df", + "reference": "010cc488e56cafe5f7494dea70aea93100c234df", "shasum": "" }, "require": { @@ -5243,14 +5243,17 @@ "symfony/polyfill-intl-idn": "^1.10", "symfony/polyfill-mbstring": "^1.0" }, + "conflict": { + "symfony/mailer": "<4.4" + }, "require-dev": { "egulias/email-validator": "^2.1.10", - "symfony/dependency-injection": "~3.4|^4.1" + "symfony/dependency-injection": "^3.4|^4.1|^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -5281,7 +5284,7 @@ "mime", "mime-type" ], - "time": "2019-08-22T08:16:11+00:00" + "time": "2019-11-30T08:27:26+00:00" }, { "name": "symfony/options-resolver", @@ -5397,16 +5400,16 @@ }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.12.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "6af626ae6fa37d396dc90a399c0ff08e5cfc45b2" + "reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6af626ae6fa37d396dc90a399c0ff08e5cfc45b2", - "reference": "6af626ae6fa37d396dc90a399c0ff08e5cfc45b2", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6f9c239e61e1b0c9229a28ff89a812dc449c3d46", + "reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46", "shasum": "" }, "require": { @@ -5420,7 +5423,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -5455,20 +5458,20 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2019-11-27T13:56:44+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.12.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", "shasum": "" }, "require": { @@ -5480,7 +5483,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -5514,20 +5517,20 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2019-11-27T14:18:11+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.12.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "04ce3335667451138df4307d6a9b61565560199e" + "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/04ce3335667451138df4307d6a9b61565560199e", - "reference": "04ce3335667451138df4307d6a9b61565560199e", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/66fea50f6cb37a35eea048d75a7d99a45b586038", + "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038", "shasum": "" }, "require": { @@ -5536,7 +5539,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -5569,7 +5572,7 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2019-11-27T13:56:44+00:00" }, { "name": "symfony/polyfill-php73", From d8677202a6e9fbe1da58538c86a44050ee5dcfab Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Tue, 3 Dec 2019 14:17:36 +0100 Subject: [PATCH 086/125] Free 'Create Release' from install/upgrade lock. --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 9e8658ca..33e5189a 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -104,7 +104,7 @@ jobs: kubectl rollout restart deployment/$APP_NAME-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/$APP_NAME-varnish --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV - name: Create Release - if: contains( github.ref, 'master' ) + if: contains( github.ref, 'master' ) && steps.kubeconfig.outputs.success == 'true' && ( success() || failure() ) id: create_release uses: actions/create-release@v1 env: From a5a837bdfd2e5ed9c792ff76223513e65b4933fd Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 3 Dec 2019 15:35:38 +0100 Subject: [PATCH 087/125] Update on readme --- README.md | 64 ++++--------------------------------------------------- 1 file changed, 4 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 05a32c9b..9a4f20df 100644 --- a/README.md +++ b/README.md @@ -1,63 +1,7 @@ +# About this component -# Readme -------- -Welcome to the the VNG Common Ground proto component! -This "proto" component provides a plug and play solution for component generation on Common Ground. That means that it takes away all the hassle of setting op codebases, containers and following the VNG Api Standaard. It does all that for you! +## License +Copyright � [Gemeente 's-Hertogenbosch](https://www.s-hertogenbosch.nl/) 2019 -For that we use **[Api Platform](https://api-platform.com)**, a next-generation web framework designed to easily create API-first projects, without compromising extensibility and flexibility. - -Getting started -------- -Do you want to create your own Commonground component? Take a look at our in depht [tutorial](TUTORIAL.md) on spinning up your own component! - -The commonground bundle -------- -This repository uses the power of conductions [commonground bundle](https://packagist.org/packages/conduction/commongroundbundle) for symfony to provide common ground specific functionality based on the [VNG Api Strategie](https://docs.geostandaarden.nl/api/API-Strategie/). Including - -* Build in support for public API's like BAG (Kadaster), KVK (Kamer van Koophandel) -* Build in validators for common dutch variables like BSN (Burger service nummer), RSIN(), KVK(), BTW() -* AVG and VNG proof audit trails -* And [muchs more](https://packagist.org/packages/conduction/commongroundbundle) .... - -Be sure to read our [design considerations](/design.md) concerning the [VNG Api Strategie](https://docs.geostandaarden.nl/api/API-Strategie/). - - -Requesting features -------- -Do you need a feature that is not on this list? don't hesitate to send us a [feature request](https://github.com/ConductionNL/commonground-component/issues/new?assignees=&labels=&template=feature_request.md&title=). - -Staying up to date -------- - -## Features -------- -API Platform embraces open web standards (OpenAPI, JSON-LD, GraphQL, Hydra, HAL, JSONAPI, JWT, OAuth, HTTP...) and the [Linked Data](https://www.w3.org/standards/semanticweb/data) movement. Your API will automatically expose structured data in Schema.org/JSON-LD. -It means that your commonground application is usable **out of the box** with technologies of the semantic web. - -* Comes with a paired [React](https://reactjs.org/) application, to provide face to your code -* And a fully functional (and automatically updated) [React Admin](https://marmelab.com/react-admin/) backend to easily test and proof your component -* Design your own data model as plain old PHP classes or [**import an existing one**](https://api-platform.com/docs/schema-generator) - from the [Schema.org](https://schema.org/) vocabulary -* **Expose in minutes a hypermedia REST or a GraphQL API** with pagination, data validation, access control, relation embedding, - filters and error handling... -* Benefit from Content Negotiation: [GraphQL](http://graphql.org), [JSON-LD](http://json-ld.org), [Hydra](http://hydra-cg.com), - [HAL](http://stateless.co/hal_specification.html), [JSONAPI](https://jsonapi.org/), [YAML](http://yaml.org/), [JSON](http://www.json.org/), [XML](https://www.w3.org/XML/) and [CSV](https://www.ietf.org/rfc/rfc4180.txt) are supported out of the box -* Enjoy the **beautiful automatically generated API documentation** (Swagger/[OpenAPI](https://www.openapis.org/)) -* Add [**a convenient Material Design administration interface**](https://api-platform.com/docs/admin) built with [React](https://reactjs.org/) - without writing a line of code -* **Scaffold fully functional Progressive-Web-Apps and mobile apps** built with [React](https://api-platform.com/docs/client-generator/react), [Vue.js](https://api-platform.com/docs/client-generator/vuejs) or [React Native](https://api-platform.com/docs/client-generator/react-native) thanks to [the client - generator](https://api-platform.com/docs/client-generator) (a Vue.js generator is also available) -* Install a development environment and deploy your project in production using **[Docker](https://api-platform.com/docs/distribution#using-the-official-distribution-recommended)** and [Kubernetes](https://api-platform.com/docs/deployment/kubernetes) -* Easily add **[JSON Web Token](https://api-platform.com/docs/core/jwt) or [OAuth](https://oauth.net/) authentication** -* Create specs and tests with a **developer friendly API testing tool** on top of [Behat](http://behat.org/) -* use **thousands of Symfony bundles and React components** with API Platform -* reuse **all your Symfony and React skills**, benefit of the incredible amount of documentation available -* enjoy the popular [Doctrine ORM](http://www.doctrine-project.org/projects/orm.html) (used by default, but fully optional: - you can use the data provider you want, including but not limited to MongoDB and ElasticSearch) - - -Credits -------- - -Created by [Ruben van der Linde](https://www.conduction.nl/team) for conduction. But based on [api platform](https://api-platform.com) by [Kévin Dunglas](https://dunglas.fr). Commercial support for common ground components available from [Conduction](https://www.conduction.nl). +[Licensed under the EUPL](LICENCE.md) From b5b7c8a5fb618b650e028b462cc49e3d39935026 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Tue, 3 Dec 2019 15:37:27 +0100 Subject: [PATCH 088/125] Fix issue with rollout --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 33e5189a..5907d2d5 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -98,7 +98,7 @@ jobs: if: failure() run: helm install --name $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - name: Rollout new containers - if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' && steps.helm-install.success == 'true' + if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' && steps.helm-install.success == 'true' && success() run: | kubectl rollout restart deployment/$APP_NAME-php --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/$APP_NAME-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV From f7a9729c53050508cd0035f6087d151359b93f55 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Tue, 3 Dec 2019 16:18:57 +0100 Subject: [PATCH 089/125] (semi) definitive fix for rollout issue --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 5907d2d5..cfdb0166 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -98,7 +98,7 @@ jobs: if: failure() run: helm install --name $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1 - name: Rollout new containers - if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' && steps.helm-install.success == 'true' && success() + if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' && success() run: | kubectl rollout restart deployment/$APP_NAME-php --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/$APP_NAME-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV From dde1ed2bf348b02e7371862ce83034ddf41cee02 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Tue, 3 Dec 2019 16:51:28 +0100 Subject: [PATCH 090/125] Allow create release to fail --- .github/workflows/dockerimage.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index cfdb0166..176b4b14 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -107,6 +107,7 @@ jobs: if: contains( github.ref, 'master' ) && steps.kubeconfig.outputs.success == 'true' && ( success() || failure() ) id: create_release uses: actions/create-release@v1 + continue-on-error: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token with: From d937a5be2137591c3ed2ecf3505bffd0c669647b Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 4 Dec 2019 06:32:09 +0100 Subject: [PATCH 091/125] Tutorial updates --- .github/workflows/dockerimage.yml | 4 ++-- TUTORIAL.md | 30 ++++++++++-------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 9aa6baf6..9fd5d8a7 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -111,7 +111,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token with: - tag_name: $APP_BUILD - release_name: $APP_BUILD + tag_name: $APP_BUILD-${{ secrets.GITHUB_TOKEN }} + release_name: $APP_BUILD-${{ secrets.GITHUB_TOKEN }} draft: false prerelease: false diff --git a/TUTORIAL.md b/TUTORIAL.md index ed149d7b..356121e3 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -12,7 +12,7 @@ For the steps considering the generation of resources (or entities as symfony ca ## Setting up your enviroment -You can install docker-desktop from [the docker website](). +You can install docker-desktop from [the docker website](https://hub.docker.com/editions/community/docker-ce-desktop-windows). ## Generating your component (repository/codebase) @@ -26,7 +26,7 @@ After that you should be redirected to your own brand new repository. We ran a fork of the base Common Ground component, that means that we copied the code of the original project into a new repository. By doing so we made sure we have all the necessities for our component, including security and compliance with international standards. ## Spinning up your component -Before we can spin up our component we must first get a local copy from our repository, we can either do this through the command line (example here) or use a Git client. +Before we can spin up our component we must first get a local copy from our repository, we can either do this through the command line or use a Git client. For this example we're going to use GitKraken but you can use any tool you like, feel free to skip this part if you are already familiar with setting up a local clone of your repository. @@ -35,7 +35,7 @@ Open gitkraken press "clone a repo" and fill in the form (select where on your l You can now navigate to the folder where you just installed your code, it should contain some folders and files and generally look like this. We will get into the files later, lets first spin up our component! Open a command window (example) and browse to the folder where you just stuffed your code, navigating in a command window is done by cd, so for our example we could type -cd c:\repos\common-ground\my-component (if you installed your code on a different disk then where the cmd window opens first type : for example D: and hit enter to go to that disk, D in this case). We are now in our folder, so let's go! Type docker-compose up and hit enter. From now on whenever we describe a command line command we will document it as follows: +cd c:\repos\common-ground\my-component (if you installed your code on a different disk then where the cmd window opens first type : for example D: and hit enter to go to that disk, D in this case). We are now in our folder, so let's go! Type docker-compose up and hit enter. From now on whenever we describe a command line command we will document it as follows (the $ isn't actually typed but represents your folder structure): ```CLI $ docker-compose up @@ -45,8 +45,9 @@ Your computer should now start up your local development environment. Don't worr Open your browser type http://localhost/ as address and hit enter, you should now see your common ground component up and running. -### trouble shooting +### Trouble shooting When spinning up components we make extensive use of the cashing of docker, and use volumes to represent server disks. When running in to unexpected trouble always remember to clear your local docker vm with the -a command (removing image cash) + ```CLI $ docker system prune -a ``` @@ -62,7 +63,7 @@ You can now access your api at http://localhost:8080/, as you can see it's pre-l First let's remove the resources currently in the api, we can do that by just removing the resources form our code base, navigate to the folder where you stored your code and open the folder api/src/Entity , you can find the example entities (the symfony name for resources) there. Just delete all the php files in that folder. -Next let's add our own entities, we can do this in two ways, we can do old fashioned coding, but we can also use the build in maker bundle of the proto component, to quickly generate our entities for us (without the fuss of actual coding). +Next let's add our own resources, we can do this in two ways, we can do old fashioned coding, but we can also use the build in maker bundle of the proto component, to quickly generate our entities for us (without the fuss of actual coding). Let's open a new command line window and navigate to our root folder, exactly like we did under "spinning up your component". And then lets fire up maker bundle (make sure that your component is still running in your other command window). We can do so by the following command: @@ -170,7 +171,7 @@ class Organisation Keep in mind that we need to add the assert annotation to our class dependencies under 'use'. -More inforation on using validation can be found at the [symfony website](https://symfony.com/doc/current/validation.html), but it is als worth nothing that tis component comes pre packed with some typical NL validators like BSN. You can find those [here](). +More information on using validation can be found at the [symfony website](https://symfony.com/doc/current/validation.html), but it is als worth nothing that tis component comes pre packed with some typical NL validators like BSN. You can find those [here](). ## Using UUID As default doctrine uses auto increment integers as identifiers (1,2, etc). For modern web applications we however prefer the use of UUID's. (e.g. e2984465-190a-4562-829e-a8cca81aa35d). Why? Wel for one it is more secure integer id's are easily guessable and make it possible to "ask" endpoint about resources that you should not know about. But UUID's also have a benefit in future proofing the application. If we in the future want to merge a table with another table (for example because two organisations using a component perform a merger) then we would have to reassign al id's and relations if we where using int based id's (both tables would have a row 1,2 etc) with UUID's however the change of doubles range somewhere in the billions. Meaning that it is likely that we only need to either reidentify only a handful of rows or more likely none at al! Turning our entire migration into a copy paste action. @@ -199,20 +200,9 @@ with ```PHP //... - /** - * @var \Ramsey\Uuid\UuidInterface - * - * @ApiProperty( - * identifier=true, - * attributes={ - * "openapi_context"={ - * "description" = "The UUID identifier of this resource", - * "type"="string", - * "format"="uuid", - * "example"="e2984465-190a-4562-829e-a8cca81aa35d" - * } - * } - * ) + /** + * @var \Ramsey\Uuid\UuidInterface The UUID identifier of this resource + * @example e2984465-190a-4562-829e-a8cca81aa35d * * @Groups({"read"}) * @ORM\Id From 07ca03b4b7d5465820803f8db9e20c146af8dd63 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 08:16:49 +0100 Subject: [PATCH 092/125] Test with release name --- .github/workflows/test.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..01c84352 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,28 @@ +name: Test + +on: + pull_request: + branches: + - master + - staging + - development + push: + branches: + - master + - staging + - development + +jobs: + + build: + + runs-on: ubuntu-latest + steps: + - name: Export release code + id: export + if: (success() || failure()) + run: | + echo "##[set-output name=releasename]$APP_BUILD-$(git rev-parse --short HEAD)" + - run: echo "$RELEASE" + with: + RELEASE: ${{ steps.export.outputs.releasename }} From 41d0d72f11cd06e6dd6cb3fefc465f7340791177 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 08:17:07 +0100 Subject: [PATCH 093/125] (semi) definitive fix for rollout issue --- .github/workflows/test.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 01c84352..719f756a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,16 +1,9 @@ name: Test on: - pull_request: - branches: - - master - - staging - - development push: branches: - - master - - staging - - development + - dev-robert jobs: From ed2817f07652e6305bf93294f2155b868c666ae4 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 08:17:55 +0100 Subject: [PATCH 094/125] changed with to env --- .github/workflows/test.yml | 2 +- .idea/workspace.xml | 57 +++++++++++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 719f756a..5e00928f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,5 +17,5 @@ jobs: run: | echo "##[set-output name=releasename]$APP_BUILD-$(git rev-parse --short HEAD)" - run: echo "$RELEASE" - with: + env: RELEASE: ${{ steps.export.outputs.releasename }} diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 980cc0cb..ced0c1eb 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,8 +1,9 @@ - - + + + @@ -321,6 +365,11 @@ - \ No newline at end of file From 510426659a1a4a25039beb003545eff5051c2858 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 08:19:11 +0100 Subject: [PATCH 095/125] HEAD to GITHUB SHA --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5e00928f..8541c591 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: id: export if: (success() || failure()) run: | - echo "##[set-output name=releasename]$APP_BUILD-$(git rev-parse --short HEAD)" + echo "##[set-output name=releasename]$APP_BUILD-$(git rev-parse --short '$GITHUB_SHA')" - run: echo "$RELEASE" env: RELEASE: ${{ steps.export.outputs.releasename }} From fb928b7d699fb6040185d9a7f337ebfa82754a93 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 08:20:11 +0100 Subject: [PATCH 096/125] Short GITHUB_SHA --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8541c591..7736035e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: id: export if: (success() || failure()) run: | - echo "##[set-output name=releasename]$APP_BUILD-$(git rev-parse --short '$GITHUB_SHA')" + echo "##[set-output name=releasename]$APP_BUILD-$GITHUB_SHA" - run: echo "$RELEASE" env: RELEASE: ${{ steps.export.outputs.releasename }} From 50fb9c7d50308c12179475c518698a3f256b59d6 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 11:12:14 +0100 Subject: [PATCH 097/125] Removal of test script, adding release number/code --- .github/workflows/dockerimage.yml | 16 +++++++++++----- .github/workflows/test.yml | 21 --------------------- 2 files changed, 11 insertions(+), 26 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 176b4b14..786009b4 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -103,15 +103,21 @@ jobs: kubectl rollout restart deployment/$APP_NAME-php --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/$APP_NAME-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/$APP_NAME-varnish --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV + - name: Export release code + if: (success() || failure()) + id: releasecode + run: | + echo "##[set-output name=releasename]$APP_BUILD-$GITHUB_SHA" + - name: Create Release if: contains( github.ref, 'master' ) && steps.kubeconfig.outputs.success == 'true' && ( success() || failure() ) id: create_release uses: actions/create-release@v1 continue-on-error: true env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token with: - tag_name: $APP_BUILD - release_name: $APP_BUILD - draft: false - prerelease: false + tag_name: ${{ steps.releasecode.outputs.releasename }} + release_name: ${{ steps.releasecode.outputs.releasename }} + draft: false + prerelease: false diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 7736035e..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Test - -on: - push: - branches: - - dev-robert - -jobs: - - build: - - runs-on: ubuntu-latest - steps: - - name: Export release code - id: export - if: (success() || failure()) - run: | - echo "##[set-output name=releasename]$APP_BUILD-$GITHUB_SHA" - - run: echo "$RELEASE" - env: - RELEASE: ${{ steps.export.outputs.releasename }} From 6a09adb1a7e4b512bc4a57ee8575e9893d8ebffc Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 13:28:05 +0100 Subject: [PATCH 098/125] Github shortcode instead of full SHA (under test) --- .github/workflows/dockerimage.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 786009b4..c809fda7 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -107,7 +107,8 @@ jobs: if: (success() || failure()) id: releasecode run: | - echo "##[set-output name=releasename]$APP_BUILD-$GITHUB_SHA" + export RELEASE=$APP_BUILD-$(git rev-parse --short "$GITHUB_SHA") + echo "##[set-output name=releasename]$RELEASE" - name: Create Release if: contains( github.ref, 'master' ) && steps.kubeconfig.outputs.success == 'true' && ( success() || failure() ) From 9ddbb43cf6de1c5c066877a7db6f64e75fd1d969 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 13:46:13 +0100 Subject: [PATCH 099/125] Printing the release name, just to be sure --- .github/workflows/dockerimage.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index c809fda7..e4bffcf2 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -109,7 +109,10 @@ jobs: run: | export RELEASE=$APP_BUILD-$(git rev-parse --short "$GITHUB_SHA") echo "##[set-output name=releasename]$RELEASE" - + - name: Print release name + run: echo $RELEASENAME + env: + RELEASENAME: ${{ steps.releasecode.outputs.releasename }} - name: Create Release if: contains( github.ref, 'master' ) && steps.kubeconfig.outputs.success == 'true' && ( success() || failure() ) id: create_release From dbac038e026a74edfc2174f9f0c0b229921ac64c Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 13:46:47 +0100 Subject: [PATCH 100/125] Made print unconditional --- .github/workflows/dockerimage.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index e4bffcf2..070e4ee0 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -110,6 +110,7 @@ jobs: export RELEASE=$APP_BUILD-$(git rev-parse --short "$GITHUB_SHA") echo "##[set-output name=releasename]$RELEASE" - name: Print release name + if: (success() || failure()) run: echo $RELEASENAME env: RELEASENAME: ${{ steps.releasecode.outputs.releasename }} From 40ab8f5b418cdf479708c5a7174c1777d81eb469 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 14:07:40 +0100 Subject: [PATCH 101/125] Quotes be gone --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 070e4ee0..4f8b430e 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -107,7 +107,7 @@ jobs: if: (success() || failure()) id: releasecode run: | - export RELEASE=$APP_BUILD-$(git rev-parse --short "$GITHUB_SHA") + export RELEASE=$APP_BUILD-$(git rev-parse --short $GITHUB_SHA) echo "##[set-output name=releasename]$RELEASE" - name: Print release name if: (success() || failure()) From 8768eea03c27e7cce631618af42af422555f0f06 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 14:33:28 +0100 Subject: [PATCH 102/125] Moved creation of release name to prevent out-of-sync GITHUB_SHA --- .github/workflows/dockerimage.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 4f8b430e..3697caa5 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -19,6 +19,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 + - name: Export release code + if: (success() || failure()) + id: releasecode + run: | + export RELEASE=$APP_BUILD-$(git rev-parse --short $GITHUB_SHA) + echo "##[set-output name=releasename]$RELEASE" - name: Pulling old images, if any run: docker-compose pull --ignore-pull-failures - name: Setting APP_NAME @@ -103,12 +109,7 @@ jobs: kubectl rollout restart deployment/$APP_NAME-php --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/$APP_NAME-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/$APP_NAME-varnish --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV - - name: Export release code - if: (success() || failure()) - id: releasecode - run: | - export RELEASE=$APP_BUILD-$(git rev-parse --short $GITHUB_SHA) - echo "##[set-output name=releasename]$RELEASE" + - name: Print release name if: (success() || failure()) run: echo $RELEASENAME From 4f8839c3de558a346f8ed7e684639b25ec29a3eb Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 14:34:29 +0100 Subject: [PATCH 103/125] Also move print location of release name --- .github/workflows/dockerimage.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 3697caa5..7910c9cb 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -25,6 +25,11 @@ jobs: run: | export RELEASE=$APP_BUILD-$(git rev-parse --short $GITHUB_SHA) echo "##[set-output name=releasename]$RELEASE" + - name: Print release name + if: (success() || failure()) + run: echo $RELEASENAME + env: + RELEASENAME: ${{ steps.releasecode.outputs.releasename }} - name: Pulling old images, if any run: docker-compose pull --ignore-pull-failures - name: Setting APP_NAME @@ -110,11 +115,7 @@ jobs: kubectl rollout restart deployment/$APP_NAME-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/$APP_NAME-varnish --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV - - name: Print release name - if: (success() || failure()) - run: echo $RELEASENAME - env: - RELEASENAME: ${{ steps.releasecode.outputs.releasename }} + - name: Create Release if: contains( github.ref, 'master' ) && steps.kubeconfig.outputs.success == 'true' && ( success() || failure() ) id: create_release From 2e6167dc6df47cc427ccd02b5da5de95567c321b Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 4 Dec 2019 14:36:11 +0100 Subject: [PATCH 104/125] Moving does not make a difference and probably breaks stuff again --- .github/workflows/dockerimage.yml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 7910c9cb..4f8b430e 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -19,17 +19,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: Export release code - if: (success() || failure()) - id: releasecode - run: | - export RELEASE=$APP_BUILD-$(git rev-parse --short $GITHUB_SHA) - echo "##[set-output name=releasename]$RELEASE" - - name: Print release name - if: (success() || failure()) - run: echo $RELEASENAME - env: - RELEASENAME: ${{ steps.releasecode.outputs.releasename }} - name: Pulling old images, if any run: docker-compose pull --ignore-pull-failures - name: Setting APP_NAME @@ -114,8 +103,17 @@ jobs: kubectl rollout restart deployment/$APP_NAME-php --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/$APP_NAME-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV kubectl rollout restart deployment/$APP_NAME-varnish --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV - - + - name: Export release code + if: (success() || failure()) + id: releasecode + run: | + export RELEASE=$APP_BUILD-$(git rev-parse --short $GITHUB_SHA) + echo "##[set-output name=releasename]$RELEASE" + - name: Print release name + if: (success() || failure()) + run: echo $RELEASENAME + env: + RELEASENAME: ${{ steps.releasecode.outputs.releasename }} - name: Create Release if: contains( github.ref, 'master' ) && steps.kubeconfig.outputs.success == 'true' && ( success() || failure() ) id: create_release From af5d9540c53c66b3bcb6e47a2bf3930fa921ba89 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 4 Dec 2019 20:50:42 +0100 Subject: [PATCH 105/125] Updates to the ingress resource Should make the entire thing available on the ingres ip --- .env | 1 + api/config/packages/twig.yaml | 1 + api/helm/templates/configmap.yaml | 1 + api/helm/templates/ingress.yaml | 10 ++++------ api/helm/templates/php-deployment.yaml | 5 +++++ api/helm/values.yaml | 10 ++-------- api/templates/helm/Values.yaml.twig | 1 + docker-compose.yml | 1 + 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.env b/.env index 66007731..ce0fe0a0 100644 --- a/.env +++ b/.env @@ -27,6 +27,7 @@ APP_DESCRIPTION='Naast deze JSON rest API is er ook een [graphql](/graphql) inte # Documentation settings ################################################## +APP_DOMAIN=conduction.nl APP_DEMO=pc.zaakonline.nl APP_REPRO=https://github.com/ConductionNL/Proto-component-commonground diff --git a/api/config/packages/twig.yaml b/api/config/packages/twig.yaml index 1a687ce2..7d186ad6 100644 --- a/api/config/packages/twig.yaml +++ b/api/config/packages/twig.yaml @@ -14,6 +14,7 @@ twig: app_version: '%env(APP_VERSION)%' app_env: '%env(APP_ENV)%' app_debug: '%env(APP_DEBUG)%' + app_domain: '%env(APP_DOMAIN)%' app_demo: '%env(APP_DEMO)%' app_repro: '%env(APP_REPRO)%' app_description: '%env(APP_DESCRIPTION)%' diff --git a/api/helm/templates/configmap.yaml b/api/helm/templates/configmap.yaml index 55279410..d3b97459 100644 --- a/api/helm/templates/configmap.yaml +++ b/api/helm/templates/configmap.yaml @@ -16,6 +16,7 @@ data: app-version: {{ .Values.settings.version | quote }} app-repro: {{ .Values.settings.repro | quote }} app-demo: {{ .Values.settings.demo | quote }} + app-domain: {{ .Values.settings.domain | quote }} app-description: {{ .Values.settings.description | quote }} app-auth: {{ .Values.settings.authorisationEnabled | quote }} diff --git a/api/helm/templates/ingress.yaml b/api/helm/templates/ingress.yaml index 4437f785..6c924078 100644 --- a/api/helm/templates/ingress.yaml +++ b/api/helm/templates/ingress.yaml @@ -1,7 +1,7 @@ apiVersion: extensions/v1beta1 kind: Ingress metadata: - name: {{ template "fullname" . }} + name: {{ include "name" . }}-{{ .Values.settings.env }}-ingress labels: app.kubernetes.io/name: {{ include "name" . }}-ingress app.kubernetes.io/part-of: {{ include "name" . }} @@ -24,12 +24,10 @@ spec: {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} + - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} http: paths: - path: /* backend: - serviceName: {{ .serviceName }} - servicePort: {{ .servicePort | default 80 }} - {{- end }} + serviceName: {{ include "name" . }}-nginx + servicePort: 80 diff --git a/api/helm/templates/php-deployment.yaml b/api/helm/templates/php-deployment.yaml index 1b03232e..3f09ef5d 100644 --- a/api/helm/templates/php-deployment.yaml +++ b/api/helm/templates/php-deployment.yaml @@ -77,6 +77,11 @@ spec: configMapKeyRef: name: {{ template "fullname" . }} key: app-demo + - name: APP_DOMAIN + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: app-domain - name: APP_REPRO valueFrom: configMapKeyRef: diff --git a/api/helm/values.yaml b/api/helm/values.yaml index 6bf6d3b2..3e671e4d 100644 --- a/api/helm/values.yaml +++ b/api/helm/values.yaml @@ -11,11 +11,12 @@ settings: description: ''Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.'' repro: https://github.com/ConductionNL/Proto-component-commonground' demo: pc.zaakonline.nl + domain: conduction.nl env: dev debug: 1 replicaCount: 1 corsAllowOrigin: ['*'] - trustedHosts: '^(.+\.)?common-ground\.dev$|^(.+\.)?zaakonline\.nl$|^(.+\.)?conduction\.nl$|^example\.com$|^(.+\.)?178.128.142.152$|178.128.142.152|localhost' + trustedHosts: '^(.+\.)?conduction\.nl$|localhost' pullPolicy: Always # You will need these proxies on kubernetes trustedProxies: @@ -94,13 +95,6 @@ ingress: # - hosts: # - example.com # - mercure.example.com - hosts: - api: - host: example.com - serviceName: varnish - mercure: - host: mercure.example.com - serviceName: mercure resources: {} # We usually recommend not to specify default resources and to leave this as a conscious diff --git a/api/templates/helm/Values.yaml.twig b/api/templates/helm/Values.yaml.twig index 33aebbd8..40241105 100644 --- a/api/templates/helm/Values.yaml.twig +++ b/api/templates/helm/Values.yaml.twig @@ -10,6 +10,7 @@ settings: version: {{ app_version }} description: '{{ app_description }}' repro: {{ app_repro }}' + domain: {{ app_domain }} demo: {{ app_demo }} env: {{ app_env }} debug: {{ app_debug }} diff --git a/docker-compose.yml b/docker-compose.yml index 43498f17..68795b67 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,6 +36,7 @@ services: - APP_VERSION=${APP_VERSION} - APP_NAME=${APP_NAME} - APP_TITLE=${APP_TITLE} + - APP_DOMAIN=${APP_DOMAIN} - APP_DEMO=${APP_DEMO} - APP_REPRO=${APP_REPRO} - APP_DESCRIPTION=${APP_DESCRIPTION} From 086c40de8b0e331c409d83b2a95c4871c3bf516f Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Thu, 5 Dec 2019 06:47:14 +0100 Subject: [PATCH 106/125] Updated ingress for new domain routing --- .env | 4 ++++ INSTALLATION.md | 19 +++++++++++----- api/.env | 4 ++-- api/config/packages/twig.yaml | 5 ++++- api/helm/templates/ingress.yaml | 35 ++++++++++++++++++++++++++--- api/helm/values.yaml | 2 +- api/templates/helm/Values.yaml.twig | 2 +- docker-compose.yml | 2 ++ 8 files changed, 59 insertions(+), 14 deletions(-) diff --git a/.env b/.env index ce0fe0a0..71e479f4 100644 --- a/.env +++ b/.env @@ -23,6 +23,10 @@ APP_BUILD=dev # The description for this api APP_DESCRIPTION='Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.' +# The urls on wich this api is available +TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 +TRUSTED_HOSTS='^(.+\.)?conduction\.nl$|^(.+\.)?huwelijksplanner\.online$|^(.+\.)?larping\.eu$|^(.+\.)?common-ground\.nl$|^(.+\.)?trouwplanner\.online$|^(.+\.)?zaakonline\.nl$|localhost' + ################################################## # Documentation settings ################################################## diff --git a/INSTALLATION.md b/INSTALLATION.md index 05bad3ed..96ea76d5 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -4,6 +4,7 @@ This document dives a little bit deeper into installing your component on a kube ## Setting up helm + ## Setting up tiller Create the tiller service account: @@ -18,39 +19,45 @@ $ kubectl create clusterrolebinding tiller --clusterrole cluster-admin --service Now we can run helm init, which installs Tiller on our cluster, along with some local housekeeping tasks such as downloading the stable repo details: ```CLI -$ helm init --service-account tiller --kubeconfig="api/helm/kubeconfig.yaml" +$ helm init --service-account tiller --kubeconfig="kubeconfig.yaml" ``` To verify that Tiller is running, list the pods in the kube-system namespace: ```CLI -$ kubectl get pods --namespace kube-system --kubeconfig="api/helm/kubeconfig.yaml" +$ kubectl get pods --namespace kube-system --kubeconfig="kubeconfig.yaml" ``` The Tiller pod name begins with the prefix tiller-deploy-. Now that we've installed both Helm components, we're ready to use helm to install our first application. + +## Setting up ingress +We need at least one nginx controller per kubernetes kluster, doh optionally we could set on up on a per namebase basis + +helm install stable/nginx-ingress --name loadbalancer --kubeconfig="kubeconfig.yaml" + ## Setting up Kubernetes Dashboard After we installed helm and tiller we can easily use both to install kubernetes dashboard ```CLI -$ helm install stable/kubernetes-dashboard --name dashboard --kubeconfig="api/helm/kubeconfig.yaml" --namespace="kube-system" +$ helm install stable/kubernetes-dashboard --name dashboard --kubeconfig="kubeconfig.yaml" --namespace="kube-system" ``` But before we can login to tiller we need a token, we can get one of those trough the secrets. Get yourself a secret list by running the following command ```CLI -$ kubectl -n kube-system get secret --kubeconfig="api/helm/kubeconfig.yaml" +$ kubectl -n kube-system get secret --kubeconfig="kubeconfig.yaml" ``` Because we just bound tiller to our admin account and use tiller (trough helm) to manage our code deployment it makes sense to use the tiller token, lets look at the tiller secret (it should look something like "tiller-token-XXXXX" and ask for the corresponding token. ```CLI -$ kubectl -n kube-system describe secrets tiller-token-xxxxx --kubeconfig="api/helm/kubeconfig.yaml" +$ kubectl -n kube-system describe secrets tiller-token-xxxxx --kubeconfig="kubeconfig.yaml" ``` This should return the token, copy it to somewhere save (just the token not the other returned information) and start up a dashboard connection ```CLI -$kubectl proxy --kubeconfig="api/helm/kubeconfig.yaml" +$kubectl proxy --kubeconfig="kubeconfig.yaml" ``` This should proxy our dashboard to helm making it available trough our favorite browser and a simple link diff --git a/api/.env b/api/.env index a2472076..235c628f 100644 --- a/api/.env +++ b/api/.env @@ -27,8 +27,8 @@ CONDUCTION_COMMONGROUND_BAG_APIKEY=!ChangeMe! #APP_NAME='pc' APP_DESCRIPTION='Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.' APP_SECRET=!ChangeMe! -TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 -TRUSTED_HOSTS='^(.+\.)?localhost|api$' +#TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 +#TRUSTED_HOSTS='^(.+\.)?localhost|api$' ###< symfony/framework-bundle ### ###> symfony/framework-bundle ### diff --git a/api/config/packages/twig.yaml b/api/config/packages/twig.yaml index 7d186ad6..8284abd9 100644 --- a/api/config/packages/twig.yaml +++ b/api/config/packages/twig.yaml @@ -22,7 +22,10 @@ twig: app_auth: '%env(AUTH_ENABLED)%' app_audittrail: '%env(AUDITTRAIL_ENABLED)%' app_notification: '%env(NOTIFICATION_ENABLED)%' - app_health: '%env(HEALTH_ENABLED)%' + app_health: '%env(HEALTH_ENABLED)%' + + trusted_hosts: '%env(TRUSTED_HOSTS)%' + trusted_proxies: '%env(TRUSTED_PROXIES)%' nlx_outway: '%env(NLX_OUTWAY)%' nlx_inway: '%env(NLX_INWAY)%' diff --git a/api/helm/templates/ingress.yaml b/api/helm/templates/ingress.yaml index 6c924078..1c549535 100644 --- a/api/helm/templates/ingress.yaml +++ b/api/helm/templates/ingress.yaml @@ -24,10 +24,39 @@ spec: {{- end }} {{- end }} rules: + - #host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} + http: + paths: + - backend: + serviceName: {{ include "name" . }} + servicePort: 80 - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} http: paths: - - path: /* - backend: - serviceName: {{ include "name" . }}-nginx + - backend: + serviceName: {{ include "name" . }} + servicePort: 80 + - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.huwelijksplanner.online + http: + paths: + - backend: + serviceName: {{ include "name" . }} + servicePort: 80 + - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.trouwplanner.online + http: + paths: + - backend: + serviceName: {{ include "name" . }} + servicePort: 80 + - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.common-ground.nl + http: + paths: + - backend: + serviceName: {{ include "name" . }} + servicePort: 80 + - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.larping.eu + http: + paths: + - backend: + serviceName: {{ include "name" . }} servicePort: 80 diff --git a/api/helm/values.yaml b/api/helm/values.yaml index 3e671e4d..3f474c4a 100644 --- a/api/helm/values.yaml +++ b/api/helm/values.yaml @@ -16,7 +16,7 @@ settings: debug: 1 replicaCount: 1 corsAllowOrigin: ['*'] - trustedHosts: '^(.+\.)?conduction\.nl$|localhost' + trustedHosts: '^(.+\.)?conduction\.nl$|^(.+\.)?huwelijksplanner\.online$|^(.+\.)?larping\.eu$|^(.+\.)?common-ground\.nl$|^(.+\.)?trouwplanner\.online$|^(.+\.)?zaakonline\.nl$|localhost' pullPolicy: Always # You will need these proxies on kubernetes trustedProxies: diff --git a/api/templates/helm/Values.yaml.twig b/api/templates/helm/Values.yaml.twig index 40241105..8b6ef17f 100644 --- a/api/templates/helm/Values.yaml.twig +++ b/api/templates/helm/Values.yaml.twig @@ -16,7 +16,7 @@ settings: debug: {{ app_debug }} replicaCount: 1 corsAllowOrigin: ['*'] - trustedHosts: '^(.+\.)?common-ground\.dev$|^(.+\.)?zaakonline\.nl$|^(.+\.)?conduction\.nl$|^example\.com$|^(.+\.)?178.128.142.152$|178.128.142.152|localhost' + trustedHosts: {{ trusted_hosts }} pullPolicy: Always # You will need these proxies on kubernetes trustedProxies: diff --git a/docker-compose.yml b/docker-compose.yml index 68795b67..51c9655a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,6 +40,8 @@ services: - APP_DEMO=${APP_DEMO} - APP_REPRO=${APP_REPRO} - APP_DESCRIPTION=${APP_DESCRIPTION} + - TRUSTED_PROXIES=${TRUSTED_PROXIES} + - TRUSTED_HOSTS=${TRUSTED_HOSTS} - AUTH_ENABLED=${AUTH_ENABLED} - AUDITTRAIL_ENABLED=${AUDITTRAIL_ENABLED} - NOTIFICATION_ENABLED=${NOTIFICATION_ENABLED} From a170188ba5205b2b6880aba3062d6eef32bb0272 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Thu, 5 Dec 2019 08:26:36 +0100 Subject: [PATCH 107/125] test --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 71e479f4..483e5053 100644 --- a/.env +++ b/.env @@ -47,7 +47,7 @@ CONTAINER_REPRO=https://hub.docker.com/repository/docker/conduction/pc-php # Notifcation settings ################################################## -NOTIFICATION_ENABLED=false +NOTIFICATION_ENABLED=falsedxfddxf NOTIFICATION_PROVIDER=sasd NOTIFICATION_ENABLED_AUTHORIZATION=sasd From 03fb95557b97814220cb2e5c5ba0f69d80e0f53c Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Thu, 5 Dec 2019 11:06:22 +0100 Subject: [PATCH 108/125] Set component.domain instead of component.environment.domain when in prod --- api/helm/templates/ingress.yaml | 45 ++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/api/helm/templates/ingress.yaml b/api/helm/templates/ingress.yaml index 1c549535..9c651cc4 100644 --- a/api/helm/templates/ingress.yaml +++ b/api/helm/templates/ingress.yaml @@ -24,12 +24,44 @@ spec: {{- end }} {{- end }} rules: - - #host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} - http: - paths: - - backend: - serviceName: {{ include "name" . }} - servicePort: 80 +# - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} +# http: +# paths: +# - backend: +# serviceName: {{ include "name" . }} +# servicePort: 80 + {{- if .Values.settings.env == 'prod' -}} + - host: {{ .Values.settings.name }}.{{ .Values.settings.domain }} + http: + paths: + - backend: + serviceName: {{ include "name" . }} + servicePort: 80 + - host: {{ .Values.settings.name }}.huwelijksplanner.online + http: + paths: + - backend: + serviceName: {{ include "name" . }} + servicePort: 80 + - host: {{ .Values.settings.name }}.trouwplanner.online + http: + paths: + - backend: + serviceName: {{ include "name" . }} + servicePort: 80 + - host: {{ .Values.settings.name }}.common-ground.nl + http: + paths: + - backend: + serviceName: {{ include "name" . }} + servicePort: 80 + - host: {{ .Values.settings.name }}.larping.eu + http: + paths: + - backend: + serviceName: {{ include "name" . }} + servicePort: 80 + {{- else -}} - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} http: paths: @@ -60,3 +92,4 @@ spec: - backend: serviceName: {{ include "name" . }} servicePort: 80 + {{- end }} From 366c4fe9131704ae4ef56f1adc1ba30c027b1b67 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Thu, 5 Dec 2019 11:37:15 +0100 Subject: [PATCH 109/125] If then fix for ingress on prod env --- INSTALLATION.md | 12 ++++++------ api/helm/templates/ingress.yaml | 18 +++++++++++++++--- api/helm/values.yaml | 7 +++++++ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/INSTALLATION.md b/INSTALLATION.md index 96ea76d5..2e8410d6 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -72,16 +72,16 @@ $ helm dependency update ./api/helm ``` If you want to create a new instance ```CLI -$ helm install --name pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1,settings.loadbalancerEnabled=true -$ helm install --name pc-stag ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=stag --set settings.env=stag,settings.debug=0,settings.loadbalancerEnabled=true -$ helm install --name pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=prod --set settings.env=prod,settings.debug=0,settings.loadbalancerEnabled=true +$ helm install --name pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1 +$ helm install --name pc-stag ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=stag --set settings.env=stag,settings.debug=0 +$ helm install --name pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=prod --set settings.env=prod,settings.debug=0 ``` Or update if you want to update an existing one ```CLI -$ helm upgrade pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1,settings.loadbalancerEnabled=true -$ helm upgrade pc-stag ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=stag --set settings.env=stag,settings.debug=0,settings.loadbalancerEnabled=true -$ helm upgrade pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=prod --set settings.env=prod,settings.debug=0,settings.loadbalancerEnabled=true +$ helm upgrade pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1 +$ helm upgrade pc-stag ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=stag --set settings.env=stag,settings.debug=0 +$ helm upgrade pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=prod --set settings.env=prod,settings.debug=0 ``` Or del if you want to delete an existing one diff --git a/api/helm/templates/ingress.yaml b/api/helm/templates/ingress.yaml index 9c651cc4..ad27ed07 100644 --- a/api/helm/templates/ingress.yaml +++ b/api/helm/templates/ingress.yaml @@ -30,7 +30,7 @@ spec: # - backend: # serviceName: {{ include "name" . }} # servicePort: 80 - {{- if .Values.settings.env == 'prod' -}} + {{- if eq .Values.settings.env "prod" }} - host: {{ .Values.settings.name }}.{{ .Values.settings.domain }} http: paths: @@ -60,8 +60,14 @@ spec: paths: - backend: serviceName: {{ include "name" . }} - servicePort: 80 - {{- else -}} + servicePort: 80 + - host: {{ .Values.settings.name }}.zaakonline.eu + http: + paths: + - backend: + serviceName: {{ include "name" . }} + servicePort: 80 + {{- else }} - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} http: paths: @@ -92,4 +98,10 @@ spec: - backend: serviceName: {{ include "name" . }} servicePort: 80 + - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.zaakonline.nl + http: + paths: + - backend: + serviceName: {{ include "name" . }} + servicePort: 80 {{- end }} diff --git a/api/helm/values.yaml b/api/helm/values.yaml index 3f474c4a..11e81898 100644 --- a/api/helm/values.yaml +++ b/api/helm/values.yaml @@ -12,6 +12,13 @@ settings: repro: https://github.com/ConductionNL/Proto-component-commonground' demo: pc.zaakonline.nl domain: conduction.nl + domains: + - conduction.nl + - larping.eu + - zaakonline.nl + - huwelijksplanner.online + - trouwplanner.online + - common-ground.dev env: dev debug: 1 replicaCount: 1 From b02a0104d8aaae1404c02940563c58032c9e33fe Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Thu, 5 Dec 2019 11:58:27 +0100 Subject: [PATCH 110/125] Fix in yaml template --- api/helm/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/helm/values.yaml b/api/helm/values.yaml index 11e81898..3aab74a4 100644 --- a/api/helm/values.yaml +++ b/api/helm/values.yaml @@ -9,7 +9,7 @@ settings: title: Proto Component version: V.0.1 description: ''Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.'' - repro: https://github.com/ConductionNL/Proto-component-commonground' + repro: 'https://github.com/ConductionNL/Proto-component-commonground' demo: pc.zaakonline.nl domain: conduction.nl domains: From 705da9c0d3b1b90faef9d3176837e16135edbec1 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Thu, 5 Dec 2019 13:11:01 +0100 Subject: [PATCH 111/125] Update Values.yaml.twig --- api/templates/helm/Values.yaml.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/templates/helm/Values.yaml.twig b/api/templates/helm/Values.yaml.twig index 8b6ef17f..26d3ab44 100644 --- a/api/templates/helm/Values.yaml.twig +++ b/api/templates/helm/Values.yaml.twig @@ -9,7 +9,7 @@ settings: title: {{ app_title }} version: {{ app_version }} description: '{{ app_description }}' - repro: {{ app_repro }}' + repro: '{{ app_repro }}' domain: {{ app_domain }} demo: {{ app_demo }} env: {{ app_env }} From d2b9965e79789fd7dd518ccddd12c1594ebb2d41 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Thu, 5 Dec 2019 13:34:37 +0100 Subject: [PATCH 112/125] Trying to fix weird errors --- api/templates/helm/Values.yaml.twig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/templates/helm/Values.yaml.twig b/api/templates/helm/Values.yaml.twig index 26d3ab44..28b8fe07 100644 --- a/api/templates/helm/Values.yaml.twig +++ b/api/templates/helm/Values.yaml.twig @@ -16,24 +16,24 @@ settings: debug: {{ app_debug }} replicaCount: 1 corsAllowOrigin: ['*'] - trustedHosts: {{ trusted_hosts }} + trustedHosts: '^(.+\.)?conduction\.nl$|^(.+\.)?huwelijksplanner\.online$|^(.+\.)?larping\.eu$|^(.+\.)?common-ground\.nl$|^(.+\.)?trouwplanner\.online$|^(.+\.)?zaakonline\.nl$|localhost' pullPolicy: Always # You will need these proxies on kubernetes trustedProxies: - 10.0.0.0/8 - 172.16.0.0/12 - 192.168.0.0/16 - # If you are runnig a single component on a kubernetes cluster you can just easaliy enable the load balancer, if not you need to set up a multi component load balancer + # If you are runnig a single component on a kubernetes cluster you can just easaliy enable the load balancer, if not you need to set up a multi component load balancer loadbalancerEnabled: false # If you want to enable NLX you are requered to add the appropreate certificates to you nlx-settings folder (located in the /api folder) nlxInwayEnabled: {{ nlx_inway }} - # If you are runnig a single component on a kubernetes cluster you can just easaliy enable the load balancer, if not you need to set up a multi component load balancer + # If you are runnig a single component on a kubernetes cluster you can just easaliy enable the load balancer, if not you need to set up a multi component load balancer notificationEnabled: false audittrailEnabled: false authorisationEnabled: false healthEnabled: false archiveEnabled: false - + php: repository: docker.io/conduction/protocomponent-php From c74e1e4780be16fcd98c0dd987a781f67c6e7dca Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Thu, 5 Dec 2019 14:59:29 +0100 Subject: [PATCH 113/125] Fix a bug with env vs values --- .env | 16 ++++---- api/helm/values.yaml | 22 +++++------ api/public/schema/openapi.yaml | 57 +++++++++++++++++++++++++++-- api/templates/helm/Values.yaml.twig | 2 +- 4 files changed, 74 insertions(+), 23 deletions(-) diff --git a/.env b/.env index 483e5053..4bfa0eec 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ ################################################## -# -# General settings for your component +# +# General settings for your component # ################################################## @@ -18,14 +18,14 @@ APP_VERSION=V.0.1 APP_DEBUG=1 # What is the enviroment type you want to use for local production? (choose between dec,stag,prod, acce or test) APP_ENV=dev -# We use a build to tag images, this is swithced to the version on master and to env on other branches +# We use a build to tag images, this is swithced to the version on master and to env on other branches APP_BUILD=dev # The description for this api APP_DESCRIPTION='Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.' # The urls on wich this api is available TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 -TRUSTED_HOSTS='^(.+\.)?conduction\.nl$|^(.+\.)?huwelijksplanner\.online$|^(.+\.)?larping\.eu$|^(.+\.)?common-ground\.nl$|^(.+\.)?trouwplanner\.online$|^(.+\.)?zaakonline\.nl$|localhost' +TRUSTED_HOSTS=^(.+\.)?conduction\.nl$|^(.+\.)?huwelijksplanner\.online$|^(.+\.)?larping\.eu$|^(.+\.)?common-ground\.nl$|^(.+\.)?trouwplanner\.online$|^(.+\.)?zaakonline\.nl$|localhost ################################################## # Documentation settings @@ -78,17 +78,17 @@ HEALTH_ENABLED=false ARCHIVE_ENABLED=false ################################################## -# NLX Setup, read more at https://docs.nlx.io/get-started/# +# NLX Setup, read more at https://docs.nlx.io/get-started/# ################################################## # Do you want to provide an nlx outway? (option for your component to reach nlx services) -NLX_OUTWAY=true +NLX_OUTWAY=true # Do you want to provice an nlx inway (option for nlx services to reach your api) -NLX_INWAY=false +NLX_INWAY=false # NLX Certification Details -NLX_COUNTRY_NAME=Netherlands +NLX_COUNTRY_NAME=Netherlands NLX_STATE=Noord-Holland NLX_LOCALITY=Amsterdam NLX_ORGANIZATION_NAME=Conduction diff --git a/api/helm/values.yaml b/api/helm/values.yaml index 3aab74a4..7f4d3075 100644 --- a/api/helm/values.yaml +++ b/api/helm/values.yaml @@ -10,15 +10,8 @@ settings: version: V.0.1 description: ''Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.'' repro: 'https://github.com/ConductionNL/Proto-component-commonground' - demo: pc.zaakonline.nl domain: conduction.nl - domains: - - conduction.nl - - larping.eu - - zaakonline.nl - - huwelijksplanner.online - - trouwplanner.online - - common-ground.dev + demo: pc.zaakonline.nl env: dev debug: 1 replicaCount: 1 @@ -30,17 +23,17 @@ settings: - 10.0.0.0/8 - 172.16.0.0/12 - 192.168.0.0/16 - # If you are runnig a single component on a kubernetes cluster you can just easaliy enable the load balancer, if not you need to set up a multi component load balancer + # If you are runnig a single component on a kubernetes cluster you can just easaliy enable the load balancer, if not you need to set up a multi component load balancer loadbalancerEnabled: false # If you want to enable NLX you are requered to add the appropreate certificates to you nlx-settings folder (located in the /api folder) nlxInwayEnabled: false - # If you are runnig a single component on a kubernetes cluster you can just easaliy enable the load balancer, if not you need to set up a multi component load balancer + # If you are runnig a single component on a kubernetes cluster you can just easaliy enable the load balancer, if not you need to set up a multi component load balancer notificationEnabled: false audittrailEnabled: false authorisationEnabled: false healthEnabled: false archiveEnabled: false - + php: repository: docker.io/conduction/protocomponent-php @@ -102,6 +95,13 @@ ingress: # - hosts: # - example.com # - mercure.example.com + hosts: + api: + host: example.com + serviceName: varnish + mercure: + host: mercure.example.com + serviceName: mercure resources: {} # We usually recommend not to specify default resources and to leave this as a conscious diff --git a/api/public/schema/openapi.yaml b/api/public/schema/openapi.yaml index d3c1e631..3cd704c7 100644 --- a/api/public/schema/openapi.yaml +++ b/api/public/schema/openapi.yaml @@ -524,7 +524,7 @@ components: schemas: ExampleEntity-read: type: object - description: 'This is an example entity' + description: 'This is an example entity.' properties: id: readOnly: true @@ -535,11 +535,14 @@ components: description: description: 'The description of this example property' type: string + camelCase: + description: 'Proof that we camel case our api' + type: string required: - name ExampleEntity-write: type: object - description: 'This is an example entity' + description: 'This is an example entity.' required: - name properties: @@ -549,13 +552,61 @@ components: description: description: 'The description of this example property' type: string + camelCase: + description: 'Proof that we camel case our api' + type: string +definitions: + ExampleEntity-read: + properties: + id: + example: e2984465-190a-4562-829e-a8cca81aa35d + format: uuid + name: + example: 'My Group' + maxLength: 255 + description: + example: 'Is the best group ever' + maxLength: 2555 + camelCase: + example: 'Best api ever' + maxLength: 255 + required: + - name + ExampleEntity-write: + properties: + name: + example: 'My Group' + maxLength: 255 + description: + example: 'Is the best group ever' + maxLength: 2555 + camelCase: + example: 'Best api ever' + maxLength: 255 + required: + - name tags: - name: ExampleEntity description: | - This is an example entity + This is an example entity. With an adtional description, all in all its pritty nice [url](www.google.nl) +securityDefinitions: + JWT-Oauth: + type: oauth2 + authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' + flow: implicit + scopes: + read: 'read right to the ExampleEntity resource' + write: 'write right to the ExampleEntity resource' + JWT-Token: + type: apiKey + in: header + name: Authorization + scopes: + read: 'read right to the ExampleEntity resource' + write: 'write right to the ExampleEntity resource' host: irc.zaakonline.nl servers: - diff --git a/api/templates/helm/Values.yaml.twig b/api/templates/helm/Values.yaml.twig index 28b8fe07..8a8e6ae7 100644 --- a/api/templates/helm/Values.yaml.twig +++ b/api/templates/helm/Values.yaml.twig @@ -16,7 +16,7 @@ settings: debug: {{ app_debug }} replicaCount: 1 corsAllowOrigin: ['*'] - trustedHosts: '^(.+\.)?conduction\.nl$|^(.+\.)?huwelijksplanner\.online$|^(.+\.)?larping\.eu$|^(.+\.)?common-ground\.nl$|^(.+\.)?trouwplanner\.online$|^(.+\.)?zaakonline\.nl$|localhost' + trustedHosts: '{{ trusted_hosts }}' pullPolicy: Always # You will need these proxies on kubernetes trustedProxies: From 642f10ce234106f04e4fc1367728e59bb82ad7e0 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Thu, 5 Dec 2019 15:55:05 +0100 Subject: [PATCH 114/125] trigger another build --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 4bfa0eec..edfba234 100644 --- a/.env +++ b/.env @@ -48,7 +48,7 @@ CONTAINER_REPRO=https://hub.docker.com/repository/docker/conduction/pc-php ################################################## NOTIFICATION_ENABLED=falsedxfddxf -NOTIFICATION_PROVIDER=sasd +NOTIFICATION_PROVIDER=sasdasd NOTIFICATION_ENABLED_AUTHORIZATION=sasd ################################################## From d36e73b104d143b8812e8b3f255e244be0b5d31d Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 10 Dec 2019 07:19:08 +0100 Subject: [PATCH 115/125] Added sesnsio framework etxra bundle --- api/composer.json | 1 + api/composer.lock | 84 ++++++++++++++++++- api/config/bundles.php | 29 +++---- .../packages/sensio_framework_extra.yaml | 3 + api/symfony.lock | 12 +++ 5 files changed, 112 insertions(+), 17 deletions(-) create mode 100644 api/config/packages/sensio_framework_extra.yaml diff --git a/api/composer.json b/api/composer.json index 5f2cf5aa..bc7545a9 100644 --- a/api/composer.json +++ b/api/composer.json @@ -13,6 +13,7 @@ "phpdocumentor/reflection-docblock": "^4.3", "ramsey/uuid": "^3.8", "ramsey/uuid-doctrine": "^1.5", + "sensio/framework-extra-bundle": "^5.5", "sensiolabs/security-checker": "^6.0", "stof/doctrine-extensions-bundle": "^1.3", "symfony/console": "4.3.*", diff --git a/api/composer.lock b/api/composer.lock index 72f0df7f..3fc1d7d6 100644 --- a/api/composer.lock +++ b/api/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "38df876b57237e6be24848f1f8f637da", + "content-hash": "a5cf6c5b0e2fcb4b7558cd2635260c67", "packages": [ { "name": "api-platform/api-pack", @@ -2229,8 +2229,8 @@ "authors": [ { "name": "Luís Otávio Cobucci Oblonczyk", - "email": "lcobucci@gmail.com", - "role": "Developer" + "role": "Developer", + "email": "lcobucci@gmail.com" } ], "description": "A simple library to work with JSON Web Token and JSON Web Signature", @@ -3249,6 +3249,84 @@ ], "time": "2018-08-11T21:01:22+00:00" }, + { + "name": "sensio/framework-extra-bundle", + "version": "v5.5.1", + "source": { + "type": "git", + "url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git", + "reference": "dfc2c4df9f7d465a65c770e9feb578fe071636f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/dfc2c4df9f7d465a65c770e9feb578fe071636f7", + "reference": "dfc2c4df9f7d465a65c770e9feb578fe071636f7", + "shasum": "" + }, + "require": { + "doctrine/annotations": "^1.0", + "php": ">=7.1.3", + "symfony/config": "^4.3|^5.0", + "symfony/dependency-injection": "^4.3|^5.0", + "symfony/framework-bundle": "^4.3|^5.0", + "symfony/http-kernel": "^4.3|^5.0" + }, + "conflict": { + "doctrine/doctrine-cache-bundle": "<1.3.1" + }, + "require-dev": { + "doctrine/doctrine-bundle": "^1.11|^2.0", + "doctrine/orm": "^2.5", + "nyholm/psr7": "^1.1", + "symfony/browser-kit": "^4.3|^5.0", + "symfony/dom-crawler": "^4.3|^5.0", + "symfony/expression-language": "^4.3|^5.0", + "symfony/finder": "^4.3|^5.0", + "symfony/monolog-bridge": "^4.0|^5.0", + "symfony/monolog-bundle": "^3.2", + "symfony/phpunit-bridge": "^4.3.5|^5.0", + "symfony/psr-http-message-bridge": "^1.1", + "symfony/security-bundle": "^4.3|^5.0", + "symfony/twig-bundle": "^4.3|^5.0", + "symfony/yaml": "^4.3|^5.0", + "twig/twig": "^1.34|^2.4|^3.0" + }, + "suggest": { + "symfony/expression-language": "", + "symfony/psr-http-message-bridge": "To use the PSR-7 converters", + "symfony/security-bundle": "" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "5.5.x-dev" + } + }, + "autoload": { + "psr-4": { + "Sensio\\Bundle\\FrameworkExtraBundle\\": "src/" + }, + "exclude-from-classmap": [ + "/tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "This bundle provides a way to configure your controllers with annotations", + "keywords": [ + "annotations", + "controllers" + ], + "time": "2019-10-16T18:54:45+00:00" + }, { "name": "sensiolabs/security-checker", "version": "v6.0.3", diff --git a/api/config/bundles.php b/api/config/bundles.php index fa4a09fd..32cd19d9 100644 --- a/api/config/bundles.php +++ b/api/config/bundles.php @@ -1,19 +1,20 @@ ['all' => true], - Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], - Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true], - Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], - Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], - Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], - ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], - Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], - Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], - Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], - Conduction\CommonGroundBundle\CommonGroundBundle::class => ['all' => true], - Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], + Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], + Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], + Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], + Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true], + Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], + Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], + Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], + Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], + Conduction\CommonGroundBundle\CommonGroundBundle::class => ['all' => true], + Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], - Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['all' => true], - Tbbc\MoneyBundle\TbbcMoneyBundle::class => ['all' => true], + Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['all' => true], + Tbbc\MoneyBundle\TbbcMoneyBundle::class => ['all' => true], ]; diff --git a/api/config/packages/sensio_framework_extra.yaml b/api/config/packages/sensio_framework_extra.yaml new file mode 100644 index 00000000..1821ccc0 --- /dev/null +++ b/api/config/packages/sensio_framework_extra.yaml @@ -0,0 +1,3 @@ +sensio_framework_extra: + router: + annotations: false diff --git a/api/symfony.lock b/api/symfony.lock index be591f61..4942a3b5 100644 --- a/api/symfony.lock +++ b/api/symfony.lock @@ -226,6 +226,18 @@ "config/packages/ramsey_uuid_doctrine.yaml" ] }, + "sensio/framework-extra-bundle": { + "version": "5.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "5.2", + "ref": "fb7e19da7f013d0d422fa9bce16f5c510e27609b" + }, + "files": [ + "config/packages/sensio_framework_extra.yaml" + ] + }, "sensiolabs/security-checker": { "version": "4.0", "recipe": { From fd514c7d3209d73d3b756e88019cb8b5f55a08ab Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 10 Dec 2019 11:35:16 +0100 Subject: [PATCH 116/125] Test voor certbot --- .env | 13 +++ api/config/packages/twig.yaml | 7 ++ api/helm/templates/ingress.yaml | 100 +++++++++++++++---- api/helm/templates/lets-encrypt-job.yaml | 39 ++++++++ api/helm/templates/lets-encrypt-secret.yaml | 12 +++ api/helm/templates/lets-encrypt-service.yaml | 16 +++ api/templates/helm/Values.yaml.twig | 1 + 7 files changed, 167 insertions(+), 21 deletions(-) create mode 100644 api/helm/templates/lets-encrypt-job.yaml create mode 100644 api/helm/templates/lets-encrypt-secret.yaml create mode 100644 api/helm/templates/lets-encrypt-service.yaml diff --git a/.env b/.env index edfba234..d2f0c4c3 100644 --- a/.env +++ b/.env @@ -27,6 +27,19 @@ APP_DESCRIPTION='Naast deze JSON rest API is er ook een [graphql](/graphql) inte TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 TRUSTED_HOSTS=^(.+\.)?conduction\.nl$|^(.+\.)?huwelijksplanner\.online$|^(.+\.)?larping\.eu$|^(.+\.)?common-ground\.nl$|^(.+\.)?trouwplanner\.online$|^(.+\.)?zaakonline\.nl$|localhost +################################################## +# Orgization details +################################################## + +# The following details describe your organisations and are used for both certificate creation and common-ground.dev + +ORGANIZATION_NAME=Conduction +ORGANIZATION_EMAIL_ADDRESS=info@conduction.nl +ORGANIZATION_COUNTRY_NAME=Netherlands +ORGANIZATION_STATE=Noord-Holland +ORGANIZATION_LOCALITY=Amsterdam +ORGANIZATION_UNIT_NAME=Common-Ground + ################################################## # Documentation settings ################################################## diff --git a/api/config/packages/twig.yaml b/api/config/packages/twig.yaml index 8284abd9..26f06175 100644 --- a/api/config/packages/twig.yaml +++ b/api/config/packages/twig.yaml @@ -8,6 +8,13 @@ twig: container_registry_base: '%env(CONTAINER_REGISTRY_BASE)%' container_project_name: '%env(CONTAINER_PROJECT_NAME)%' + + organization_name: '%env(ORGANIZATION_NAME)%' + organization_email: '%env(ORGANIZATION_EMAIL_ADDRESS)%' + organization_country: '%env(ORGANIZATION_COUNTRY_NAME)%' + organization_state: '%env(ORGANIZATION_STATE)%' + organization_locality: '%env(ORGANIZATION_LOCALITY)%' + organization_unit: '%env(ORGANIZATION_UNIT_NAME)%' app_name: '%env(APP_NAME)%' app_title: '%env(APP_TITLE)%' diff --git a/api/helm/templates/ingress.yaml b/api/helm/templates/ingress.yaml index ad27ed07..d7cd7d40 100644 --- a/api/helm/templates/ingress.yaml +++ b/api/helm/templates/ingress.yaml @@ -13,16 +13,14 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} spec: -{{- if .Values.ingress.tls }} tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ .host | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} + - hosts: + {{- if eq .Values.settings.env "prod" }} + - {{ .Values.settings.domain }} + {{- else }} + - {{ .Values.settings.env }}.{{ .Values.settings.domain }} + {{- end }} + secretName: {{ include "name" . }}-certs rules: # - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} # http: @@ -34,74 +32,134 @@ spec: - host: {{ .Values.settings.name }}.{{ .Values.settings.domain }} http: paths: - - backend: + - path: /.well-known/* + backend: + serviceName: {{ include "name" . }}-letsencrypt + servicePort: 80 + - path: /* + backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.huwelijksplanner.online http: paths: - - backend: + - path: /.well-known/* + backend: + serviceName: {{ include "name" . }}-letsencrypt + servicePort: 80 + - path: /* + backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.trouwplanner.online http: paths: - - backend: + - path: /.well-known/* + backend: + serviceName: {{ include "name" . }}-letsencrypt + servicePort: 80 + - path: /* + backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.common-ground.nl http: paths: - - backend: + - path: /.well-known/* + backend: + serviceName: {{ include "name" . }}-letsencrypt + servicePort: 80 + - path: /* + backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.larping.eu http: paths: - - backend: + - path: /.well-known/* + backend: + serviceName: {{ include "name" . }}-letsencrypt + servicePort: 80 + - path: /* + backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.zaakonline.eu http: paths: - - backend: + - path: /.well-known/* + backend: + serviceName: {{ include "name" . }}-letsencrypt + servicePort: 80 + - path: /* + backend: serviceName: {{ include "name" . }} servicePort: 80 {{- else }} - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} http: paths: - - backend: + - path: /.well-known/* + backend: + serviceName: {{ include "name" . }}-letsencrypt + servicePort: 80 + - path: /* + backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.huwelijksplanner.online http: paths: - - backend: + - path: /.well-known/* + backend: + serviceName: {{ include "name" . }}-letsencrypt + servicePort: 80 + - path: /* + backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.trouwplanner.online http: paths: - - backend: + - path: /.well-known/* + backend: + serviceName: {{ include "name" . }}-letsencrypt + servicePort: 80 + - path: /* + backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.common-ground.nl http: paths: - - backend: + - path: /.well-known/* + backend: + serviceName: {{ include "name" . }}-letsencrypt + servicePort: 80 + - path: /* + backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.larping.eu http: paths: - - backend: + - path: /.well-known/* + backend: + serviceName: {{ include "name" . }}-letsencrypt + servicePort: 80 + - path: /* + backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.zaakonline.nl http: paths: - - backend: + - path: /.well-known/* + backend: + serviceName: {{ include "name" . }}-letsencrypt + servicePort: 80 + - path: /* + backend: serviceName: {{ include "name" . }} servicePort: 80 {{- end }} diff --git a/api/helm/templates/lets-encrypt-job.yaml b/api/helm/templates/lets-encrypt-job.yaml new file mode 100644 index 00000000..ee55da01 --- /dev/null +++ b/api/helm/templates/lets-encrypt-job.yaml @@ -0,0 +1,39 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ include "name" . }}-letsencrypt-job + labels: + app.kubernetes.io/name: {{ include "name" . }} + app.kubernetes.io/part-of: {{ include "name" . }} + helm.sh/chart: {{ include "chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + template: + metadata: + name: {{ include "name" . }}-letsencrypt + labels: + app: {{ include "name" . }}-letsencrypt + spec: + containers: + # Bash script that starts an http server and launches certbot + # Fork of github.com/sjenning/kube-nginx-letsencrypt + - image: quay.io/hiphipjorge/kube-nginx-letsencrypt:latest + name: letsencrypt + imagePullPolicy: Always + ports: + - name: letsencrypt + containerPort: 80 + env: + {{- if eq .Values.settings.env "prod" }} + - name: DOMAINS + value: { .Values.settings.domain }} + {{- else }} + - name: DOMAINS + value: {{ .Values.settings.env }}.{{ .Values.settings.domain }} + {{- end }} + - name: EMAIL + value: {{ .Values.settings.email }} + - name: SECRET + value: {{ include "name" . }}-letsencrypt-certs + restartPolicy: Never \ No newline at end of file diff --git a/api/helm/templates/lets-encrypt-secret.yaml b/api/helm/templates/lets-encrypt-secret.yaml new file mode 100644 index 00000000..4ea2960a --- /dev/null +++ b/api/helm/templates/lets-encrypt-secret.yaml @@ -0,0 +1,12 @@ +# An empty secret (with no data) in order for the update to work +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "fullname" . }}-letsencrypt-certs + labels: + app.kubernetes.io/name: {{ include "name" . }} + app.kubernetes.io/part-of: {{ include "name" . }} + helm.sh/chart: {{ include "chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +type: Opaque \ No newline at end of file diff --git a/api/helm/templates/lets-encrypt-service.yaml b/api/helm/templates/lets-encrypt-service.yaml new file mode 100644 index 00000000..48247ae1 --- /dev/null +++ b/api/helm/templates/lets-encrypt-service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "name" . }}-letsencrypt + labels: + app.kubernetes.io/name: {{ include "name" . }} + app.kubernetes.io/part-of: {{ include "name" . }} + helm.sh/chart: {{ include "chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + selector: + app: {{ include "name" . }}-letsencrypt + ports: + - protocol: "TCP" + port: 80 \ No newline at end of file diff --git a/api/templates/helm/Values.yaml.twig b/api/templates/helm/Values.yaml.twig index 8a8e6ae7..e9b28795 100644 --- a/api/templates/helm/Values.yaml.twig +++ b/api/templates/helm/Values.yaml.twig @@ -11,6 +11,7 @@ settings: description: '{{ app_description }}' repro: '{{ app_repro }}' domain: {{ app_domain }} + email: {{ organization_email }} demo: {{ app_demo }} env: {{ app_env }} debug: {{ app_debug }} From f0681520ce5f9b3fb972391c7c3a34bab6ac97aa Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 10 Dec 2019 14:47:53 +0100 Subject: [PATCH 117/125] Fixed certbot --- INSTALLATION.md | 42 ++++++++- api/helm/templates/cert-issuer.yaml | 16 ++++ api/helm/templates/certificate.yaml | 22 +++++ api/helm/templates/ingress.yaml | 96 ++++---------------- api/helm/templates/lets-encrypt-job.yaml | 39 -------- api/helm/templates/lets-encrypt-secret.yaml | 12 --- api/helm/templates/lets-encrypt-service.yaml | 16 ---- 7 files changed, 93 insertions(+), 150 deletions(-) create mode 100644 api/helm/templates/cert-issuer.yaml create mode 100644 api/helm/templates/certificate.yaml delete mode 100644 api/helm/templates/lets-encrypt-job.yaml delete mode 100644 api/helm/templates/lets-encrypt-secret.yaml delete mode 100644 api/helm/templates/lets-encrypt-service.yaml diff --git a/INSTALLATION.md b/INSTALLATION.md index 2e8410d6..5ed0a969 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -35,10 +35,19 @@ Now that we've installed both Helm components, we're ready to use helm to instal ## Setting up ingress We need at least one nginx controller per kubernetes kluster, doh optionally we could set on up on a per namebase basis -helm install stable/nginx-ingress --name loadbalancer --kubeconfig="kubeconfig.yaml" +```CLI +$ helm install stable/nginx-ingress --name loadbalancer --kubeconfig="kubeconfig.yaml" +``` + +We can check that out with + +```CLI +$ kubectl describe ingress pc-dev-ingress -n=kube-system --kubeconfig="kubeconfig.yaml" +``` ## Setting up Kubernetes Dashboard After we installed helm and tiller we can easily use both to install kubernetes dashboard + ```CLI $ helm install stable/kubernetes-dashboard --name dashboard --kubeconfig="kubeconfig.yaml" --namespace="kube-system" ``` @@ -57,7 +66,7 @@ $ kubectl -n kube-system describe secrets tiller-token-xxxxx --kubeconfig="kube This should return the token, copy it to somewhere save (just the token not the other returned information) and start up a dashboard connection ```CLI -$kubectl proxy --kubeconfig="kubeconfig.yaml" +$ kubectl proxy --kubeconfig="kubeconfig.yaml" ``` This should proxy our dashboard to helm making it available trough our favorite browser and a simple link @@ -65,6 +74,29 @@ This should proxy our dashboard to helm making it available trough our favorite http://localhost:8001/api/v1/namespaces/kube-system/services/https:dashboard-kubernetes-dashboard:https/proxy/#!/login ``` + +## Cert Manager +https://cert-manager.io/docs/installation/kubernetes/ + +```CLI +$ kubectl apply --validate=false -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.12/deploy/manifests/00-crds.yaml --kubeconfig="kubeconfig.yaml" +$ kubectl create namespace cert-manager --kubeconfig="kubeconfig.yaml" +``` + + The we need tp deploy the cert manager to our cluster + +```CLI +$ helm repo add jetstack https://charts.jetstack.io +$ helm install --name cert-manager --namespace cert-manager --version v0.12.0 \ jetstack/cert-manager --kubeconfig="kubeconfig.yaml" +``` + +lets check if everything is working + +```CLI +$ kubectl get pods --namespace cert-manager --kubeconfig="kubeconfig.yaml" +$ kubectl describe certificate -n dev --kubeconfig="kubeconfig.yaml" +``` + ## Deploying trough helm First we always need to update our dependencies ```CLI @@ -86,9 +118,9 @@ $ helm upgrade pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --name Or del if you want to delete an existing one ```CLI -$ helm del pc-dev --purge --kubeconfig="api/helm/kubeconfig.yaml --namespace=dev" -$ helm del pc-stag --purge --kubeconfig="api/helm/kubeconfig.yaml --namespace=stag" -$ helm del pp-prod --purge --kubeconfig="api/helm/kubeconfig.yaml --namespace=prod" +$ helm del pc-dev --purge --kubeconfig="api/helm/kubeconfig.yaml" +$ helm del pc-stag --purge --kubeconfig="api/helm/kubeconfig.yaml" +$ helm del pc-prod --purge --kubeconfig="api/helm/kubeconfig.yaml" ``` Note that you can replace common ground with the namespace that you want to use (normally the name of your component). diff --git a/api/helm/templates/cert-issuer.yaml b/api/helm/templates/cert-issuer.yaml new file mode 100644 index 00000000..804486a2 --- /dev/null +++ b/api/helm/templates/cert-issuer.yaml @@ -0,0 +1,16 @@ +apiVersion: cert-manager.io/v1alpha2 +kind: ClusterIssuer +metadata: + name: {{ include "name" . }}-{{ .Values.settings.env }}-letsencrypt +spec: + acme: + email: {{ .Values.settings.email }} + http01: {} + privateKeySecretRef: + name: letsencrypt-private-key + server: https://acme-v02.api.letsencrypt.org/directory + solvers: + - selector: {} + http01: + ingress: + class: nginx \ No newline at end of file diff --git a/api/helm/templates/certificate.yaml b/api/helm/templates/certificate.yaml new file mode 100644 index 00000000..43dacaf8 --- /dev/null +++ b/api/helm/templates/certificate.yaml @@ -0,0 +1,22 @@ +apiVersion: cert-manager.io/v1alpha2 +kind: Certificate +metadata: + name: {{ include "name" . }}-acme-cert +spec: + secretName: {{ include "name" . }}-tls-cert + duration: 24h + renewBefore: 12h + {{- if eq .Values.settings.env "prod" }} + commonName: {{ .Values.settings.name }}.{{ .Values.settings.domain }} + {{- else }} + commonName: {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} + {{- end }} + dnsNames: + {{- if eq .Values.settings.env "prod" }} + - {{ .Values.settings.name }}.{{ .Values.settings.domain }} + {{- else }} + - {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} + {{- end }} + issuerRef: + name: {{ include "name" . }}-{{ .Values.settings.env }}-letsencrypt + kind: ClusterIssuer \ No newline at end of file diff --git a/api/helm/templates/ingress.yaml b/api/helm/templates/ingress.yaml index d7cd7d40..5c76e036 100644 --- a/api/helm/templates/ingress.yaml +++ b/api/helm/templates/ingress.yaml @@ -1,6 +1,10 @@ apiVersion: extensions/v1beta1 kind: Ingress metadata: + annotations: + # add an annotation indicating the issuer to use. + cert-manager.io/acme-challenge-type: http01 + cert-manager.io/cluster-issuer: {{ include "name" . }}-{{ .Values.settings.env }}-letsencrypt name: {{ include "name" . }}-{{ .Values.settings.env }}-ingress labels: app.kubernetes.io/name: {{ include "name" . }}-ingress @@ -13,14 +17,10 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} spec: - tls: + tls: - hosts: - {{- if eq .Values.settings.env "prod" }} - {{ .Values.settings.domain }} - {{- else }} - - {{ .Values.settings.env }}.{{ .Values.settings.domain }} - {{- end }} - secretName: {{ include "name" . }}-certs + secretName: {{ include "name" . }}-tls-cert rules: # - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} # http: @@ -32,134 +32,74 @@ spec: - host: {{ .Values.settings.name }}.{{ .Values.settings.domain }} http: paths: - - path: /.well-known/* - backend: - serviceName: {{ include "name" . }}-letsencrypt - servicePort: 80 - - path: /* - backend: + - backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.huwelijksplanner.online http: paths: - - path: /.well-known/* - backend: - serviceName: {{ include "name" . }}-letsencrypt - servicePort: 80 - - path: /* - backend: + - backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.trouwplanner.online http: paths: - - path: /.well-known/* - backend: - serviceName: {{ include "name" . }}-letsencrypt - servicePort: 80 - - path: /* - backend: + - backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.common-ground.nl http: paths: - - path: /.well-known/* - backend: - serviceName: {{ include "name" . }}-letsencrypt - servicePort: 80 - - path: /* - backend: + - backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.larping.eu http: paths: - - path: /.well-known/* - backend: - serviceName: {{ include "name" . }}-letsencrypt - servicePort: 80 - - path: /* - backend: + - backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.zaakonline.eu http: paths: - - path: /.well-known/* - backend: - serviceName: {{ include "name" . }}-letsencrypt - servicePort: 80 - - path: /* - backend: + - backend: serviceName: {{ include "name" . }} servicePort: 80 {{- else }} - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.{{ .Values.settings.domain }} http: paths: - - path: /.well-known/* - backend: - serviceName: {{ include "name" . }}-letsencrypt - servicePort: 80 - - path: /* - backend: + - backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.huwelijksplanner.online http: paths: - - path: /.well-known/* - backend: - serviceName: {{ include "name" . }}-letsencrypt - servicePort: 80 - - path: /* - backend: + - backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.trouwplanner.online http: paths: - - path: /.well-known/* - backend: - serviceName: {{ include "name" . }}-letsencrypt - servicePort: 80 - - path: /* - backend: + - backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.common-ground.nl http: paths: - - path: /.well-known/* - backend: - serviceName: {{ include "name" . }}-letsencrypt - servicePort: 80 - - path: /* - backend: + - backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.larping.eu http: paths: - - path: /.well-known/* - backend: - serviceName: {{ include "name" . }}-letsencrypt - servicePort: 80 - - path: /* - backend: + - backend: serviceName: {{ include "name" . }} servicePort: 80 - host: {{ .Values.settings.name }}.{{ .Values.settings.env }}.zaakonline.nl http: paths: - - path: /.well-known/* - backend: - serviceName: {{ include "name" . }}-letsencrypt - servicePort: 80 - - path: /* - backend: + - backend: serviceName: {{ include "name" . }} servicePort: 80 {{- end }} diff --git a/api/helm/templates/lets-encrypt-job.yaml b/api/helm/templates/lets-encrypt-job.yaml deleted file mode 100644 index ee55da01..00000000 --- a/api/helm/templates/lets-encrypt-job.yaml +++ /dev/null @@ -1,39 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: {{ include "name" . }}-letsencrypt-job - labels: - app.kubernetes.io/name: {{ include "name" . }} - app.kubernetes.io/part-of: {{ include "name" . }} - helm.sh/chart: {{ include "chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -spec: - template: - metadata: - name: {{ include "name" . }}-letsencrypt - labels: - app: {{ include "name" . }}-letsencrypt - spec: - containers: - # Bash script that starts an http server and launches certbot - # Fork of github.com/sjenning/kube-nginx-letsencrypt - - image: quay.io/hiphipjorge/kube-nginx-letsencrypt:latest - name: letsencrypt - imagePullPolicy: Always - ports: - - name: letsencrypt - containerPort: 80 - env: - {{- if eq .Values.settings.env "prod" }} - - name: DOMAINS - value: { .Values.settings.domain }} - {{- else }} - - name: DOMAINS - value: {{ .Values.settings.env }}.{{ .Values.settings.domain }} - {{- end }} - - name: EMAIL - value: {{ .Values.settings.email }} - - name: SECRET - value: {{ include "name" . }}-letsencrypt-certs - restartPolicy: Never \ No newline at end of file diff --git a/api/helm/templates/lets-encrypt-secret.yaml b/api/helm/templates/lets-encrypt-secret.yaml deleted file mode 100644 index 4ea2960a..00000000 --- a/api/helm/templates/lets-encrypt-secret.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# An empty secret (with no data) in order for the update to work -apiVersion: v1 -kind: Secret -metadata: - name: {{ template "fullname" . }}-letsencrypt-certs - labels: - app.kubernetes.io/name: {{ include "name" . }} - app.kubernetes.io/part-of: {{ include "name" . }} - helm.sh/chart: {{ include "chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -type: Opaque \ No newline at end of file diff --git a/api/helm/templates/lets-encrypt-service.yaml b/api/helm/templates/lets-encrypt-service.yaml deleted file mode 100644 index 48247ae1..00000000 --- a/api/helm/templates/lets-encrypt-service.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "name" . }}-letsencrypt - labels: - app.kubernetes.io/name: {{ include "name" . }} - app.kubernetes.io/part-of: {{ include "name" . }} - helm.sh/chart: {{ include "chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -spec: - selector: - app: {{ include "name" . }}-letsencrypt - ports: - - protocol: "TCP" - port: 80 \ No newline at end of file From 75e28298b02939271a483a684fedf564b1b4b906 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Tue, 10 Dec 2019 14:51:37 +0100 Subject: [PATCH 118/125] Replaced deprecated interface --- api/src/Repository/ExampleEntityRepository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/Repository/ExampleEntityRepository.php b/api/src/Repository/ExampleEntityRepository.php index 7baa698c..692bece7 100644 --- a/api/src/Repository/ExampleEntityRepository.php +++ b/api/src/Repository/ExampleEntityRepository.php @@ -4,7 +4,7 @@ use App\Entity\ExampleEntity; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; -use Symfony\Bridge\Doctrine\RegistryInterface; +use Doctrine\Common\Persistence\ManagerRegistry; /** * @method ExampleEntity|null find($id, $lockMode = null, $lockVersion = null) @@ -14,7 +14,7 @@ */ class ExampleEntityRepository extends ServiceEntityRepository { - public function __construct(RegistryInterface $registry) + public function __construct(ManagerRegistry $registry) { parent::__construct($registry, ExampleEntity::class); } From ae03943e0c16bac86d1cf2ae1f22161b21f62ab5 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 10 Dec 2019 13:56:48 +0000 Subject: [PATCH 119/125] Apply fixes from StyleCI --- api/config/bundles.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/api/config/bundles.php b/api/config/bundles.php index 32cd19d9..b3f9617a 100644 --- a/api/config/bundles.php +++ b/api/config/bundles.php @@ -1,20 +1,20 @@ ['all' => true], - Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], - Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], - Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true], - Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], - Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], - Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], - ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], - Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], - Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], - Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], - Conduction\CommonGroundBundle\CommonGroundBundle::class => ['all' => true], - Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], + Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], + Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], + Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], + Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true], + Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], + Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], + Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], + Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], + Conduction\CommonGroundBundle\CommonGroundBundle::class => ['all' => true], + Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], - Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['all' => true], - Tbbc\MoneyBundle\TbbcMoneyBundle::class => ['all' => true], + Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['all' => true], + Tbbc\MoneyBundle\TbbcMoneyBundle::class => ['all' => true], ]; From 06bc6bc194b643c8a09d43f287ce8b98a3d3f00d Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 10 Dec 2019 15:47:56 +0100 Subject: [PATCH 120/125] Fix on .env variable and an increase of the php containers to 3 --- api/helm/templates/configmap.yaml | 7 ++++++ api/helm/templates/php-deployment.yaml | 32 +++++++++++++++++++++++--- api/templates/helm/Values.yaml.twig | 7 +++++- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/api/helm/templates/configmap.yaml b/api/helm/templates/configmap.yaml index d3b97459..39c5e996 100644 --- a/api/helm/templates/configmap.yaml +++ b/api/helm/templates/configmap.yaml @@ -25,6 +25,13 @@ data: app-health: {{ .Values.settings.healthEnabled | quote }} app-archive: {{ .Values.settings.archiveEnabled | quote }} + organization-name: {{ .Values.settings.organisationMame | quote }} + organization-email: {{ .Values.settings.email | quote }} + organization-country: {{ .Values.settings.country | quote }} + organization-state: {{ .Values.settings.state | quote }} + organization-locality: {{ .Values.settings.locality | quote }} + organization-unit: {{ .Values.settings.unit | quote }} + env: {{ .Values.settings.env | quote }} debug: {{ .Values.settings.debug | quote }} cors-allow-origin: {{ .Values.settings.corsAllowOrigin | quote }} diff --git a/api/helm/templates/php-deployment.yaml b/api/helm/templates/php-deployment.yaml index 3f09ef5d..611e5d39 100644 --- a/api/helm/templates/php-deployment.yaml +++ b/api/helm/templates/php-deployment.yaml @@ -9,7 +9,7 @@ metadata: app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} spec: - replicas: {{ .Values.php.replicaCount }} + replicas: 3 template: metadata: labels: @@ -82,11 +82,37 @@ spec: configMapKeyRef: name: {{ template "fullname" . }} key: app-domain - - name: APP_REPRO + # organization + - name: ORGANIZATION_NAME valueFrom: configMapKeyRef: name: {{ template "fullname" . }} - key: app-repro + key: organization-name + - name: ORGANIZATION_EMAIL_ADDRESS + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: organization-email + - name: ORGANIZATION_COUNTRY_NAME + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: organization-country + - name: ORGANIZATION_STATE + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: organization-state + - name: ORGANIZATION_LOCALITY + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: organization-locality + - name: ORGANIZATION_UNIT_NAME + valueFrom: + configMapKeyRef: + name: {{ template "fullname" . }} + key: organization-unit # config - name: AUTH_ENABLED valueFrom: diff --git a/api/templates/helm/Values.yaml.twig b/api/templates/helm/Values.yaml.twig index e9b28795..616c3f77 100644 --- a/api/templates/helm/Values.yaml.twig +++ b/api/templates/helm/Values.yaml.twig @@ -10,8 +10,13 @@ settings: version: {{ app_version }} description: '{{ app_description }}' repro: '{{ app_repro }}' - domain: {{ app_domain }} + domain: {{ app_domain }} + organisationName: {{ organization_name }} email: {{ organization_email }} + country: {{ organization_country }} + state: {{ organization_state }} + locality: {{ organization_locality }} + unit: {{ unit }} demo: {{ app_demo }} env: {{ app_env }} debug: {{ app_debug }} From 0d1fe68c642413f8bfb9b105ab376c415658c76d Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 10 Dec 2019 15:57:22 +0100 Subject: [PATCH 121/125] Added missing .env variables --- docker-compose.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 51c9655a..4d7436b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,6 +40,12 @@ services: - APP_DEMO=${APP_DEMO} - APP_REPRO=${APP_REPRO} - APP_DESCRIPTION=${APP_DESCRIPTION} + - ORGANIZATION_NAME=${ORGANIZATION_NAME} + - ORGANIZATION_EMAIL_ADDRESS=${ORGANIZATION_EMAIL_ADDRESS} + - ORGANIZATION_COUNTRY_NAME=${ORGANIZATION_COUNTRY_NAME} + - ORGANIZATION_STATE=${ORGANIZATION_STATE} + - ORGANIZATION_LOCALITY=${ORGANIZATION_LOCALITY} + - ORGANIZATION_UNIT_NAME=${ORGANIZATION_UNIT_NAME} - TRUSTED_PROXIES=${TRUSTED_PROXIES} - TRUSTED_HOSTS=${TRUSTED_HOSTS} - AUTH_ENABLED=${AUTH_ENABLED} From 43c9ea0bede798d6479df097991299ce0db00f83 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 10 Dec 2019 16:07:30 +0100 Subject: [PATCH 122/125] Fix on organisation unit --- api/templates/helm/Values.yaml.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/templates/helm/Values.yaml.twig b/api/templates/helm/Values.yaml.twig index 616c3f77..37ec6129 100644 --- a/api/templates/helm/Values.yaml.twig +++ b/api/templates/helm/Values.yaml.twig @@ -16,7 +16,7 @@ settings: country: {{ organization_country }} state: {{ organization_state }} locality: {{ organization_locality }} - unit: {{ unit }} + unit: {{ organization_unit }} demo: {{ app_demo }} env: {{ app_env }} debug: {{ app_debug }} From 4ef9753fbe70b5abec418ef99f2708aa75f22526 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 10 Dec 2019 17:04:04 +0100 Subject: [PATCH 123/125] Added doctrine shema check to ci/cd --- .github/workflows/dockerimage.yml | 2 ++ api/helm/values.yaml | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 4f8b430e..e5ca75c3 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -63,6 +63,8 @@ jobs: run: docker-compose logs - name: Security Checks run: docker-compose exec -T php composer req sensiolabs/security-checker + - name: Database Check + run: docker-compose exec -T php bin/console doctrine:schema:validate - name: Chores run: docker-compose down - name: Login to DockerHub Registry diff --git a/api/helm/values.yaml b/api/helm/values.yaml index 7f4d3075..18c2d9e3 100644 --- a/api/helm/values.yaml +++ b/api/helm/values.yaml @@ -10,7 +10,13 @@ settings: version: V.0.1 description: ''Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.'' repro: 'https://github.com/ConductionNL/Proto-component-commonground' - domain: conduction.nl + domain: conduction.nl + organisationName: Conduction + email: info@conduction.nl + country: Netherlands + state: Noord-Holland + locality: Amsterdam + unit: Common-Ground demo: pc.zaakonline.nl env: dev debug: 1 From 3c801ea5aa06204a66d6268bf88c332d8fedd414 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 10 Dec 2019 17:38:58 +0100 Subject: [PATCH 124/125] Add database update to ci/cd --- .github/workflows/dockerimage.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index e5ca75c3..3be28c02 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -63,6 +63,8 @@ jobs: run: docker-compose logs - name: Security Checks run: docker-compose exec -T php composer req sensiolabs/security-checker + - name: Database Update + run: docker-compose exec -T php bin/console doctrine:schema:update --force - name: Database Check run: docker-compose exec -T php bin/console doctrine:schema:validate - name: Chores From c8233fc00cf8ea4fd9773c9a6b8b383910483c81 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Tue, 10 Dec 2019 18:20:13 +0100 Subject: [PATCH 125/125] Set name converter to snake case --- api/config/packages/api_platform.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/config/packages/api_platform.yaml b/api/config/packages/api_platform.yaml index 11f8555f..6fd42010 100644 --- a/api/config/packages/api_platform.yaml +++ b/api/config/packages/api_platform.yaml @@ -46,7 +46,7 @@ api_platform: enable_re_doc: true # In the NL api strategie we use snake case for naming - # name_converter: 'Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter' + name_converter: 'Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter' # Lets confirm to JSON-HA: first, as per common ground. But allow other serializers formats: