├── .gitignore ├── LICENSE ├── Pipfile ├── Pipfile.lock ├── README.md ├── __init__.py ├── __main__.py ├── app ├── __init__.py ├── __main__.py ├── http │ ├── __init__.py │ ├── api │ │ ├── __init__.py │ │ └── endpoints.py │ └── web │ │ └── app │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ │ └── src │ │ ├── App.css │ │ ├── App.js │ │ ├── App.test.js │ │ ├── GithubRepo │ │ └── index.js │ │ ├── Home │ │ └── index.js │ │ ├── Login │ │ └── index.js │ │ ├── Main │ │ └── index.js │ │ ├── SearchBar │ │ └── index.js │ │ ├── apiClient.js │ │ ├── githubClient.js │ │ ├── index.css │ │ ├── index.js │ │ ├── logo.svg │ │ ├── reportWebVitals.js │ │ └── setupTests.js ├── kudo │ ├── __init__.py │ ├── schema.py │ └── service.py └── repository │ ├── __init__.py │ └── mongo.py ├── client_secrets.json └── docker-compose.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.env 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | name = "pypi" 3 | url = "https://pypi.org/simple" 4 | verify_ssl = true 5 | 6 | [dev-packages] 7 | 8 | [packages] 9 | flask = "==1.0.2" 10 | marshmallow = "==2.16.3" 11 | pymongo = "==3.7.2" 12 | flask-cors = "==3.0.7" 13 | flask-oidc = "==1.4.0" 14 | 15 | [requires] 16 | python_version = "3.8" 17 | -------------------------------------------------------------------------------- /Pipfile.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_meta": { 3 | "hash": { 4 | "sha256": "61210a693f6abdb842dbffee91f6876ad9bfd3d64ea5eb56f9300afb8e6d0805" 5 | }, 6 | "pipfile-spec": 6, 7 | "requires": { 8 | "python_version": "3.8" 9 | }, 10 | "sources": [ 11 | { 12 | "name": "pypi", 13 | "url": "https://pypi.org/simple", 14 | "verify_ssl": true 15 | } 16 | ] 17 | }, 18 | "default": { 19 | "click": { 20 | "hashes": [ 21 | "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a", 22 | "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc" 23 | ], 24 | "version": "==7.1.2" 25 | }, 26 | "flask": { 27 | "hashes": [ 28 | "sha256:2271c0070dbcb5275fad4a82e29f23ab92682dc45f9dfbc22c02ba9b9322ce48", 29 | "sha256:a080b744b7e345ccfcbc77954861cb05b3c63786e93f2b3875e0913d44b43f05" 30 | ], 31 | "index": "pypi", 32 | "version": "==1.0.2" 33 | }, 34 | "flask-cors": { 35 | "hashes": [ 36 | "sha256:7ad56ee3b90d4955148fc25a2ecaa1124fc84298471e266a7fea59aeac4405a5", 37 | "sha256:7e90bf225fdf163d11b84b59fb17594d0580a16b97ab4e1146b1fb2737c1cfec" 38 | ], 39 | "index": "pypi", 40 | "version": "==3.0.7" 41 | }, 42 | "flask-oidc": { 43 | "hashes": [ 44 | "sha256:0c12151139d47a562e1c5ae203fb9dbc759fe7474cc01e0238bef828ece58f4e" 45 | ], 46 | "index": "pypi", 47 | "version": "==1.4.0" 48 | }, 49 | "httplib2": { 50 | "hashes": [ 51 | "sha256:749c32603f9bf16c1277f59531d502e8f1c2ca19901ae653b49c4ed698f0820e", 52 | "sha256:e0d428dad43c72dbce7d163b7753ffc7a39c097e6788ef10f4198db69b92f08e" 53 | ], 54 | "version": "==0.19.0" 55 | }, 56 | "itsdangerous": { 57 | "hashes": [ 58 | "sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19", 59 | "sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749" 60 | ], 61 | "version": "==1.1.0" 62 | }, 63 | "jinja2": { 64 | "hashes": [ 65 | "sha256:03e47ad063331dd6a3f04a43eddca8a966a26ba0c5b7207a9a9e4e08f1b29419", 66 | "sha256:a6d58433de0ae800347cab1fa3043cebbabe8baa9d29e668f1c768cb87a333c6" 67 | ], 68 | "index": "pypi", 69 | "version": "==2.11.3" 70 | }, 71 | "markupsafe": { 72 | "hashes": [ 73 | "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", 74 | "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", 75 | "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", 76 | "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", 77 | "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42", 78 | "sha256:195d7d2c4fbb0ee8139a6cf67194f3973a6b3042d742ebe0a9ed36d8b6f0c07f", 79 | "sha256:22c178a091fc6630d0d045bdb5992d2dfe14e3259760e713c490da5323866c39", 80 | "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", 81 | "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", 82 | "sha256:2beec1e0de6924ea551859edb9e7679da6e4870d32cb766240ce17e0a0ba2014", 83 | "sha256:3b8a6499709d29c2e2399569d96719a1b21dcd94410a586a18526b143ec8470f", 84 | "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", 85 | "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", 86 | "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", 87 | "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", 88 | "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b", 89 | "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", 90 | "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15", 91 | "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", 92 | "sha256:6f1e273a344928347c1290119b493a1f0303c52f5a5eae5f16d74f48c15d4a85", 93 | "sha256:6fffc775d90dcc9aed1b89219549b329a9250d918fd0b8fa8d93d154918422e1", 94 | "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", 95 | "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", 96 | "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", 97 | "sha256:7fed13866cf14bba33e7176717346713881f56d9d2bcebab207f7a036f41b850", 98 | "sha256:84dee80c15f1b560d55bcfe6d47b27d070b4681c699c572af2e3c7cc90a3b8e0", 99 | "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", 100 | "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", 101 | "sha256:98bae9582248d6cf62321dcb52aaf5d9adf0bad3b40582925ef7c7f0ed85fceb", 102 | "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", 103 | "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", 104 | "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", 105 | "sha256:a6a744282b7718a2a62d2ed9d993cad6f5f585605ad352c11de459f4108df0a1", 106 | "sha256:acf08ac40292838b3cbbb06cfe9b2cb9ec78fce8baca31ddb87aaac2e2dc3bc2", 107 | "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", 108 | "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", 109 | "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", 110 | "sha256:b1dba4527182c95a0db8b6060cc98ac49b9e2f5e64320e2b56e47cb2831978c7", 111 | "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", 112 | "sha256:b7d644ddb4dbd407d31ffb699f1d140bc35478da613b441c582aeb7c43838dd8", 113 | "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", 114 | "sha256:bf5aa3cbcfdf57fa2ee9cd1822c862ef23037f5c832ad09cfea57fa846dec193", 115 | "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", 116 | "sha256:caabedc8323f1e93231b52fc32bdcde6db817623d33e100708d9a68e1f53b26b", 117 | "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", 118 | "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2", 119 | "sha256:d53bc011414228441014aa71dbec320c66468c1030aae3a6e29778a3382d96e5", 120 | "sha256:d73a845f227b0bfe8a7455ee623525ee656a9e2e749e4742706d80a6065d5e2c", 121 | "sha256:d9be0ba6c527163cbed5e0857c451fcd092ce83947944d6c14bc95441203f032", 122 | "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7", 123 | "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be", 124 | "sha256:feb7b34d6325451ef96bc0e36e1a6c0c1c64bc1fbec4b854f4529e51887b1621" 125 | ], 126 | "version": "==1.1.1" 127 | }, 128 | "marshmallow": { 129 | "hashes": [ 130 | "sha256:a2052f62b18f6dad520f465e437f63ab8812423975d48b9ebd30a735466e782a", 131 | "sha256:e1b79eb3b815b49918c64114dda691b8767b48a1f66dd1d8c0cd5842b74257c2" 132 | ], 133 | "index": "pypi", 134 | "version": "==2.16.3" 135 | }, 136 | "oauth2client": { 137 | "hashes": [ 138 | "sha256:b8a81cc5d60e2d364f0b1b98f958dbd472887acaf1a5b05e21c28c31a2d6d3ac", 139 | "sha256:d486741e451287f69568a4d26d70d9acd73a2bbfa275746c535b4209891cccc6" 140 | ], 141 | "version": "==4.1.3" 142 | }, 143 | "pyasn1": { 144 | "hashes": [ 145 | "sha256:39c7e2ec30515947ff4e87fb6f456dfc6e84857d34be479c9d4a4ba4bf46aa5d", 146 | "sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba" 147 | ], 148 | "version": "==0.4.8" 149 | }, 150 | "pyasn1-modules": { 151 | "hashes": [ 152 | "sha256:905f84c712230b2c592c19470d3ca8d552de726050d1d1716282a1f6146be65e", 153 | "sha256:a50b808ffeb97cb3601dd25981f6b016cbb3d31fbf57a8b8a87428e6158d0c74" 154 | ], 155 | "version": "==0.2.8" 156 | }, 157 | "pymongo": { 158 | "hashes": [ 159 | "sha256:025f94fc1e1364f00e50badc88c47f98af20012f23317234e51a11333ef986e6", 160 | "sha256:02aa7fb282606331aefbc0586e2cf540e9dbe5e343493295e7f390936ad2738e", 161 | "sha256:057210e831573e932702cf332012ed39da78edf0f02d24a3f0b213264a87a397", 162 | "sha256:0d946b79c56187fe139276d4c8ed612a27a616966c8b9779d6b79e2053587c8b", 163 | "sha256:104790893b928d310aae8a955e0bdbaa442fb0ac0a33d1bbb0741c791a407778", 164 | "sha256:15527ef218d95a8717486106553b0d54ff2641e795b65668754e17ab9ca6e381", 165 | "sha256:1826527a0b032f6e20e7ac7f72d7c26dd476a5e5aa82c04aa1c7088a59fded7d", 166 | "sha256:22e3aa4ce1c3eebc7f70f9ca7fd4ce1ea33e8bdb7b61996806cd312f08f84a3a", 167 | "sha256:244e1101e9a48615b9a16cbd194f73c115fdfefc96894803158608115f703b26", 168 | "sha256:24b8c04fdb633a84829d03909752c385faef249c06114cc8d8e1700b95aae5c8", 169 | "sha256:2c276696350785d3104412cbe3ac70ab1e3a10c408e7b20599ee41403a3ed630", 170 | "sha256:2d8474dc833b1182b651b184ace997a7bd83de0f51244de988d3c30e49f07de3", 171 | "sha256:3119b57fe1d964781e91a53e81532c85ed1701baaddec592e22f6b77a9fdf3df", 172 | "sha256:3bee8e7e0709b0fcdaa498a3e513bde9ffc7cd09dbceb11e425bd91c89dbd5b6", 173 | "sha256:436c071e01a464753d30dbfc8768dd93aecf2a8e378e5314d130b95e77b4d612", 174 | "sha256:46635e3f19ad04d5a7d7cf23d232388ddbfccf46d9a3b7436b6abadda4e84813", 175 | "sha256:4772e0b679717e7ac4608d996f57b6f380748a919b457cb05bb941467b888b22", 176 | "sha256:4e2cd80e16f481a62c3175b607373200e714ed29025f21559ebf7524f295689f", 177 | "sha256:52732960efa0e003ca1c092dc0a3c65276e897681287a788a01ca78dda3b41f0", 178 | "sha256:55a7de51ec7d1731b2431886d0349146645f2816e5b8eb982d7c49f89472c9f3", 179 | "sha256:5f8ed5934197a2d4b2087646e98de3e099a237099dcf498b9e38dd3465f74ef4", 180 | "sha256:64b064124fcbc8eb04a155117dc4d9a336e3cda3f069958fbc44fe70c3c3d1e9", 181 | "sha256:65958b8e4319f992e85dad59d8081888b97fcdbde5f0d14bc28f2848b92d3ef1", 182 | "sha256:7683428862e20c6a790c19e64f8ccf487f613fbc83d47e3d532df9c81668d451", 183 | "sha256:78566d5570c75a127c2491e343dc006798a384f06be588fe9b0cbe5595711559", 184 | "sha256:7d1cb00c093dbf1d0b16ccf123e79dee3b82608e4a2a88947695f0460eef13ff", 185 | "sha256:8c74e2a9b594f7962c62cef7680a4cb92a96b4e6e3c2f970790da67cc0213a7e", 186 | "sha256:8e60aa7699170f55f4b0f56ee6f8415229777ac7e4b4b1aa41fc61eec08c1f1d", 187 | "sha256:9447b561529576d89d3bf973e5241a88cf76e45bd101963f5236888713dea774", 188 | "sha256:970055bfeb0be373f2f5299a3db8432444bad3bc2f198753ee6c2a3a781e0959", 189 | "sha256:a6344b8542e584e140dc3c651d68bde51270e79490aa9320f9e708f9b2c39bd5", 190 | "sha256:ce309ca470d747b02ba6069d286a17b7df8e9c94d10d727d9cf3a64e51d85184", 191 | "sha256:cfbd86ed4c2b2ac71bbdbcea6669bf295def7152e3722ddd9dda94ac7981f33d", 192 | "sha256:d7929c513732dff093481f4a0954ed5ff16816365842136b17caa0b4992e49d3" 193 | ], 194 | "index": "pypi", 195 | "version": "==3.7.2" 196 | }, 197 | "pyparsing": { 198 | "hashes": [ 199 | "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1", 200 | "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b" 201 | ], 202 | "version": "==2.4.7" 203 | }, 204 | "rsa": { 205 | "hashes": [ 206 | "sha256:78f9a9bf4e7be0c5ded4583326e7461e3a3c5aae24073648b4bdfa797d78c9d2", 207 | "sha256:9d689e6ca1b3038bc82bf8d23e944b6b6037bc02301a574935b2dd946e0353b9" 208 | ], 209 | "version": "==4.7.2" 210 | }, 211 | "six": { 212 | "hashes": [ 213 | "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", 214 | "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" 215 | ], 216 | "version": "==1.15.0" 217 | }, 218 | "werkzeug": { 219 | "hashes": [ 220 | "sha256:2de2a5db0baeae7b2d2664949077c2ac63fbd16d98da0ff71837f7d1dea3fd43", 221 | "sha256:6c80b1e5ad3665290ea39320b91e1be1e0d5f60652b964a3070216de83d2e47c" 222 | ], 223 | "version": "==1.0.1" 224 | } 225 | }, 226 | "develop": {} 227 | } 228 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Build a Simple CRUD App with Python, Flask, and React 2 | 3 | This tutorial show how to build a basic CRUD (Create, Read, Update, and Delete) application using Python with Flask as the API and React for the front-end. 4 | 5 | Please read the [Build a Simple CRUD App with Python, Flask, and React](https://developer.okta.com/blog/2018/12/20/crud-app-with-python-flask-react) to see the step-by-step instructions for creating this application. 6 | 7 | If you'd like to simply clone this repo and configure it with your Okta settings, here's the abbreviated steps: 8 | 9 | 1. Create an [Okta developer account](https://developer.okta.com/signup) if you don't already have one. 10 | 11 | 2. Create a new **Web** app and **SPA** app on Okta with the default settings. Put your web app settings in `client_secrets.json`. For the SPA app, put your settings in `app/http/web/app/src/Main/index.js`. 12 | 13 | 3. Start MongoDB with Docker Compose: 14 | 15 | docker-compose up 16 | export MONGO_URL=mongodb://mongo_user:mongo_secret@0.0.0.0:27017/ 17 | 18 | 4. Start the Python backend: 19 | 20 | FLASK_APP=$PWD/app/http/api/endpoints.py FLASK_ENV=development pipenv run python -m flask run --port 4433 21 | 22 | 5. Start the React frontend: 23 | 24 | cd app/http/web/app 25 | npm i 26 | npm start 27 | 28 | ## Help 29 | 30 | Please post any questions as comments on the [blog post](https://developer.okta.com/blog/2018/12/20/crud-app-with-python-flask-react), or visit our [Okta Developer Forums](https://devforum.okta.com/). You can also email developers@okta.com if you'd like to create a support ticket. 31 | 32 | ## License 33 | 34 | Apache 2.0, see [LICENSE](LICENSE). 35 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oktadev/python-flask-react-crud-example/c2165e5d90f556fb90e7b3a39bc34720208d67a5/__init__.py -------------------------------------------------------------------------------- /__main__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, print_function 2 | 3 | -------------------------------------------------------------------------------- /app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oktadev/python-flask-react-crud-example/c2165e5d90f556fb90e7b3a39bc34720208d67a5/app/__init__.py -------------------------------------------------------------------------------- /app/__main__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, print_function -------------------------------------------------------------------------------- /app/http/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oktadev/python-flask-react-crud-example/c2165e5d90f556fb90e7b3a39bc34720208d67a5/app/http/__init__.py -------------------------------------------------------------------------------- /app/http/api/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oktadev/python-flask-react-crud-example/c2165e5d90f556fb90e7b3a39bc34720208d67a5/app/http/api/__init__.py -------------------------------------------------------------------------------- /app/http/api/endpoints.py: -------------------------------------------------------------------------------- 1 | from flask_oidc import OpenIDConnect 2 | from flask import Flask, json, g, request 3 | from app.kudo.service import Service as Kudo 4 | from app.kudo.schema import GithubRepoSchema 5 | from flask_cors import CORS 6 | 7 | app = Flask(__name__) 8 | app.config.update({ 9 | 'OIDC_CLIENT_SECRETS': './client_secrets.json', 10 | 'OIDC_RESOURCE_SERVER_ONLY': True 11 | }) 12 | oidc = OpenIDConnect(app) 13 | CORS(app) 14 | 15 | @app.route("/kudos", methods=["GET"]) 16 | @oidc.accept_token(True) 17 | def index(): 18 | return json_response(Kudo(g.oidc_token_info['sub']).find_all_kudos()) 19 | 20 | 21 | @app.route("/kudos", methods=["POST"]) 22 | @oidc.accept_token(True) 23 | def create(): 24 | github_repo = GithubRepoSchema().load(json.loads(request.data)) 25 | 26 | if github_repo.errors: 27 | return json_response({'error': github_repo.errors}, 422) 28 | 29 | kudo = Kudo(g.oidc_token_info['sub']).create_kudo_for(github_repo) 30 | return json_response(kudo) 31 | 32 | 33 | @app.route("/kudo/", methods=["GET"]) 34 | @oidc.accept_token(True) 35 | def show(repo_id): 36 | kudo = Kudo(g.oidc_token_info['sub']).find_kudo(repo_id) 37 | 38 | if kudo: 39 | return json_response(kudo) 40 | else: 41 | return json_response({'error': 'kudo not found'}, 404) 42 | 43 | 44 | @app.route("/kudo/", methods=["PUT"]) 45 | @oidc.accept_token(True) 46 | def update(repo_id): 47 | github_repo = GithubRepoSchema().load(json.loads(request.data)) 48 | 49 | if github_repo.errors: 50 | return json_response({'error': github_repo.errors}, 422) 51 | 52 | kudo_service = Kudo(g.oidc_token_info['sub']) 53 | if kudo_service.update_kudo_with(repo_id, github_repo): 54 | return json_response(github_repo.data) 55 | else: 56 | return json_response({'error': 'kudo not found'}, 404) 57 | 58 | 59 | @app.route("/kudo/", methods=["DELETE"]) 60 | @oidc.accept_token(True) 61 | def delete(repo_id): 62 | kudo_service = Kudo(g.oidc_token_info['sub']) 63 | if kudo_service.delete_kudo_for(repo_id): 64 | return json_response({}) 65 | else: 66 | return json_response({'error': 'kudo not found'}, 404) 67 | 68 | 69 | def json_response(payload, status=200): 70 | return (json.dumps(payload), status, {'content-type': 'application/json'}) 71 | -------------------------------------------------------------------------------- /app/http/web/app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /app/http/web/app/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `yarn start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `yarn test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `yarn build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `yarn eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `yarn build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /app/http/web/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@material-ui/core": "^4.11.3", 7 | "@material-ui/icons": "^4.11.2", 8 | "@okta/okta-auth-js": "^4.8.0", 9 | "@okta/okta-react": "^5.1.0", 10 | "@testing-library/jest-dom": "^5.11.4", 11 | "@testing-library/react": "^11.1.0", 12 | "@testing-library/user-event": "^12.1.10", 13 | "axios": "^0.21.2", 14 | "react": "^17.0.2", 15 | "react-dom": "^17.0.2", 16 | "react-router-dom": "^5.2.0", 17 | "react-scripts": "4.0.3", 18 | "react-swipeable-views": "^0.13.9", 19 | "web-vitals": "^1.0.1" 20 | }, 21 | "scripts": { 22 | "start": "PORT=8080 react-scripts start", 23 | "build": "react-scripts build", 24 | "test": "react-scripts test", 25 | "eject": "react-scripts eject" 26 | }, 27 | "eslintConfig": { 28 | "extends": [ 29 | "react-app", 30 | "react-app/jest" 31 | ] 32 | }, 33 | "browserslist": { 34 | "production": [ 35 | ">0.2%", 36 | "not dead", 37 | "not op_mini all" 38 | ], 39 | "development": [ 40 | "last 1 chrome version", 41 | "last 1 firefox version", 42 | "last 1 safari version" 43 | ] 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/http/web/app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oktadev/python-flask-react-crud-example/c2165e5d90f556fb90e7b3a39bc34720208d67a5/app/http/web/app/public/favicon.ico -------------------------------------------------------------------------------- /app/http/web/app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /app/http/web/app/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oktadev/python-flask-react-crud-example/c2165e5d90f556fb90e7b3a39bc34720208d67a5/app/http/web/app/public/logo192.png -------------------------------------------------------------------------------- /app/http/web/app/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oktadev/python-flask-react-crud-example/c2165e5d90f556fb90e7b3a39bc34720208d67a5/app/http/web/app/public/logo512.png -------------------------------------------------------------------------------- /app/http/web/app/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /app/http/web/app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /app/http/web/app/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/http/web/app/src/App.js: -------------------------------------------------------------------------------- 1 | import logo from './logo.svg'; 2 | import './App.css'; 3 | 4 | function App() { 5 | return ( 6 |
7 |
8 | logo 9 |

