c2cgeoportal-geoportal 2.6.0__py2.py3-none-any.whl → 2.7.1.156__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. c2cgeoportal_geoportal/__init__.py +224 -84
  2. c2cgeoportal_geoportal/lib/__init__.py +67 -43
  3. c2cgeoportal_geoportal/lib/authentication.py +50 -22
  4. c2cgeoportal_geoportal/lib/bashcolor.py +17 -13
  5. c2cgeoportal_geoportal/lib/cacheversion.py +16 -8
  6. c2cgeoportal_geoportal/lib/caching.py +61 -191
  7. c2cgeoportal_geoportal/lib/check_collector.py +17 -10
  8. c2cgeoportal_geoportal/lib/checker.py +61 -63
  9. c2cgeoportal_geoportal/lib/common_headers.py +170 -0
  10. c2cgeoportal_geoportal/lib/dbreflection.py +54 -39
  11. c2cgeoportal_geoportal/lib/filter_capabilities.py +122 -88
  12. c2cgeoportal_geoportal/lib/fulltextsearch.py +6 -5
  13. c2cgeoportal_geoportal/lib/functionality.py +20 -17
  14. c2cgeoportal_geoportal/lib/headers.py +14 -5
  15. c2cgeoportal_geoportal/lib/i18n.py +4 -4
  16. c2cgeoportal_geoportal/lib/layers.py +30 -11
  17. c2cgeoportal_geoportal/lib/lingua_extractor.py +361 -237
  18. c2cgeoportal_geoportal/lib/loader.py +10 -15
  19. c2cgeoportal_geoportal/lib/metrics.py +28 -17
  20. c2cgeoportal_geoportal/lib/oauth2.py +214 -145
  21. c2cgeoportal_geoportal/lib/wmstparsing.py +115 -90
  22. c2cgeoportal_geoportal/lib/xsd.py +26 -16
  23. c2cgeoportal_geoportal/resources.py +15 -9
  24. c2cgeoportal_geoportal/scaffolds/advance_create/ci/config.yaml +26 -0
  25. c2cgeoportal_geoportal/scaffolds/advance_create/cookiecutter.json +18 -0
  26. c2cgeoportal_geoportal/scaffolds/advance_create/{{cookiecutter.project}}/geoportal/.dockerignore +6 -0
  27. c2cgeoportal_geoportal/scaffolds/advance_create/{{cookiecutter.project}}/geoportal/.eslintrc.yaml +19 -0
  28. c2cgeoportal_geoportal/scaffolds/{create/geoportal/+dot+prospector.yaml → advance_create/{{cookiecutter.project}}/geoportal/.prospector.yaml} +8 -2
  29. c2cgeoportal_geoportal/scaffolds/{create/geoportal/Dockerfile_tmpl → advance_create/{{cookiecutter.project}}/geoportal/Dockerfile} +18 -9
  30. c2cgeoportal_geoportal/scaffolds/{create/geoportal/alembic.yaml_tmpl → advance_create/{{cookiecutter.project}}/geoportal/alembic.yaml} +1 -1
  31. c2cgeoportal_geoportal/scaffolds/{create/geoportal/development.ini_tmpl → advance_create/{{cookiecutter.project}}/geoportal/development.ini} +34 -15
  32. c2cgeoportal_geoportal/scaffolds/advance_create/{{cookiecutter.project}}/geoportal/gunicorn.conf.py +102 -0
  33. c2cgeoportal_geoportal/scaffolds/{create → advance_create/{{cookiecutter.project}}}/geoportal/lingua-client.cfg +1 -0
  34. c2cgeoportal_geoportal/scaffolds/advance_create/{{cookiecutter.project}}/geoportal/production.ini +38 -0
  35. c2cgeoportal_geoportal/scaffolds/advance_create/{{cookiecutter.project}}/geoportal/requirements.txt +2 -0
  36. c2cgeoportal_geoportal/scaffolds/{create/geoportal/setup.py_tmpl → advance_create/{{cookiecutter.project}}/geoportal/setup.py} +6 -7
  37. c2cgeoportal_geoportal/scaffolds/{create → advance_create/{{cookiecutter.project}}}/geoportal/tools/extract-messages.js +8 -6
  38. c2cgeoportal_geoportal/scaffolds/advance_create/{{cookiecutter.project}}/geoportal/tsconfig.json +8 -0
  39. c2cgeoportal_geoportal/scaffolds/advance_create/{{cookiecutter.project}}/geoportal/webpack.api.js +75 -0
  40. c2cgeoportal_geoportal/scaffolds/{create/geoportal/webpack.apps.js_tmpl → advance_create/{{cookiecutter.project}}/geoportal/webpack.apps.js} +31 -28
  41. c2cgeoportal_geoportal/scaffolds/{create → advance_create/{{cookiecutter.project}}}/geoportal/webpack.commons.js +3 -7
  42. c2cgeoportal_geoportal/scaffolds/{create → advance_create/{{cookiecutter.project}}}/geoportal/webpack.config.js +1 -1
  43. c2cgeoportal_geoportal/scaffolds/{create/geoportal/+package+_geoportal/__init__.py_tmpl → advance_create/{{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal/__init__.py} +11 -22
  44. c2cgeoportal_geoportal/scaffolds/advance_create/{{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal/authentication.py +10 -0
  45. c2cgeoportal_geoportal/scaffolds/advance_create/{{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal/dev.py +14 -0
  46. c2cgeoportal_geoportal/scaffolds/advance_create/{{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal/models.py +8 -0
  47. c2cgeoportal_geoportal/scaffolds/advance_create/{{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal/multi_organization.py +7 -0
  48. c2cgeoportal_geoportal/scaffolds/{create/geoportal/+package+_geoportal → advance_create/{{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal}/resources.py +4 -3
  49. c2cgeoportal_geoportal/scaffolds/{create/geoportal/+package+_geoportal/static-ngeo/api/index.js_tmpl → advance_create/{{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal/static-ngeo/api/index.js} +1 -2
  50. c2cgeoportal_geoportal/scaffolds/{create/geoportal/+package+_geoportal/static-ngeo/js/+package+module.js_tmpl → advance_create/{{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal/static-ngeo/js/{{cookiecutter.package}}module.js} +4 -4
  51. c2cgeoportal_geoportal/scaffolds/{create/geoportal/+package+_geoportal/subscribers.py_tmpl → advance_create/{{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal/subscribers.py} +1 -3
  52. c2cgeoportal_geoportal/scaffolds/advance_update/cookiecutter.json +18 -0
  53. c2cgeoportal_geoportal/scaffolds/{update/geoportal/CONST_Makefile_tmpl → advance_update/{{cookiecutter.project}}/geoportal/CONST_Makefile} +3 -7
  54. c2cgeoportal_geoportal/scaffolds/create/cookiecutter.json +18 -0
  55. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/.dockerignore +14 -0
  56. c2cgeoportal_geoportal/scaffolds/create/{+dot+editorconfig → {{cookiecutter.project}}/.editorconfig} +2 -5
  57. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/.github/workflows/main.yaml +43 -0
  58. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/.github/workflows/rebuild.yaml +46 -0
  59. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/.github/workflows/update_l10n.yaml +65 -0
  60. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/.gitignore +16 -0
  61. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/.prettierignore +1 -0
  62. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/.prettierrc.yaml +2 -0
  63. c2cgeoportal_geoportal/scaffolds/create/{Dockerfile_tmpl → {{cookiecutter.project}}/Dockerfile} +20 -11
  64. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/Makefile +14 -0
  65. c2cgeoportal_geoportal/scaffolds/create/{README.rst_tmpl → {{cookiecutter.project}}/README.rst} +4 -4
  66. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/build +162 -0
  67. c2cgeoportal_geoportal/scaffolds/create/{ci/config.yaml_tmpl → {{cookiecutter.project}}/ci/config.yaml} +7 -5
  68. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/ci/requirements.txt +1 -0
  69. c2cgeoportal_geoportal/scaffolds/create/{docker-compose-lib.yaml → {{cookiecutter.project}}/docker-compose-lib.yaml} +133 -17
  70. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/docker-compose.override.sample.yaml +67 -0
  71. c2cgeoportal_geoportal/scaffolds/create/{docker-compose.yaml → {{cookiecutter.project}}/docker-compose.yaml} +17 -12
  72. c2cgeoportal_geoportal/scaffolds/create/{env.default_tmpl → {{cookiecutter.project}}/env.default} +29 -14
  73. c2cgeoportal_geoportal/scaffolds/create/{env.project_tmpl → {{cookiecutter.project}}/env.project} +16 -4
  74. c2cgeoportal_geoportal/scaffolds/create/{geoportal/vars.yaml_tmpl → {{cookiecutter.project}}/geoportal/vars.yaml} +93 -27
  75. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal/static/css/mobile.css +0 -0
  76. c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/data/Readme.txt +1 -1
  77. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/mapserver/demo.map.tmpl +224 -0
  78. c2cgeoportal_geoportal/scaffolds/create/{mapserver/mapserver.map.tmpl_tmpl → {{cookiecutter.project}}/mapserver/mapserver.map.tmpl} +7 -15
  79. c2cgeoportal_geoportal/scaffolds/create/{print/print-apps/+package+ → {{cookiecutter.project}}/print/print-apps/{{cookiecutter.package}}}/A3_Landscape.jrxml +8 -8
  80. c2cgeoportal_geoportal/scaffolds/create/{print/print-apps/+package+ → {{cookiecutter.project}}/print/print-apps/{{cookiecutter.package}}}/A3_Portrait.jrxml +8 -8
  81. c2cgeoportal_geoportal/scaffolds/create/{print/print-apps/+package+ → {{cookiecutter.project}}/print/print-apps/{{cookiecutter.package}}}/A4_Landscape.jrxml +8 -8
  82. c2cgeoportal_geoportal/scaffolds/create/{print/print-apps/+package+ → {{cookiecutter.project}}/print/print-apps/{{cookiecutter.package}}}/A4_Portrait.jrxml +8 -8
  83. c2cgeoportal_geoportal/scaffolds/create/{print/print-apps/+package+ → {{cookiecutter.project}}/print/print-apps/{{cookiecutter.package}}}/config.yaml.tmpl +5 -4
  84. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/print/print-apps/{{cookiecutter.package}}/localisation.properties +4 -0
  85. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/print/print-apps/{{cookiecutter.package}}/localisation_fr.properties +4 -0
  86. c2cgeoportal_geoportal/scaffolds/create/{project.yaml_tmpl → {{cookiecutter.project}}/project.yaml} +6 -6
  87. c2cgeoportal_geoportal/scaffolds/create/{qgisserver/pg_service.conf.tmpl_tmpl → {{cookiecutter.project}}/qgisserver/pg_service.conf.tmpl} +2 -2
  88. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/scripts/db-backup +110 -0
  89. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/scripts/db-restore +114 -0
  90. c2cgeoportal_geoportal/scaffolds/create/{setup.cfg_tmpl → {{cookiecutter.project}}/setup.cfg} +1 -1
  91. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/spell-ignore-words.txt +3 -0
  92. c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/tilegeneration/config.yaml.tmpl +195 -0
  93. c2cgeoportal_geoportal/scaffolds/update/cookiecutter.json +18 -0
  94. c2cgeoportal_geoportal/scaffolds/update/{+dot+upgrade.yaml_tmpl → {{cookiecutter.project}}/.upgrade.yaml} +49 -39
  95. c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/CONST_CHANGELOG.txt +1160 -0
  96. c2cgeoportal_geoportal/scaffolds/update/{geoportal → {{cookiecutter.project}}/geoportal}/CONST_config-schema.yaml +47 -2
  97. c2cgeoportal_geoportal/scaffolds/update/{geoportal/CONST_vars.yaml_tmpl → {{cookiecutter.project}}/geoportal/CONST_vars.yaml} +350 -17
  98. c2cgeoportal_geoportal/scripts/__init__.py +16 -30
  99. c2cgeoportal_geoportal/scripts/c2cupgrade.py +271 -232
  100. c2cgeoportal_geoportal/scripts/create_demo_theme.py +3 -6
  101. c2cgeoportal_geoportal/scripts/manage_users.py +34 -39
  102. c2cgeoportal_geoportal/scripts/pcreate.py +312 -0
  103. c2cgeoportal_geoportal/scripts/theme2fts.py +72 -23
  104. c2cgeoportal_geoportal/scripts/urllogin.py +19 -11
  105. c2cgeoportal_geoportal/templates/login.html +88 -84
  106. c2cgeoportal_geoportal/templates/notlogin.html +59 -59
  107. c2cgeoportal_geoportal/templates/testi18n.html +6 -8
  108. c2cgeoportal_geoportal/views/__init__.py +23 -4
  109. c2cgeoportal_geoportal/views/dev.py +9 -7
  110. c2cgeoportal_geoportal/views/dynamic.py +56 -19
  111. c2cgeoportal_geoportal/views/entry.py +93 -24
  112. c2cgeoportal_geoportal/views/fulltextsearch.py +28 -22
  113. c2cgeoportal_geoportal/views/geometry_processing.py +15 -7
  114. c2cgeoportal_geoportal/views/i18n.py +91 -9
  115. c2cgeoportal_geoportal/views/layers.py +160 -126
  116. c2cgeoportal_geoportal/views/login.py +106 -93
  117. c2cgeoportal_geoportal/views/mapserverproxy.py +46 -29
  118. c2cgeoportal_geoportal/views/memory.py +12 -12
  119. c2cgeoportal_geoportal/views/ogcproxy.py +48 -30
  120. c2cgeoportal_geoportal/views/pdfreport.py +26 -22
  121. c2cgeoportal_geoportal/views/printproxy.py +60 -52
  122. c2cgeoportal_geoportal/views/profile.py +24 -23
  123. c2cgeoportal_geoportal/views/proxy.py +87 -69
  124. c2cgeoportal_geoportal/views/raster.py +35 -24
  125. c2cgeoportal_geoportal/views/resourceproxy.py +13 -11
  126. c2cgeoportal_geoportal/views/shortener.py +27 -24
  127. c2cgeoportal_geoportal/views/theme.py +427 -321
  128. c2cgeoportal_geoportal/views/tinyowsproxy.py +46 -39
  129. c2cgeoportal_geoportal/views/vector_tiles.py +80 -0
  130. {c2cgeoportal_geoportal-2.6.0.dist-info → c2cgeoportal_geoportal-2.7.1.156.dist-info}/METADATA +25 -20
  131. c2cgeoportal_geoportal-2.7.1.156.dist-info/RECORD +185 -0
  132. {c2cgeoportal_geoportal-2.6.0.dist-info → c2cgeoportal_geoportal-2.7.1.156.dist-info}/WHEEL +1 -1
  133. {c2cgeoportal_geoportal-2.6.0.dist-info → c2cgeoportal_geoportal-2.7.1.156.dist-info}/entry_points.txt +3 -1
  134. tests/__init__.py +7 -3
  135. tests/test_cachebuster.py +0 -2
  136. tests/test_caching.py +17 -25
  137. tests/test_checker.py +0 -2
  138. tests/test_decimaljson.py +4 -4
  139. tests/test_headerstween.py +0 -2
  140. tests/test_i18n.py +1 -1
  141. tests/test_init.py +4 -7
  142. tests/test_locale_negociator.py +0 -2
  143. tests/test_mapserverproxy_route_predicate.py +0 -2
  144. tests/test_raster.py +0 -2
  145. tests/test_wmstparsing.py +0 -2
  146. c2cgeoportal_geoportal/scaffolds/__init__.py +0 -227
  147. c2cgeoportal_geoportal/scaffolds/create/+dot+dockerignore_tmpl +0 -12
  148. c2cgeoportal_geoportal/scaffolds/create/+dot+github/workflows/main.yaml_tmpl +0 -89
  149. c2cgeoportal_geoportal/scaffolds/create/+dot+github/workflows/rebuild.yaml_tmpl +0 -78
  150. c2cgeoportal_geoportal/scaffolds/create/+dot+gitignore_tmpl +0 -16
  151. c2cgeoportal_geoportal/scaffolds/create/Makefile +0 -3
  152. c2cgeoportal_geoportal/scaffolds/create/build_tmpl +0 -167
  153. c2cgeoportal_geoportal/scaffolds/create/ci/requirements.txt +0 -1
  154. c2cgeoportal_geoportal/scaffolds/create/ci/trigger +0 -68
  155. c2cgeoportal_geoportal/scaffolds/create/docker-compose.override.sample.yaml +0 -54
  156. c2cgeoportal_geoportal/scaffolds/create/geoportal/+dot+dockerignore_tmpl +0 -6
  157. c2cgeoportal_geoportal/scaffolds/create/geoportal/+dot+eslintrc_tmpl +0 -15
  158. c2cgeoportal_geoportal/scaffolds/create/geoportal/+package+_geoportal/models.py_tmpl +0 -10
  159. c2cgeoportal_geoportal/scaffolds/create/geoportal/+package+_geoportal/static/robot.txt +0 -3
  160. c2cgeoportal_geoportal/scaffolds/create/geoportal/production.ini_tmpl +0 -106
  161. c2cgeoportal_geoportal/scaffolds/create/geoportal/requirements.txt +0 -2
  162. c2cgeoportal_geoportal/scaffolds/create/geoportal/tsconfig.json_tmpl +0 -9
  163. c2cgeoportal_geoportal/scaffolds/create/geoportal/webpack.api.js_tmpl +0 -72
  164. c2cgeoportal_geoportal/scaffolds/create/mapserver/demo.map.tmpl_tmpl +0 -262
  165. c2cgeoportal_geoportal/scaffolds/create/mapserver/tinyows.xml +0 -36
  166. c2cgeoportal_geoportal/scaffolds/create/print/print-apps/+package+/config.yaml +0 -168
  167. c2cgeoportal_geoportal/scaffolds/create/qgisserver/geomapfish.yaml.tmpl_tmpl +0 -16
  168. c2cgeoportal_geoportal/scaffolds/create/spell-ignore-words.txt +0 -1
  169. c2cgeoportal_geoportal/scaffolds/create/tilegeneration/config.yaml.tmpl_tmpl +0 -185
  170. c2cgeoportal_geoportal/scaffolds/create/yamllint.yaml +0 -11
  171. c2cgeoportal_geoportal/scaffolds/update/CONST_CHANGELOG.txt_tmpl +0 -454
  172. c2cgeoportal_geoportal/templates/dynamic.js +0 -21
  173. c2cgeoportal_geoportal-2.6.0.dist-info/RECORD +0 -173
  174. /c2cgeoportal_geoportal/{scaffolds/create/geoportal/+package+_geoportal/static/css/desktop.css → py.typed} +0 -0
  175. /c2cgeoportal_geoportal/scaffolds/{create/geoportal/Makefile_tmpl → advance_create/{{cookiecutter.project}}/geoportal/Makefile} +0 -0
  176. /c2cgeoportal_geoportal/scaffolds/{create → advance_create/{{cookiecutter.project}}}/geoportal/alembic.ini +0 -0
  177. /c2cgeoportal_geoportal/scaffolds/{create → advance_create/{{cookiecutter.project}}}/geoportal/language_mapping +0 -0
  178. /c2cgeoportal_geoportal/scaffolds/{create → advance_create/{{cookiecutter.project}}}/geoportal/lingua-server.cfg +0 -0
  179. /c2cgeoportal_geoportal/scaffolds/{create/geoportal/+package+_geoportal → advance_create/{{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal}/views/__init__.py +0 -0
  180. /c2cgeoportal_geoportal/scaffolds/create/{geoportal/+package+_geoportal/locale/en/LC_MESSAGES/+package+_geoportal-client.po → {{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal/locale/en/LC_MESSAGES/{{cookiecutter.package}}_geoportal-client.po} +0 -0
  181. /c2cgeoportal_geoportal/scaffolds/create/{geoportal/+package+_geoportal/static/css/iframe_api.css → {{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal/static/css/desktop.css} +0 -0
  182. /c2cgeoportal_geoportal/scaffolds/create/{geoportal/+package+_geoportal/static/css/mobile.css → {{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal/static/css/iframe_api.css} +0 -0
  183. /c2cgeoportal_geoportal/scaffolds/create/{geoportal/+package+_geoportal → {{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal}/static/images/banner_left.png +0 -0
  184. /c2cgeoportal_geoportal/scaffolds/create/{geoportal/+package+_geoportal → {{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal}/static/images/banner_right.png +0 -0
  185. /c2cgeoportal_geoportal/scaffolds/create/{geoportal/+package+_geoportal → {{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal}/static/images/blank.png +0 -0
  186. /c2cgeoportal_geoportal/scaffolds/create/{geoportal/+package+_geoportal → {{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal}/static/images/markers/marker-blue.png +0 -0
  187. /c2cgeoportal_geoportal/scaffolds/create/{geoportal/+package+_geoportal → {{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal}/static/images/markers/marker-gold.png +0 -0
  188. /c2cgeoportal_geoportal/scaffolds/create/{geoportal/+package+_geoportal → {{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal}/static/images/markers/marker-green.png +0 -0
  189. /c2cgeoportal_geoportal/scaffolds/create/{geoportal/+package+_geoportal → {{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal}/static/images/markers/marker.png +0 -0
  190. /c2cgeoportal_geoportal/scaffolds/create/{geoportal/+package+_geoportal → {{cookiecutter.project}}/geoportal/{{cookiecutter.package}}_geoportal}/static/robot.txt.tmpl +0 -0
  191. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/data/TM_EUROPE_BORDERS-0.3.sql +0 -0
  192. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts/Arial.ttf +0 -0
  193. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts/Arialbd.ttf +0 -0
  194. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts/Arialbi.ttf +0 -0
  195. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts/Ariali.ttf +0 -0
  196. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts/NotoSans-Bold.ttf +0 -0
  197. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts/NotoSans-BoldItalic.ttf +0 -0
  198. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts/NotoSans-Italic.ttf +0 -0
  199. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts/NotoSans-Regular.ttf +0 -0
  200. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts/Verdana.ttf +0 -0
  201. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts/Verdanab.ttf +0 -0
  202. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts/Verdanai.ttf +0 -0
  203. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts/Verdanaz.ttf +0 -0
  204. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/fonts.conf +0 -0
  205. /c2cgeoportal_geoportal/scaffolds/create/{mapserver → {{cookiecutter.project}}/mapserver}/tinyows.xml.tmpl +0 -0
  206. /c2cgeoportal_geoportal/scaffolds/create/{print/print-apps/+package+ → {{cookiecutter.project}}/print/print-apps/{{cookiecutter.package}}}/legend.jrxml +0 -0
  207. /c2cgeoportal_geoportal/scaffolds/create/{print/print-apps/+package+ → {{cookiecutter.project}}/print/print-apps/{{cookiecutter.package}}}/logo.png +0 -0
  208. /c2cgeoportal_geoportal/scaffolds/create/{print/print-apps/+package+ → {{cookiecutter.project}}/print/print-apps/{{cookiecutter.package}}}/north.svg +0 -0
  209. /c2cgeoportal_geoportal/scaffolds/create/{print/print-apps/+package+ → {{cookiecutter.project}}/print/print-apps/{{cookiecutter.package}}}/results.jrxml +0 -0
  210. /c2cgeoportal_geoportal/scaffolds/create/{pyproject.toml → {{cookiecutter.project}}/pyproject.toml} +0 -0
  211. /c2cgeoportal_geoportal/scaffolds/create/{run_alembic.sh → {{cookiecutter.project}}/run_alembic.sh} +0 -0
  212. {c2cgeoportal_geoportal-2.6.0.dist-info → c2cgeoportal_geoportal-2.7.1.156.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2021, Camptocamp SA
1
+ # Copyright (c) 2021-2024, Camptocamp SA
4
2
  # All rights reserved.
5
3
 
6
4
  # Redistribution and use in source and binary forms, with or without
@@ -31,18 +29,22 @@ import logging
31
29
  from datetime import datetime, timedelta
32
30
  from typing import Any, Dict, List, Union
33
31
 
32
+ import basicauth
34
33
  import oauthlib.common
35
34
  import oauthlib.oauth2
36
35
  import pyramid.threadlocal
37
36
 
37
+ import c2cgeoportal_commons # pylint: disable=unused-import
38
38
  from c2cgeoportal_geoportal.lib.caching import get_region
39
39
 
40
40
  LOG = logging.getLogger(__name__)
41
41
  OBJECT_CACHE_REGION = get_region("obj")
42
42
 
43
43
 
44
- class RequestValidator(oauthlib.oauth2.RequestValidator):
45
- def __init__(self, authorization_expires_in):
44
+ class RequestValidator(oauthlib.oauth2.RequestValidator): # type: ignore
45
+ """The oauth2 request validator implementation."""
46
+
47
+ def __init__(self, authorization_expires_in: int) -> None:
46
48
  # in minutes
47
49
  self.authorization_expires_in = authorization_expires_in
48
50
 
@@ -63,8 +65,11 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
63
65
  both body and query can be obtained by direct attribute access, i.e.
64
66
  request.client_id for client_id in the URL query.
65
67
 
66
- :param request: oauthlib.common.Request
67
- :rtype: True or False
68
+ Arguments:
69
+
70
+ request: oauthlib.common.Request
71
+
72
+ Returns: True or False
68
73
 
69
74
  Method is used by:
70
75
  - Authorization Code Grant
@@ -72,23 +77,13 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
72
77
  - Client Credentials Grant
73
78
  - Refresh Token Grant
74
79
 
75
- .. _`HTTP Basic Authentication Scheme`: http://tools.ietf.org/html/rfc1945#section-11.1
80
+ .. _`HTTP Basic Authentication Scheme`: https://tools.ietf.org/html/rfc1945#section-11.1
76
81
  """
77
82
  del args, kwargs
78
83
 
79
- LOG.debug("authenticate_client")
84
+ LOG.debug("authenticate_client => unimplemented")
80
85
 
81
- from c2cgeoportal_commons.models import DBSession, static # pylint: disable=import-outside-toplevel
82
-
83
- params = dict(request.decoded_body)
84
-
85
- request.client = (
86
- DBSession.query(static.OAuth2Client)
87
- .filter(static.OAuth2Client.client_id == params["client_id"])
88
- .one_or_none()
89
- )
90
-
91
- return request.client is not None
86
+ raise NotImplementedError("Not implemented, the method `authenticate_client_id` should be used.")
92
87
 
93
88
  def authenticate_client_id( # pylint: disable=no-self-use,useless-suppression
94
89
  self,
@@ -107,9 +102,6 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
107
102
  to set request.client to the client object associated with the
108
103
  given client_id.
109
104
 
110
- :param request: oauthlib.common.Request
111
- :rtype: True or False
112
-
113
105
  Method is used by:
114
106
  - Authorization Code Grant
115
107
  """
@@ -121,13 +113,24 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
121
113
 
122
114
  params = dict(request.decoded_body)
123
115
 
116
+ if "client_secret" in params:
117
+ client_secret = params["client_secret"]
118
+ elif "Authorization" in request.headers:
119
+ username, password = basicauth.decode(request.headers["Authorization"])
120
+ assert client_id == username
121
+ client_secret = password
122
+ else:
123
+ # Unable to get the client secret
124
+ return False
125
+
124
126
  request.client = (
125
127
  DBSession.query(static.OAuth2Client)
126
128
  .filter(static.OAuth2Client.client_id == client_id)
127
- .filter(static.OAuth2Client.secret == params["client_secret"])
129
+ .filter(static.OAuth2Client.secret == client_secret)
128
130
  .one_or_none()
129
131
  )
130
132
 
133
+ LOG.debug("authenticate_client_id => %s", request.client is not None)
131
134
  return request.client is not None
132
135
 
133
136
  def client_authentication_required( # pylint: disable=no-self-use,useless-suppression
@@ -150,23 +153,26 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
150
153
  client credentials or whenever Client provided client authentication, see
151
154
  `Section 6`_
152
155
 
153
- :param request: oauthlib.common.Request
154
- :rtype: True or False
156
+ Arguments:
157
+
158
+ request: oauthlib.common.Request
159
+
160
+ Returns: True or False
155
161
 
156
162
  Method is used by:
157
163
  - Authorization Code Grant
158
164
  - Resource Owner Password Credentials Grant
159
165
  - Refresh Token Grant
160
166
 
161
- .. _`Section 4.3.2`: http://tools.ietf.org/html/rfc6749#section-4.3.2
162
- .. _`Section 4.1.3`: http://tools.ietf.org/html/rfc6749#section-4.1.3
163
- .. _`Section 6`: http://tools.ietf.org/html/rfc6749#section-6
167
+ .. _`Section 4.3.2`: https://tools.ietf.org/html/rfc6749#section-4.3.2
168
+ .. _`Section 4.1.3`: https://tools.ietf.org/html/rfc6749#section-4.1.3
169
+ .. _`Section 6`: https://tools.ietf.org/html/rfc6749#section-6
164
170
  """
165
171
  del request, args, kwargs
166
172
 
167
- LOG.debug("client_authentication_required")
173
+ LOG.debug("client_authentication_required => False")
168
174
 
169
- return True
175
+ return False
170
176
 
171
177
  def confirm_redirect_uri( # pylint: disable=no-self-use,useless-suppression
172
178
  self,
@@ -178,8 +184,10 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
178
184
  **kwargs: Any,
179
185
  ) -> bool:
180
186
  """
181
- Ensure that the authorization process represented by this authorization
182
- code began with this 'redirect_uri'.
187
+ Ensure that the authorization process is correct.
188
+
189
+ Ensure that the authorization process represented by this authorization code began with this
190
+ ``redirect_uri``.
183
191
 
184
192
  If the client specifies a redirect_uri when obtaining code then that
185
193
  redirect URI must be bound to the code and verified equal in this
@@ -187,12 +195,15 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
187
195
  the client's allowed redirect URIs, but against the URI used when the
188
196
  code was saved.
189
197
 
190
- :param client_id: Unicode client identifier
191
- :param code: Unicode authorization_code.
192
- :param redirect_uri: Unicode absolute URI
193
- :param client: Client object set by you, see authenticate_client.
194
- :param request: The HTTP Request (oauthlib.common.Request)
195
- :rtype: True or False
198
+ Arguments:
199
+
200
+ client_id: Unicode client identifier
201
+ code: Unicode authorization_code.
202
+ redirect_uri: Unicode absolute URI
203
+ client: Client object set by you, see authenticate_client.
204
+ request: The HTTP Request
205
+
206
+ Returns: True or False
196
207
 
197
208
  Method is used by:
198
209
  - Authorization Code Grant (during token request)
@@ -212,20 +223,26 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
212
223
  .filter(static.OAuth2AuthorizationCode.expire_at > datetime.now())
213
224
  .one_or_none()
214
225
  )
226
+ LOG.debug("confirm_redirect_uri => %s", authorization_code is not None)
215
227
  return authorization_code is not None
216
228
 
217
229
  def get_code_challenge_method( # pylint: disable=no-self-use,useless-suppression
218
230
  self, code: str, request: oauthlib.common.Request
219
231
  ) -> None:
220
- """Is called during the "token" request processing, when a
221
- ``code_verifier`` and a ``code_challenge`` has been provided.
222
- See ``.get_code_challenge``.
223
- Must return ``plain`` or ``S256``. You can return a custom value if you have
224
- implemented your own ``AuthorizationCodeGrant`` class.
225
- :param code: Authorization code.
226
- :param request: OAuthlib request.
227
- :type request: oauthlib.common.Request
228
- :rtype: code_challenge_method string
232
+ """
233
+ Is called during the "token" request processing.
234
+
235
+ When a ``code_verifier`` and a ``code_challenge`` has
236
+ been provided. See ``.get_code_challenge``. Must return ``plain`` or ``S256``. You can return a custom
237
+ value if you have implemented your own ``AuthorizationCodeGrant`` class.
238
+
239
+ Arguments:
240
+
241
+ code: Authorization code.
242
+ request: OAuthlib request.
243
+
244
+ Returns: code_challenge_method string
245
+
229
246
  Method is used by:
230
247
  - Authorization Code Grant - when PKCE is active
231
248
  """
@@ -245,9 +262,12 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
245
262
  """
246
263
  Get the default redirect URI for the client.
247
264
 
248
- :param client_id: Unicode client identifier
249
- :param request: The HTTP Request (oauthlib.common.Request)
250
- :rtype: The default redirect URI for the client
265
+ Arguments:
266
+
267
+ client_id: Unicode client identifier
268
+ request: The HTTP Request
269
+
270
+ Returns: The default redirect URI for the client
251
271
 
252
272
  Method is used by:
253
273
  - Authorization Code Grant
@@ -269,9 +289,12 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
269
289
  """
270
290
  Get the default scopes for the client.
271
291
 
272
- :param client_id: Unicode client identifier
273
- :param request: The HTTP Request (oauthlib.common.Request)
274
- :rtype: List of default scopes
292
+ Arguments:
293
+
294
+ client_id: Unicode client identifier
295
+ request: The HTTP Request
296
+
297
+ Returns: List of default scopes
275
298
 
276
299
  Method is used by all core grant types:
277
300
  - Authorization Code Grant
@@ -295,9 +318,12 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
295
318
  """
296
319
  Get the list of scopes associated with the refresh token.
297
320
 
298
- :param refresh_token: Unicode refresh token
299
- :param request: The HTTP Request (oauthlib.common.Request)
300
- :rtype: List of scopes.
321
+ Arguments:
322
+
323
+ refresh_token: Unicode refresh token
324
+ request: The HTTP Request
325
+
326
+ Returns: List of scopes.
301
327
 
302
328
  Method is used by:
303
329
  - Refresh token grant
@@ -316,11 +342,13 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
316
342
  *args: Any,
317
343
  **kwargs: Any,
318
344
  ) -> None:
319
- """Introspect an access or refresh token.
320
- Called once the introspect request is validated. This method should
321
- verify the *token* and either return a dictionary with the list of
322
- claims associated, or `None` in case the token is unknown.
323
- Below the list of registered claims you should be interested in:
345
+ """
346
+ Introspect an access or refresh token.
347
+
348
+ Called once the introspect request is validated. This method
349
+ should verify the *token* and either return a dictionary with the list of claims associated, or `None`
350
+ in case the token is unknown. Below the list of registered claims you should be interested in:
351
+
324
352
  - scope : space-separated list of scopes
325
353
  - client_id : client identifier
326
354
  - username : human-readable identifier for the resource owner
@@ -337,12 +365,16 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
337
365
  The implementation can use *token_type_hint* to improve lookup
338
366
  efficiency, but must fallback to other types to be compliant with RFC.
339
367
  The dict of claims is added to request.token after this method.
340
- :param token: The token string.
341
- :param token_type_hint: access_token or refresh_token.
342
- :param request: OAuthlib request.
343
- :type request: oauthlib.common.Request
368
+
369
+ Arguments:
370
+
371
+ token: The token string.
372
+ token_type_hint: access_token or refresh_token.
373
+ request: OAuthlib request.
374
+
344
375
  Method is used by:
345
376
  - Introspect Endpoint (all grants are compatible)
377
+
346
378
  .. _`Introspect Claims`: https://tools.ietf.org/html/rfc7662#section-2.2
347
379
  .. _`JWT Claims`: https://tools.ietf.org/html/rfc7519#section-4
348
380
  """
@@ -363,9 +395,11 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
363
395
  """
364
396
  Invalidate an authorization code after use.
365
397
 
366
- :param client_id: Unicode client identifier
367
- :param code: The authorization code grant (request.code).
368
- :param request: The HTTP Request (oauthlib.common.Request)
398
+ Arguments:
399
+
400
+ client_id: Unicode client identifier
401
+ code: The authorization code grant (request.code).
402
+ request: The HTTP Request
369
403
 
370
404
  Method is used by:
371
405
  - Authorization Code Grant
@@ -404,10 +438,11 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
404
438
  used in situations where returning all valid scopes from the
405
439
  get_original_scopes is not practical.
406
440
 
407
- :param request_scopes: A list of scopes that were requested by client
408
- :param refresh_token: Unicode refresh_token
409
- :param request: The HTTP Request (oauthlib.common.Request)
410
- :rtype: True or False
441
+ Arguments:
442
+
443
+ request_scopes: A list of scopes that were requested by client
444
+ refresh_token: Unicode refresh_token
445
+ request: The HTTP Request
411
446
 
412
447
  Method is used by:
413
448
  - Refresh token grant
@@ -429,9 +464,11 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
429
464
  """
430
465
  Revoke an access or refresh token.
431
466
 
432
- :param token: The token string.
433
- :param token_type_hint: access_token or refresh_token.
434
- :param request: The HTTP Request (oauthlib.common.Request)
467
+ Arguments:
468
+
469
+ token: The token string.
470
+ token_type_hint: access_token or refresh_token.
471
+ request: The HTTP Request
435
472
 
436
473
  Method is used by:
437
474
  - Revocation Endpoint
@@ -452,8 +489,9 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
452
489
  or replaced with a new one (rotated). Return True to rotate and
453
490
  and False for keeping original.
454
491
 
455
- :param request: oauthlib.common.Request
456
- :rtype: True or False
492
+ Arguments:
493
+
494
+ request: oauthlib.common.Request
457
495
 
458
496
  Method is used by:
459
497
  - Refresh Token Grant
@@ -491,9 +529,11 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
491
529
  chose to send one. That value should be saved and used in
492
530
  'validate_code'.
493
531
 
494
- :param client_id: Unicode client identifier
495
- :param code: A dict of the authorization code grant and, optionally, state.
496
- :param request: The HTTP Request (oauthlib.common.Request)
532
+ Arguments:
533
+
534
+ client_id: Unicode client identifier
535
+ code: A dict of the authorization code grant and, optionally, state.
536
+ request: The HTTP Request
497
537
 
498
538
  Method is used by:
499
539
  - Authorization Code Grant
@@ -559,10 +599,13 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
559
599
  Note that while "scope" is a string-separated list of authorized scopes,
560
600
  the original list is still available in request.scopes
561
601
 
562
- :param client_id: Unicode client identifier
563
- :param token: A Bearer token dict
564
- :param request: The HTTP Request (oauthlib.common.Request)
565
- :rtype: The default redirect URI for the client
602
+ Arguments:
603
+
604
+ client_id: Unicode client identifier
605
+ token: A Bearer token dict
606
+ request: The HTTP Request
607
+
608
+ Returns: The default redirect URI for the client
566
609
 
567
610
  Method is used by all core grant types issuing Bearer tokens:
568
611
  - Authorization Code Grant
@@ -607,9 +650,11 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
607
650
  """
608
651
  Ensure the Bearer token is valid and authorized access to scopes.
609
652
 
610
- :param token: A string of random characters.
611
- :param scopes: A list of scopes associated with the protected resource.
612
- :param request: The HTTP Request (oauthlib.common.Request)
653
+ Arguments:
654
+
655
+ token: A string of random characters.
656
+ scopes: A list of scopes associated with the protected resource.
657
+ request: The HTTP Request
613
658
 
614
659
  A key to OAuth 2 security and restricting impact of leaked tokens is
615
660
  the short expiration time of tokens, *always ensure the token has not
@@ -641,10 +686,11 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
641
686
  one provided for django these attributes will be made available
642
687
  in all protected views as keyword arguments.
643
688
 
644
- :param token: Unicode Bearer token
645
- :param scopes: List of scopes (defined by you)
646
- :param request: The HTTP Request (oauthlib.common.Request)
647
- :rtype: True or False
689
+ Arguments:
690
+
691
+ token: Unicode Bearer token
692
+ scopes: List of scopes (defined by you)
693
+ request: The HTTP Request
648
694
 
649
695
  Method is indirectly used by all core Bearer token issuing grant types:
650
696
  - Authorization Code Grant
@@ -666,6 +712,7 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
666
712
  if bearer_token is not None:
667
713
  request.user = bearer_token.user
668
714
 
715
+ LOG.debug("validate_bearer_token => %s", bearer_token is not None)
669
716
  return bearer_token is not None
670
717
 
671
718
  def validate_client_id( # pylint: disable=no-self-use,useless-suppression
@@ -682,8 +729,10 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
682
729
  to set request.client to the client object associated with the
683
730
  given client_id.
684
731
 
685
- :param request: oauthlib.common.Request
686
- :rtype: True or False
732
+ Arguments:
733
+
734
+ client_id: Unicode client identifier
735
+ request: oauthlib.common.Request
687
736
 
688
737
  Method is used by:
689
738
  - Authorization Code Grant
@@ -714,8 +763,7 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
714
763
  **kwargs: Any,
715
764
  ) -> bool:
716
765
  """
717
- Verify that the authorization_code is valid and assigned to the given
718
- client.
766
+ Verify that the authorization_code is valid and assigned to the given client.
719
767
 
720
768
  Before returning true, set the following based on the information stored
721
769
  with the code in 'save_authorization_code':
@@ -727,11 +775,12 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
727
775
  associated with this authorization code. Similarly request.scopes
728
776
  must also be set.
729
777
 
730
- :param client_id: Unicode client identifier
731
- :param code: Unicode authorization code
732
- :param client: Client object set by you, see authenticate_client.
733
- :param request: The HTTP Request (oauthlib.common.Request)
734
- :rtype: True or False
778
+ Arguments:
779
+
780
+ client_id: Unicode client identifier
781
+ code: Unicode authorization code
782
+ client: Client object set by you, see authenticate_client.
783
+ request: The HTTP Request
735
784
 
736
785
  Method is used by:
737
786
  - Authorization Code Grant
@@ -752,13 +801,14 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
752
801
  )
753
802
  if authorization_code is not None:
754
803
  request.user = authorization_code.user
804
+ LOG.debug("validate_code => %s", authorization_code is not None)
755
805
  return authorization_code is not None
756
806
 
757
807
  def validate_grant_type( # pylint: disable=no-self-use,useless-suppression
758
808
  self,
759
809
  client_id: str,
760
810
  grant_type: str,
761
- client,
811
+ client: "c2cgeoportal_commons.models.static.OAuth2Client",
762
812
  request: oauthlib.common.Request,
763
813
  *args: Any,
764
814
  **kwargs: Any,
@@ -766,11 +816,12 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
766
816
  """
767
817
  Ensure client is authorized to use the grant_type requested.
768
818
 
769
- :param client_id: Unicode client identifier
770
- :param grant_type: Unicode grant type, i.e. authorization_code, password.
771
- :param client: Client object set by you, see authenticate_client.
772
- :param request: The HTTP Request (oauthlib.common.Request)
773
- :rtype: True or False
819
+ Arguments:
820
+
821
+ client_id: Unicode client identifier
822
+ grant_type: Unicode grant type, i.e. authorization_code, password.
823
+ client: Client object set by you, see authenticate_client.
824
+ request: The HTTP Request
774
825
 
775
826
  Method is used by:
776
827
  - Authorization Code Grant
@@ -778,9 +829,14 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
778
829
  - Client Credentials Grant
779
830
  - Refresh Token Grant
780
831
  """
781
- del request, args, kwargs
832
+ del client, request, args, kwargs
782
833
 
783
- LOG.debug("validate_grant_type %s %s", client_id, grant_type)
834
+ LOG.debug(
835
+ "validate_grant_type %s %s => %s",
836
+ client_id,
837
+ grant_type,
838
+ grant_type in ("authorization_code", "refresh_token"),
839
+ )
784
840
 
785
841
  return grant_type in ("authorization_code", "refresh_token")
786
842
 
@@ -798,10 +854,11 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
798
854
  All clients should register the absolute URIs of all URIs they intend
799
855
  to redirect to. The registration is outside of the scope of oauthlib.
800
856
 
801
- :param client_id: Unicode client identifier
802
- :param redirect_uri: Unicode absolute URI
803
- :param request: The HTTP Request (oauthlib.common.Request)
804
- :rtype: True or False
857
+ Arguments:
858
+
859
+ client_id: Unicode client identifier
860
+ redirect_uri: Unicode absolute URI
861
+ request: The HTTP Request
805
862
 
806
863
  Method is used by:
807
864
  - Authorization Code Grant
@@ -836,10 +893,11 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
836
893
  OBS! The request.user attribute should be set to the resource owner
837
894
  associated with this refresh token.
838
895
 
839
- :param refresh_token: Unicode refresh token
840
- :param client: Client object set by you, see authenticate_client.
841
- :param request: The HTTP Request (oauthlib.common.Request)
842
- :rtype: True or False
896
+ Arguments:
897
+
898
+ refresh_token: Unicode refresh token
899
+ client: Client object set by you, see authenticate_client.
900
+ request: The HTTP Request
843
901
 
844
902
  Method is used by:
845
903
  - Authorization Code Grant (indirectly by issuing refresh tokens)
@@ -856,7 +914,6 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
856
914
  DBSession.query(static.OAuth2BearerToken)
857
915
  .filter(static.OAuth2BearerToken.refresh_token == refresh_token)
858
916
  .filter(static.OAuth2BearerToken.client_id == request.client.id)
859
- .filter(static.OAuth2BearerToken.expire_at > datetime.now())
860
917
  .one_or_none()
861
918
  )
862
919
 
@@ -869,7 +926,7 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
869
926
  self,
870
927
  client_id: str,
871
928
  response_type: str,
872
- client,
929
+ client: "c2cgeoportal_commons.models.static.OAuth2Client",
873
930
  request: oauthlib.common.Request,
874
931
  *args: Any,
875
932
  **kwargs: Any,
@@ -877,17 +934,18 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
877
934
  """
878
935
  Ensure client is authorized to use the response_type requested.
879
936
 
880
- :param client_id: Unicode client identifier
881
- :param response_type: Unicode response type, i.e. code, token.
882
- :param client: Client object set by you, see authenticate_client.
883
- :param request: The HTTP Request (oauthlib.common.Request)
884
- :rtype: True or False
937
+ Arguments:
938
+
939
+ client_id: Unicode client identifier
940
+ response_type: Unicode response type, i.e. code, token.
941
+ client: Client object set by you, see authenticate_client.
942
+ request: The HTTP Request
885
943
 
886
944
  Method is used by:
887
945
  - Authorization Code Grant
888
946
  - Implicit Grant
889
947
  """
890
- del request, args, kwargs
948
+ del client, request, args, kwargs
891
949
 
892
950
  LOG.debug("validate_response_type %s %s", client_id, response_type)
893
951
 
@@ -897,7 +955,7 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
897
955
  self,
898
956
  client_id: str,
899
957
  scopes: List[str],
900
- client,
958
+ client: "c2cgeoportal_commons.models.static.OAuth2Client",
901
959
  request: oauthlib.common.Request,
902
960
  *args: Any,
903
961
  **kwargs: Any,
@@ -905,11 +963,12 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
905
963
  """
906
964
  Ensure the client is authorized access to requested scopes.
907
965
 
908
- :param client_id: Unicode client identifier
909
- :param scopes: List of scopes (defined by you)
910
- :param client: Client object set by you, see authenticate_client.
911
- :param request: The HTTP Request (oauthlib.common.Request)
912
- :rtype: True or False
966
+ Arguments:
967
+
968
+ client_id: Unicode client identifier
969
+ scopes: List of scopes (defined by you)
970
+ client: Client object set by you, see authenticate_client.
971
+ request: The HTTP Request
913
972
 
914
973
  Method is used by all core grant types:
915
974
  - Authorization Code Grant
@@ -917,7 +976,7 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
917
976
  - Resource Owner Password Credentials Grant
918
977
  - Client Credentials Grant
919
978
  """
920
- del request, args, kwargs
979
+ del client, request, args, kwargs
921
980
 
922
981
  LOG.debug("validate_scopes %s %s", client_id, scopes)
923
982
 
@@ -925,8 +984,8 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
925
984
 
926
985
  def validate_user( # pylint: disable=no-self-use,useless-suppression
927
986
  self,
928
- username,
929
- password,
987
+ username: str,
988
+ password: str,
930
989
  client: "c2cgeoportal_commons.models.static.OAuth2Client", # noqa: F821
931
990
  request: oauthlib.common.Request,
932
991
  *args: Any,
@@ -940,11 +999,12 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
940
999
  not set you will be unable to associate a token with a user in the
941
1000
  persistence method used (commonly, save_bearer_token).
942
1001
 
943
- :param username: Unicode username
944
- :param password: Unicode password
945
- :param client: Client object set by you, see authenticate_client.
946
- :param request: The HTTP Request (oauthlib.common.Request)
947
- :rtype: True or False
1002
+ Arguments:
1003
+
1004
+ username: Unicode username
1005
+ password: Unicode password
1006
+ client: Client object set by you, see authenticate_client.
1007
+ request: The HTTP Request
948
1008
 
949
1009
  Method is used by:
950
1010
  - Resource Owner Password Credentials Grant
@@ -956,12 +1016,21 @@ class RequestValidator(oauthlib.oauth2.RequestValidator):
956
1016
  raise NotImplementedError("Not implemented.")
957
1017
 
958
1018
 
959
- @OBJECT_CACHE_REGION.cache_on_arguments()
960
- def get_oauth_client(settings):
1019
+ def get_oauth_client(settings: Dict[str, Any]) -> oauthlib.oauth2.WebApplicationServer:
1020
+ """Get the oauth2 client, with a cache."""
961
1021
  authentication_settings = settings.get("authentication", {})
1022
+ return _get_oauth_client_cache(
1023
+ authentication_settings.get("oauth2_authorization_expire_minutes", 10),
1024
+ authentication_settings.get("oauth2_token_expire_minutes", 60),
1025
+ )
1026
+
1027
+
1028
+ @OBJECT_CACHE_REGION.cache_on_arguments() # type: ignore
1029
+ def _get_oauth_client_cache(
1030
+ authorization_expire_minutes: int, token_expire_minutes: int
1031
+ ) -> oauthlib.oauth2.WebApplicationServer:
1032
+ """Get the oauth2 client, with a cache."""
962
1033
  return oauthlib.oauth2.WebApplicationServer(
963
- RequestValidator(
964
- authorization_expires_in=authentication_settings.get("oauth2_authorization_expire_minutes", 10)
965
- ),
966
- token_expires_in=authentication_settings.get("oauth2_token_expire_minutes", 60) * 60,
1034
+ RequestValidator(authorization_expires_in=authorization_expire_minutes),
1035
+ token_expires_in=token_expire_minutes * 60,
967
1036
  )