10 | Edit src/App.js and save to reload. 11 |

12 | 18 | Learn React 19 | 20 |
21 |
22 | ); 23 | } 24 | 25 | export default App; 26 | -------------------------------------------------------------------------------- /app/http/web/app/src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /app/http/web/app/src/GithubRepo/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withStyles } from '@material-ui/core/styles'; 3 | import Card from '@material-ui/core/Card'; 4 | import CardHeader from '@material-ui/core/CardHeader'; 5 | import CardContent from '@material-ui/core/CardContent'; 6 | import CardActions from '@material-ui/core/CardActions'; 7 | import IconButton from '@material-ui/core/IconButton'; 8 | import Typography from '@material-ui/core/Typography'; 9 | import FavoriteIcon from '@material-ui/icons/Favorite'; 10 | 11 | const styles = theme => ({ 12 | card: { 13 | maxWidth: 400, 14 | }, 15 | media: { 16 | height: 0, 17 | paddingTop: '56.25%', // 16:9 18 | }, 19 | actions: { 20 | display: 'flex', 21 | } 22 | }); 23 | 24 | class GithubRepo extends React.Component { 25 | handleClick = (event) => { 26 | this.props.onKudo(this.props.repo) 27 | } 28 | 29 | render() { 30 | const { classes } = this.props; 31 | 32 | return ( 33 | 34 | 37 | 38 | 39 | {this.props.repo.description} 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | ); 49 | } 50 | } 51 | 52 | export default withStyles(styles)(GithubRepo); 53 | -------------------------------------------------------------------------------- /app/http/web/app/src/Home/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withStyles } from '@material-ui/core/styles'; 3 | import SwipeableViews from 'react-swipeable-views'; 4 | import Tabs from '@material-ui/core/Tabs'; 5 | import Tab from '@material-ui/core/Tab'; 6 | import Grid from '@material-ui/core/Grid'; 7 | import { withOktaAuth } from '@okta/okta-react'; 8 | 9 | import GithubRepo from "../GithubRepo" 10 | import SearchBar from "../SearchBar" 11 | 12 | import githubClient from '../githubClient' 13 | import APIClient from '../apiClient' 14 | 15 | const styles = theme => ({ 16 | root: { 17 | flexGrow: 1, 18 | marginTop: 30 19 | }, 20 | paper: { 21 | padding: theme.spacing(2), 22 | textAlign: 'center', 23 | color: theme.palette.text.secondary, 24 | }, 25 | }); 26 | 27 | class Home extends React.Component { 28 | state = { 29 | value: 0, 30 | repos: [], 31 | kudos: [] 32 | }; 33 | 34 | componentDidMount() { 35 | const accessToken = this.props.authState.accessToken.accessToken; 36 | this.apiClient = new APIClient(accessToken); 37 | this.apiClient.getKudos().then((data) => 38 | this.setState({...this.state, kudos: data}) 39 | ); 40 | } 41 | 42 | handleTabChange = (event, value) => { 43 | this.setState({ value }); 44 | }; 45 | 46 | handleTabChangeIndex = index => { 47 | this.setState({ value: index }); 48 | }; 49 | 50 | resetRepos = repos => this.setState({ ...this.state, repos }) 51 | 52 | isKudo = repo => this.state.kudos.find(r => r.id === repo.id) 53 | onKudo = (repo) => { 54 | this.updateBackend(repo); 55 | } 56 | 57 | updateBackend = (repo) => { 58 | if (this.isKudo(repo)) { 59 | this.apiClient.deleteKudo(repo); 60 | } else { 61 | this.apiClient.createKudo(repo); 62 | } 63 | this.updateState(repo); 64 | } 65 | 66 | updateState = (repo) => { 67 | if (this.isKudo(repo)) { 68 | this.setState({ 69 | ...this.state, 70 | kudos: this.state.kudos.filter( r => r.id !== repo.id ) 71 | }) 72 | } else { 73 | this.setState({ 74 | ...this.state, 75 | kudos: [repo, ...this.state.kudos] 76 | }) 77 | } 78 | } 79 | 80 | onSearch = (event) => { 81 | const target = event.target; 82 | if (!target.value || target.length < 3) { return } 83 | if (event.which !== 13) { return } 84 | 85 | githubClient(target.value) 86 | .then((response) => { 87 | target.blur(); 88 | this.setState({ ...this.state, value: 1 }); 89 | this.resetRepos(response.items); 90 | }) 91 | } 92 | 93 | renderRepos = (repos) => { 94 | if (!repos) { return [] } 95 | return repos.map((repo) => { 96 | return ( 97 | 98 | 99 | 100 | ); 101 | }) 102 | } 103 | 104 | render() { 105 | return ( 106 |
107 | 108 | 115 | 116 | 117 | 118 | 119 | 124 | 125 | { this.renderRepos(this.state.kudos) } 126 | 127 | 128 | { this.renderRepos(this.state.repos) } 129 | 130 | 131 |
132 | ); 133 | } 134 | } 135 | 136 | export default withStyles(styles)(withOktaAuth(Home)); 137 | -------------------------------------------------------------------------------- /app/http/web/app/src/Login/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Button from '@material-ui/core/Button'; 3 | import { Redirect } from 'react-router-dom' 4 | import { withOktaAuth } from '@okta/okta-react'; 5 | 6 | class Login extends React.Component { 7 | constructor(props) { 8 | super(props); 9 | this.login = this.login.bind(this); 10 | } 11 | 12 | async login() { 13 | await this.props.oktaAuth.signInWithRedirect(); 14 | } 15 | 16 | render() { 17 | if (this.props.authState.isAuthenticated) { 18 | return 19 | } else { 20 | return ( 21 |
22 | 23 |
24 | ) 25 | } 26 | } 27 | } 28 | 29 | export default withOktaAuth(Login); 30 | -------------------------------------------------------------------------------- /app/http/web/app/src/Main/index.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Switch, Route } from 'react-router-dom' 3 | import { Security, LoginCallback, SecureRoute } from '@okta/okta-react'; 4 | import { OktaAuth, toRelativeUrl } from '@okta/okta-auth-js'; 5 | 6 | import Login from '../Login' 7 | import Home from '../Home' 8 | 9 | class Main extends Component { 10 | 11 | constructor(props) { 12 | super(props); 13 | this.oktaAuth = new OktaAuth({ 14 | issuer: 'https://{yourOktaDomain}/oauth2/default', 15 | clientId: '{clientId}', 16 | redirectUri: window.location.origin + '/callback' 17 | }); 18 | this.restoreOriginalUri = async (_oktaAuth, originalUri) => { 19 | props.history.replace(toRelativeUrl(originalUri, window.location.origin)); 20 | }; 21 | } 22 | 23 | render() { 24 | return ( 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | ); 33 | } 34 | } 35 | 36 | export default Main; 37 | -------------------------------------------------------------------------------- /app/http/web/app/src/SearchBar/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import AppBar from '@material-ui/core/AppBar'; 4 | import Toolbar from '@material-ui/core/Toolbar'; 5 | import InputBase from '@material-ui/core/InputBase'; 6 | import Button from '@material-ui/core/Button'; 7 | import { fade } from '@material-ui/core/styles/colorManipulator'; 8 | import { withStyles } from '@material-ui/core/styles'; 9 | import SearchIcon from '@material-ui/icons/Search'; 10 | import { withOktaAuth } from '@okta/okta-react'; 11 | 12 | const styles = theme => ({ 13 | root: { 14 | width: '100%', 15 | }, 16 | MuiAppBar: { 17 | alignItems: 'center' 18 | }, 19 | grow: { 20 | flexGrow: 1, 21 | }, 22 | title: { 23 | display: 'none', 24 | [theme.breakpoints.up('sm')]: { 25 | display: 'block', 26 | }, 27 | }, 28 | search: { 29 | position: 'relative', 30 | borderRadius: theme.shape.borderRadius, 31 | backgroundColor: fade(theme.palette.common.white, 0.15), 32 | '&:hover': { 33 | backgroundColor: fade(theme.palette.common.white, 0.25), 34 | }, 35 | marginRight: theme.spacing(2), 36 | marginLeft: 0, 37 | width: '100%', 38 | [theme.breakpoints.up('sm')]: { 39 | marginLeft: theme.spacing(3), 40 | width: 'auto', 41 | }, 42 | }, 43 | searchIcon: { 44 | width: theme.spacing(9), 45 | height: '100%', 46 | position: 'absolute', 47 | pointerEvents: 'none', 48 | display: 'flex', 49 | alignItems: 'center', 50 | justifyContent: 'center', 51 | }, 52 | inputRoot: { 53 | color: 'inherit', 54 | width: '100%', 55 | }, 56 | inputInput: { 57 | paddingTop: theme.spacing(), 58 | paddingRight: theme.spacing(), 59 | paddingBottom: theme.spacing(), 60 | paddingLeft: theme.spacing(10), 61 | transition: theme.transitions.create('width'), 62 | width: '100%', 63 | [theme.breakpoints.up('md')]: { 64 | width: 400, 65 | }, 66 | }, 67 | toolbar: { 68 | alignItems: 'center' 69 | } 70 | }); 71 | 72 | class SearchBar extends React.Component { 73 | constructor(props) { 74 | super(props); 75 | this.logout = this.logout.bind(this); 76 | } 77 | 78 | async logout(e) { 79 | e.preventDefault(); 80 | await this.props.oktaAuth.signOut(); 81 | } 82 | 83 | render() { 84 | const { classes } = this.props; 85 | 86 | return ( 87 |
88 | 89 | 90 |
91 |
92 | 93 |
94 | 102 |
103 |
104 | 105 | 106 | 107 |
108 | ); 109 | } 110 | } 111 | 112 | SearchBar.propTypes = { 113 | classes: PropTypes.object.isRequired, 114 | }; 115 | 116 | export default withStyles(styles)(withOktaAuth(SearchBar)); 117 | -------------------------------------------------------------------------------- /app/http/web/app/src/apiClient.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const BASE_URI = 'http://localhost:4433'; 4 | 5 | const client = axios.create({ 6 | baseURL: BASE_URI, 7 | json: true 8 | }); 9 | 10 | class APIClient { 11 | constructor(accessToken) { 12 | this.accessToken = accessToken; 13 | } 14 | 15 | createKudo(repo) { 16 | return this.perform('post', '/kudos', repo); 17 | } 18 | 19 | deleteKudo(repo) { 20 | return this.perform('delete', `/kudos/${repo.id}`); 21 | } 22 | 23 | getKudos() { 24 | return this.perform('get', '/kudos'); 25 | } 26 | 27 | async perform (method, resource, data) { 28 | return client({ 29 | method, 30 | url: resource, 31 | data, 32 | headers: { 33 | Authorization: `Bearer ${this.accessToken}` 34 | } 35 | }).then(resp => { 36 | return resp.data ? resp.data : []; 37 | }) 38 | } 39 | } 40 | 41 | export default APIClient; 42 | -------------------------------------------------------------------------------- /app/http/web/app/src/githubClient.js: -------------------------------------------------------------------------------- 1 | function getJSONRepos(query) { 2 | return fetch('https://api.github.com/search/repositories?q=' + query).then(response => response.json()); 3 | } 4 | 5 | export default getJSONRepos; 6 | -------------------------------------------------------------------------------- /app/http/web/app/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /app/http/web/app/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { Router } from 'react-router-dom' 4 | import { createBrowserHistory } from 'history' 5 | 6 | import Main from './Main'; 7 | 8 | const history = createBrowserHistory(); 9 | 10 | ReactDOM.render(( 11 | 12 |
13 | 14 | ), document.getElementById('root')) 15 | -------------------------------------------------------------------------------- /app/http/web/app/src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/http/web/app/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /app/http/web/app/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /app/kudo/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oktadev/python-flask-react-crud-example/c2165e5d90f556fb90e7b3a39bc34720208d67a5/app/kudo/__init__.py -------------------------------------------------------------------------------- /app/kudo/schema.py: -------------------------------------------------------------------------------- 1 | from marshmallow import Schema, fields 2 | 3 | class GithubRepoSchema(Schema): 4 | id = fields.Int(required=True) 5 | repo_name = fields.Str() 6 | full_name = fields.Str() 7 | language = fields.Str() 8 | description = fields.Str() 9 | repo_url = fields.URL() 10 | 11 | class KudoSchema(GithubRepoSchema): 12 | user_id = fields.Email(required=True) 13 | -------------------------------------------------------------------------------- /app/kudo/service.py: -------------------------------------------------------------------------------- 1 | from ..repository import Repository 2 | from ..repository.mongo import MongoRepository 3 | from .schema import KudoSchema 4 | 5 | class Service(object): 6 | def __init__(self, user_id, repo_client=Repository(adapter=MongoRepository)): 7 | self.repo_client = repo_client 8 | self.user_id = user_id 9 | 10 | if not user_id: 11 | raise Exception("user id not provided") 12 | 13 | def find_all_kudos(self): 14 | kudos = self.repo_client.find_all({'user_id': self.user_id}) 15 | return [self.dump(kudo) for kudo in kudos] 16 | 17 | def find_kudo(self, repo_id): 18 | kudo = self.repo_client.find({'user_id': self.user_id, 'repo_id': repo_id}) 19 | return self.dump(kudo) 20 | 21 | def create_kudo_for(self, githubRepo): 22 | self.repo_client.create(self.prepare_kudo(githubRepo)) 23 | return self.dump(githubRepo.data) 24 | 25 | def update_kudo_with(self, repo_id, githubRepo): 26 | records_affected = self.repo_client.update({'user_id': self.user_id, 'repo_id': repo_id}, self.prepare_kudo(githubRepo)) 27 | return records_affected > 0 28 | 29 | def delete_kudo_for(self, repo_id): 30 | records_affected = self.repo_client.delete({'user_id': self.user_id, 'repo_id': repo_id}) 31 | return records_affected > 0 32 | 33 | def dump(self, data): 34 | return KudoSchema(exclude=['_id']).dump(data).data 35 | 36 | def prepare_kudo(self, githubRepo): 37 | data = githubRepo.data 38 | data['user_id'] = self.user_id 39 | return data 40 | -------------------------------------------------------------------------------- /app/repository/__init__.py: -------------------------------------------------------------------------------- 1 | class Repository(object): 2 | def __init__(self, adapter=None): 3 | self.client = adapter() 4 | 5 | def find_all(self, selector): 6 | return self.client.find_all(selector) 7 | 8 | def find(self, selector): 9 | return self.client.find(selector) 10 | 11 | def create(self, kudo): 12 | return self.client.create(kudo) 13 | 14 | def update(self, selector, kudo): 15 | return self.client.update(selector, kudo) 16 | 17 | def delete(self, selector): 18 | return self.client.delete(selector) 19 | -------------------------------------------------------------------------------- /app/repository/mongo.py: -------------------------------------------------------------------------------- 1 | import os 2 | from pymongo import MongoClient 3 | 4 | COLLECTION_NAME = 'kudos' 5 | 6 | class MongoRepository(object): 7 | def __init__(self): 8 | mongo_url = os.environ.get('MONGO_URL') 9 | self.db = MongoClient(mongo_url).kudos 10 | 11 | def find_all(self, selector): 12 | return self.db.kudos.find(selector) 13 | 14 | def find(self, selector): 15 | return self.db.kudos.find_one(selector) 16 | 17 | def create(self, kudo): 18 | return self.db.kudos.insert_one(kudo) 19 | 20 | def update(self, selector, kudo): 21 | return self.db.kudos.replace_one(selector, kudo).modified_count 22 | 23 | def delete(self, selector): 24 | return self.db.kudos.delete_one(selector).deleted_count 25 | -------------------------------------------------------------------------------- /client_secrets.json: -------------------------------------------------------------------------------- 1 | { 2 | "web": { 3 | "auth_uri": "https://{yourOktaDomain}/oauth2/default/v1/authorize", 4 | "client_id": "{yourClientId}", 5 | "client_secret": "{yourClientSecret}", 6 | "redirect_uris": [ 7 | "http://localhost:8080/authorization-code/callback" 8 | ], 9 | "issuer": "https://{yourOktaDomain}/oauth2/default", 10 | "token_uri": "https://{yourOktaDomain}/oauth2/default/v1/token", 11 | "token_introspection_uri": "https://{yourOktaDomain}/oauth2/default/v1/introspect", 12 | "userinfo_uri": "https://{yourOktaDomain}/oauth2/default/v1/userinfo" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | mongo: 4 | image: mongo 5 | restart: always 6 | ports: 7 | - "27017:27017" 8 | environment: 9 | MONGO_INITDB_ROOT_USERNAME: mongo_user 10 | MONGO_INITDB_ROOT_PASSWORD: mongo_secret 11 | --------------------------------------------------------------------------------