ingot-auth 0.1.0__tar.gz

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 (242) hide show
  1. ingot_auth-0.1.0/LICENSE +201 -0
  2. ingot_auth-0.1.0/PKG-INFO +85 -0
  3. ingot_auth-0.1.0/README.md +56 -0
  4. ingot_auth-0.1.0/ingot_auth/__init__.py +10 -0
  5. ingot_auth-0.1.0/ingot_auth/__main__.py +46 -0
  6. ingot_auth-0.1.0/ingot_auth/access/__init__.py +29 -0
  7. ingot_auth-0.1.0/ingot_auth/access/groups/__init__.py +111 -0
  8. ingot_auth-0.1.0/ingot_auth/access/groups/commands.py +38 -0
  9. ingot_auth-0.1.0/ingot_auth/access/groups/entities.py +52 -0
  10. ingot_auth-0.1.0/ingot_auth/access/groups/errors.py +38 -0
  11. ingot_auth-0.1.0/ingot_auth/access/groups/items.py +15 -0
  12. ingot_auth-0.1.0/ingot_auth/access/groups/operations.py +30 -0
  13. ingot_auth-0.1.0/ingot_auth/access/groups/permissions.py +11 -0
  14. ingot_auth-0.1.0/ingot_auth/access/groups/v1/__init__.py +0 -0
  15. ingot_auth-0.1.0/ingot_auth/access/groups/v1/groups.proto +29 -0
  16. ingot_auth-0.1.0/ingot_auth/access/groups/v1/groups_pb2.py +48 -0
  17. ingot_auth-0.1.0/ingot_auth/access/groups/v1/groups_pb2.pyi +120 -0
  18. ingot_auth-0.1.0/ingot_auth/access/groups/v1/groups_pb2_grpc.py +101 -0
  19. ingot_auth-0.1.0/ingot_auth/access/groups/v1/groups_pb2_grpc.pyi +58 -0
  20. ingot_auth-0.1.0/ingot_auth/access/members/__init__.py +53 -0
  21. ingot_auth-0.1.0/ingot_auth/access/members/commands.py +122 -0
  22. ingot_auth-0.1.0/ingot_auth/access/members/operations.py +134 -0
  23. ingot_auth-0.1.0/ingot_auth/access/members/permissions.py +13 -0
  24. ingot_auth-0.1.0/ingot_auth/access/members/v1/__init__.py +0 -0
  25. ingot_auth-0.1.0/ingot_auth/access/members/v1/members.proto +58 -0
  26. ingot_auth-0.1.0/ingot_auth/access/members/v1/members_pb2.py +56 -0
  27. ingot_auth-0.1.0/ingot_auth/access/members/v1/members_pb2.pyi +214 -0
  28. ingot_auth-0.1.0/ingot_auth/access/members/v1/members_pb2_grpc.py +233 -0
  29. ingot_auth-0.1.0/ingot_auth/access/members/v1/members_pb2_grpc.pyi +94 -0
  30. ingot_auth-0.1.0/ingot_auth/access/strategies.py +36 -0
  31. ingot_auth-0.1.0/ingot_auth/auth/__init__.py +41 -0
  32. ingot_auth-0.1.0/ingot_auth/caches/__init__.py +37 -0
  33. ingot_auth-0.1.0/ingot_auth/caches/attempts.py +40 -0
  34. ingot_auth-0.1.0/ingot_auth/caches/callers.py +72 -0
  35. ingot_auth-0.1.0/ingot_auth/caches/errors.py +20 -0
  36. ingot_auth-0.1.0/ingot_auth/caches/items.py +46 -0
  37. ingot_auth-0.1.0/ingot_auth/caches/sessions.py +53 -0
  38. ingot_auth-0.1.0/ingot_auth/contrib/__init__.py +4 -0
  39. ingot_auth-0.1.0/ingot_auth/contrib/caches/__init__.py +4 -0
  40. ingot_auth-0.1.0/ingot_auth/contrib/caches/memory/__init__.py +28 -0
  41. ingot_auth-0.1.0/ingot_auth/contrib/caches/memory/attempts.py +40 -0
  42. ingot_auth-0.1.0/ingot_auth/contrib/caches/memory/callers.py +51 -0
  43. ingot_auth-0.1.0/ingot_auth/contrib/caches/memory/sessions.py +47 -0
  44. ingot_auth-0.1.0/ingot_auth/contrib/storages/__init__.py +4 -0
  45. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/__init__.py +84 -0
  46. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/access/__init__.py +15 -0
  47. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/access/members.py +36 -0
  48. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/profiles/__init__.py +55 -0
  49. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/profiles/attrs.py +11 -0
  50. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/profiles/identities.py +39 -0
  51. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/profiles/secrets.py +31 -0
  52. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/profiles/tags.py +11 -0
  53. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/registry.py +67 -0
  54. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/sessions/__init__.py +76 -0
  55. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/sessions/attrs.py +13 -0
  56. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/sessions/presets.py +59 -0
  57. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/sign_up/__init__.py +15 -0
  58. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/sign_up/records.py +37 -0
  59. ingot_auth-0.1.0/ingot_auth/contrib/storages/memory/state.py +32 -0
  60. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/__init__.py +104 -0
  61. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/access/__init__.py +15 -0
  62. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/access/members.py +63 -0
  63. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/collection.py +80 -0
  64. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/profiles/__init__.py +62 -0
  65. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/profiles/attrs.py +32 -0
  66. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/profiles/identities.py +59 -0
  67. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/profiles/secrets.py +38 -0
  68. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/profiles/tags.py +26 -0
  69. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/registry.py +102 -0
  70. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/sessions/__init__.py +113 -0
  71. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/sessions/attrs.py +42 -0
  72. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/sessions/presets.py +89 -0
  73. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/sign_up/__init__.py +15 -0
  74. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/sign_up/records.py +54 -0
  75. ingot_auth-0.1.0/ingot_auth/contrib/storages/mongodb/values.py +44 -0
  76. ingot_auth-0.1.0/ingot_auth/contrib/transports/__init__.py +1 -0
  77. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/__init__.py +79 -0
  78. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/access/__init__.py +30 -0
  79. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/access/groups.py +31 -0
  80. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/access/members.py +56 -0
  81. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/base.py +84 -0
  82. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/errors.py +232 -0
  83. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/metadata.py +114 -0
  84. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/methods/__init__.py +17 -0
  85. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/methods/nickname.py +78 -0
  86. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/profiles/__init__.py +28 -0
  87. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/profiles/attrs.py +87 -0
  88. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/profiles/tags.py +62 -0
  89. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/sessions/__init__.py +34 -0
  90. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/sessions/attrs.py +180 -0
  91. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/sessions/presets.py +113 -0
  92. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/sign_in.py +19 -0
  93. ingot_auth-0.1.0/ingot_auth/contrib/transports/grpcio/sign_up.py +15 -0
  94. ingot_auth-0.1.0/ingot_auth/logging/__init__.py +25 -0
  95. ingot_auth-0.1.0/ingot_auth/metadata/__init__.py +31 -0
  96. ingot_auth-0.1.0/ingot_auth/metadata/items.py +64 -0
  97. ingot_auth-0.1.0/ingot_auth/metadata/operations.py +73 -0
  98. ingot_auth-0.1.0/ingot_auth/metadata/permissions.py +11 -0
  99. ingot_auth-0.1.0/ingot_auth/metadata/v1/__init__.py +0 -0
  100. ingot_auth-0.1.0/ingot_auth/metadata/v1/metadata.proto +86 -0
  101. ingot_auth-0.1.0/ingot_auth/metadata/v1/metadata_pb2.py +60 -0
  102. ingot_auth-0.1.0/ingot_auth/metadata/v1/metadata_pb2.pyi +301 -0
  103. ingot_auth-0.1.0/ingot_auth/metadata/v1/metadata_pb2_grpc.py +107 -0
  104. ingot_auth-0.1.0/ingot_auth/metadata/v1/metadata_pb2_grpc.pyi +67 -0
  105. ingot_auth-0.1.0/ingot_auth/methods/__init__.py +104 -0
  106. ingot_auth-0.1.0/ingot_auth/methods/base.py +200 -0
  107. ingot_auth-0.1.0/ingot_auth/methods/email_code/__init__.py +172 -0
  108. ingot_auth-0.1.0/ingot_auth/methods/email_code/configs.py +16 -0
  109. ingot_auth-0.1.0/ingot_auth/methods/email_code/permissions.py +15 -0
  110. ingot_auth-0.1.0/ingot_auth/methods/email_code/policies.py +28 -0
  111. ingot_auth-0.1.0/ingot_auth/methods/errors.py +96 -0
  112. ingot_auth-0.1.0/ingot_auth/methods/nickname/__init__.py +124 -0
  113. ingot_auth-0.1.0/ingot_auth/methods/nickname/configs.py +16 -0
  114. ingot_auth-0.1.0/ingot_auth/methods/nickname/permissions.py +15 -0
  115. ingot_auth-0.1.0/ingot_auth/methods/nickname/policies.py +30 -0
  116. ingot_auth-0.1.0/ingot_auth/methods/nickname/v1/__init__.py +0 -0
  117. ingot_auth-0.1.0/ingot_auth/methods/nickname/v1/nickname.proto +45 -0
  118. ingot_auth-0.1.0/ingot_auth/methods/nickname/v1/nickname_pb2.py +49 -0
  119. ingot_auth-0.1.0/ingot_auth/methods/nickname/v1/nickname_pb2.pyi +136 -0
  120. ingot_auth-0.1.0/ingot_auth/methods/nickname/v1/nickname_pb2_grpc.py +148 -0
  121. ingot_auth-0.1.0/ingot_auth/methods/nickname/v1/nickname_pb2_grpc.pyi +76 -0
  122. ingot_auth-0.1.0/ingot_auth/methods/operations.py +185 -0
  123. ingot_auth-0.1.0/ingot_auth/methods/password/__init__.py +102 -0
  124. ingot_auth-0.1.0/ingot_auth/methods/password/policies.py +41 -0
  125. ingot_auth-0.1.0/ingot_auth/methods/password/scrypt.py +61 -0
  126. ingot_auth-0.1.0/ingot_auth/methods/steps.py +33 -0
  127. ingot_auth-0.1.0/ingot_auth/policies/__init__.py +32 -0
  128. ingot_auth-0.1.0/ingot_auth/policies/chars.py +78 -0
  129. ingot_auth-0.1.0/ingot_auth/policies/errors.py +24 -0
  130. ingot_auth-0.1.0/ingot_auth/policies/length.py +36 -0
  131. ingot_auth-0.1.0/ingot_auth/policies/parameters.py +16 -0
  132. ingot_auth-0.1.0/ingot_auth/profiles/__init__.py +23 -0
  133. ingot_auth-0.1.0/ingot_auth/profiles/attrs/__init__.py +44 -0
  134. ingot_auth-0.1.0/ingot_auth/profiles/attrs/commands.py +112 -0
  135. ingot_auth-0.1.0/ingot_auth/profiles/attrs/operations.py +68 -0
  136. ingot_auth-0.1.0/ingot_auth/profiles/attrs/permissions.py +14 -0
  137. ingot_auth-0.1.0/ingot_auth/profiles/attrs/v1/__init__.py +0 -0
  138. ingot_auth-0.1.0/ingot_auth/profiles/attrs/v1/attrs.proto +69 -0
  139. ingot_auth-0.1.0/ingot_auth/profiles/attrs/v1/attrs_pb2.py +58 -0
  140. ingot_auth-0.1.0/ingot_auth/profiles/attrs/v1/attrs_pb2.pyi +243 -0
  141. ingot_auth-0.1.0/ingot_auth/profiles/attrs/v1/attrs_pb2_grpc.py +233 -0
  142. ingot_auth-0.1.0/ingot_auth/profiles/attrs/v1/attrs_pb2_grpc.pyi +94 -0
  143. ingot_auth-0.1.0/ingot_auth/profiles/tags/__init__.py +44 -0
  144. ingot_auth-0.1.0/ingot_auth/profiles/tags/commands.py +72 -0
  145. ingot_auth-0.1.0/ingot_auth/profiles/tags/operations.py +68 -0
  146. ingot_auth-0.1.0/ingot_auth/profiles/tags/permissions.py +14 -0
  147. ingot_auth-0.1.0/ingot_auth/profiles/tags/v1/__init__.py +0 -0
  148. ingot_auth-0.1.0/ingot_auth/profiles/tags/v1/tags.proto +59 -0
  149. ingot_auth-0.1.0/ingot_auth/profiles/tags/v1/tags_pb2.py +56 -0
  150. ingot_auth-0.1.0/ingot_auth/profiles/tags/v1/tags_pb2.pyi +217 -0
  151. ingot_auth-0.1.0/ingot_auth/profiles/tags/v1/tags_pb2_grpc.py +233 -0
  152. ingot_auth-0.1.0/ingot_auth/profiles/tags/v1/tags_pb2_grpc.pyi +94 -0
  153. ingot_auth-0.1.0/ingot_auth/project.py +24 -0
  154. ingot_auth-0.1.0/ingot_auth/py.typed +0 -0
  155. ingot_auth-0.1.0/ingot_auth/registry/__init__.py +12 -0
  156. ingot_auth-0.1.0/ingot_auth/registry/commands.py +141 -0
  157. ingot_auth-0.1.0/ingot_auth/registry/errors.py +51 -0
  158. ingot_auth-0.1.0/ingot_auth/registry/operations.py +111 -0
  159. ingot_auth-0.1.0/ingot_auth/sessions/__init__.py +164 -0
  160. ingot_auth-0.1.0/ingot_auth/sessions/attrs/__init__.py +49 -0
  161. ingot_auth-0.1.0/ingot_auth/sessions/attrs/commands.py +128 -0
  162. ingot_auth-0.1.0/ingot_auth/sessions/attrs/operations.py +69 -0
  163. ingot_auth-0.1.0/ingot_auth/sessions/attrs/permissions.py +14 -0
  164. ingot_auth-0.1.0/ingot_auth/sessions/attrs/v1/__init__.py +0 -0
  165. ingot_auth-0.1.0/ingot_auth/sessions/attrs/v1/attrs.proto +97 -0
  166. ingot_auth-0.1.0/ingot_auth/sessions/attrs/v1/attrs_pb2.py +63 -0
  167. ingot_auth-0.1.0/ingot_auth/sessions/attrs/v1/attrs_pb2.pyi +314 -0
  168. ingot_auth-0.1.0/ingot_auth/sessions/attrs/v1/attrs_pb2_grpc.py +233 -0
  169. ingot_auth-0.1.0/ingot_auth/sessions/attrs/v1/attrs_pb2_grpc.pyi +94 -0
  170. ingot_auth-0.1.0/ingot_auth/sessions/attrs/values.py +43 -0
  171. ingot_auth-0.1.0/ingot_auth/sessions/errors.py +22 -0
  172. ingot_auth-0.1.0/ingot_auth/sessions/items.py +16 -0
  173. ingot_auth-0.1.0/ingot_auth/sessions/lifetimes.py +53 -0
  174. ingot_auth-0.1.0/ingot_auth/sessions/presets/__init__.py +61 -0
  175. ingot_auth-0.1.0/ingot_auth/sessions/presets/commands.py +184 -0
  176. ingot_auth-0.1.0/ingot_auth/sessions/presets/operations.py +146 -0
  177. ingot_auth-0.1.0/ingot_auth/sessions/presets/permissions.py +16 -0
  178. ingot_auth-0.1.0/ingot_auth/sessions/presets/v1/__init__.py +0 -0
  179. ingot_auth-0.1.0/ingot_auth/sessions/presets/v1/presets.proto +96 -0
  180. ingot_auth-0.1.0/ingot_auth/sessions/presets/v1/presets_pb2.py +70 -0
  181. ingot_auth-0.1.0/ingot_auth/sessions/presets/v1/presets_pb2.pyi +360 -0
  182. ingot_auth-0.1.0/ingot_auth/sessions/presets/v1/presets_pb2_grpc.py +368 -0
  183. ingot_auth-0.1.0/ingot_auth/sessions/presets/v1/presets_pb2_grpc.pyi +136 -0
  184. ingot_auth-0.1.0/ingot_auth/settings/__init__.py +14 -0
  185. ingot_auth-0.1.0/ingot_auth/settings/configs.py +23 -0
  186. ingot_auth-0.1.0/ingot_auth/sign_in/__init__.py +49 -0
  187. ingot_auth-0.1.0/ingot_auth/sign_in/items.py +59 -0
  188. ingot_auth-0.1.0/ingot_auth/sign_in/operations.py +149 -0
  189. ingot_auth-0.1.0/ingot_auth/sign_in/permissions.py +14 -0
  190. ingot_auth-0.1.0/ingot_auth/sign_in/timings.py +74 -0
  191. ingot_auth-0.1.0/ingot_auth/sign_in/v1/__init__.py +0 -0
  192. ingot_auth-0.1.0/ingot_auth/sign_in/v1/sign_in.proto +27 -0
  193. ingot_auth-0.1.0/ingot_auth/sign_in/v1/sign_in_pb2.py +40 -0
  194. ingot_auth-0.1.0/ingot_auth/sign_in/v1/sign_in_pb2.pyi +90 -0
  195. ingot_auth-0.1.0/ingot_auth/sign_in/v1/sign_in_pb2_grpc.py +24 -0
  196. ingot_auth-0.1.0/ingot_auth/sign_in/v1/sign_in_pb2_grpc.pyi +20 -0
  197. ingot_auth-0.1.0/ingot_auth/sign_up/__init__.py +36 -0
  198. ingot_auth-0.1.0/ingot_auth/sign_up/items.py +54 -0
  199. ingot_auth-0.1.0/ingot_auth/sign_up/operations.py +148 -0
  200. ingot_auth-0.1.0/ingot_auth/sign_up/permissions.py +14 -0
  201. ingot_auth-0.1.0/ingot_auth/sign_up/v1/__init__.py +0 -0
  202. ingot_auth-0.1.0/ingot_auth/sign_up/v1/sign_up.proto +25 -0
  203. ingot_auth-0.1.0/ingot_auth/sign_up/v1/sign_up_pb2.py +40 -0
  204. ingot_auth-0.1.0/ingot_auth/sign_up/v1/sign_up_pb2.pyi +85 -0
  205. ingot_auth-0.1.0/ingot_auth/sign_up/v1/sign_up_pb2_grpc.py +24 -0
  206. ingot_auth-0.1.0/ingot_auth/sign_up/v1/sign_up_pb2_grpc.pyi +20 -0
  207. ingot_auth-0.1.0/ingot_auth/storages/__init__.py +222 -0
  208. ingot_auth-0.1.0/ingot_auth/storages/access/__init__.py +19 -0
  209. ingot_auth-0.1.0/ingot_auth/storages/access/items.py +16 -0
  210. ingot_auth-0.1.0/ingot_auth/storages/access/members.py +53 -0
  211. ingot_auth-0.1.0/ingot_auth/storages/errors.py +80 -0
  212. ingot_auth-0.1.0/ingot_auth/storages/items.py +47 -0
  213. ingot_auth-0.1.0/ingot_auth/storages/profiles/__init__.py +81 -0
  214. ingot_auth-0.1.0/ingot_auth/storages/profiles/attrs.py +14 -0
  215. ingot_auth-0.1.0/ingot_auth/storages/profiles/errors.py +88 -0
  216. ingot_auth-0.1.0/ingot_auth/storages/profiles/identities.py +45 -0
  217. ingot_auth-0.1.0/ingot_auth/storages/profiles/items.py +49 -0
  218. ingot_auth-0.1.0/ingot_auth/storages/profiles/secrets.py +42 -0
  219. ingot_auth-0.1.0/ingot_auth/storages/profiles/tags.py +14 -0
  220. ingot_auth-0.1.0/ingot_auth/storages/registry.py +72 -0
  221. ingot_auth-0.1.0/ingot_auth/storages/sessions/__init__.py +100 -0
  222. ingot_auth-0.1.0/ingot_auth/storages/sessions/attrs.py +14 -0
  223. ingot_auth-0.1.0/ingot_auth/storages/sessions/errors.py +28 -0
  224. ingot_auth-0.1.0/ingot_auth/storages/sessions/items.py +102 -0
  225. ingot_auth-0.1.0/ingot_auth/storages/sessions/presets.py +57 -0
  226. ingot_auth-0.1.0/ingot_auth/storages/sign_up/__init__.py +22 -0
  227. ingot_auth-0.1.0/ingot_auth/storages/sign_up/errors.py +21 -0
  228. ingot_auth-0.1.0/ingot_auth/storages/sign_up/items.py +26 -0
  229. ingot_auth-0.1.0/ingot_auth/storages/sign_up/records.py +36 -0
  230. ingot_auth-0.1.0/ingot_auth/testing/__init__.py +1 -0
  231. ingot_auth-0.1.0/ingot_auth/testing/contracts/__init__.py +49 -0
  232. ingot_auth-0.1.0/ingot_auth/testing/contracts/access.py +50 -0
  233. ingot_auth-0.1.0/ingot_auth/testing/contracts/base.py +31 -0
  234. ingot_auth-0.1.0/ingot_auth/testing/contracts/cache.py +154 -0
  235. ingot_auth-0.1.0/ingot_auth/testing/contracts/profiles.py +112 -0
  236. ingot_auth-0.1.0/ingot_auth/testing/contracts/sessions.py +83 -0
  237. ingot_auth-0.1.0/ingot_auth/testing/contracts/sign_up.py +36 -0
  238. ingot_auth-0.1.0/ingot_auth/testing/contracts/storage.py +355 -0
  239. ingot_auth-0.1.0/ingot_auth/testing/contracts/transactions.py +105 -0
  240. ingot_auth-0.1.0/ingot_auth/testing/methods.py +104 -0
  241. ingot_auth-0.1.0/pyproject.toml +200 -0
  242. ingot_auth-0.1.0/pyproject.toml.orig +170 -0
@@ -0,0 +1,201 @@
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.
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.4
2
+ Name: ingot-auth
3
+ Version: 0.1.0
4
+ Summary: Sign-up, sign-in and sessions of the users of Ingots applications.
5
+ Keywords: ingots,auth,authentication,sign-in,sign-up
6
+ Author: Aliaksandr Karotki
7
+ Author-email: Aliaksandr Karotki <abkarotki@gmail.com>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: MacOS
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
18
+ Classifier: Typing :: Typed
19
+ Requires-Dist: ingots>=0.33.1,<0.34
20
+ Requires-Dist: ingot-grpcio>=0.12.0,<0.13 ; extra == 'grpcio'
21
+ Requires-Dist: ingot-pymongo>=0.13.0,<0.14 ; extra == 'pymongo'
22
+ Requires-Python: >=3.14
23
+ Project-URL: repository, https://github.com/ak-ingots/ingot-auth
24
+ Project-URL: changelog, https://github.com/ak-ingots/ingot-auth/blob/main/CHANGELOG.md
25
+ Project-URL: documentation, https://ingots.readthedocs.io/projects/ingot-auth/
26
+ Provides-Extra: grpcio
27
+ Provides-Extra: pymongo
28
+ Description-Content-Type: text/markdown
29
+
30
+ # ingot-auth
31
+
32
+ [![ci](https://github.com/ak-ingots/ingot-auth/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ak-ingots/ingot-auth/actions/workflows/ci.yml)
33
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/ak-ingots/ingot-auth/blob/main/LICENSE)
34
+ [![Documentation Status](https://app.readthedocs.org/projects/ingot-auth/badge/?version=latest)](https://ingots.readthedocs.io/projects/ingot-auth/en/latest/)
35
+
36
+ <!-- Links must be absolute: this README also renders on PyPI. -->
37
+
38
+ The sign-up, the sign-in and the sessions of the users of Ingots
39
+ applications. An addon of [Ingots](https://github.com/ak-ingots/ingots).
40
+
41
+ **Status:** pre-alpha: the registries of the tags and the attributes of the
42
+ profiles and of the attributes and the presets of the sessions, with their
43
+ metadata for the consumers, all of it over gRPC; the sign-up and the
44
+ sign-in by pluggable methods in steps, a nickname and a password, over gRPC
45
+ too, and an email and a code sent to it; the policies of what a user types,
46
+ operations run together in groups; the groups of the users, declared in the
47
+ code, and their members, on the command line and over gRPC; the sessions a
48
+ sign-in opens, a token turned into a caller; all of it stored in memory or
49
+ in MongoDB.
50
+
51
+ ## For Consumers
52
+
53
+ ```sh
54
+ uv add ingot-auth
55
+ ```
56
+
57
+ The [documentation](https://ingots.readthedocs.io/projects/ingot-auth/en/latest/)
58
+ has the guide, the contrib, the caches, the storages and the transports an
59
+ application plugs in, and the Python API.
60
+
61
+ ## Development
62
+
63
+ Requires [uv](https://docs.astral.sh/uv/) and `make`; uv fetches the
64
+ interpreters it needs. `make lint` lints the gRPC contract by
65
+ [Buf](https://buf.build/docs/cli/), of the version the ecosystem pins in
66
+ [ingots-libs](https://github.com/ak-ingots/ingots-libs/blob/main/.github/actions/setup-buf/version):
67
+ cloned inside ingots-libs, as `make clone` there does, it takes that one,
68
+ fetched on the first use; alone, install that version on the `PATH`, or give
69
+ its path as `BUF`.
70
+
71
+ ```sh
72
+ make # the target list
73
+ make check # everything CI runs: lint, test, coverage, wheel-test, doc, cl-check
74
+ make format # black
75
+ make doc-serve # build the documentation and serve it
76
+ make all # build the sdist and the wheel into dist/
77
+ ```
78
+
79
+ - Every change users should know about adds a news fragment to `changelog.d/`
80
+ (see [its README](https://github.com/ak-ingots/ingot-auth/blob/main/changelog.d/README.md)).
81
+ - A release is a pull request setting the version (`uv version X.Y.Z`) and
82
+ collating the changelog (`make cl-build VERSION=X.Y.Z`), then the tag
83
+ `vX.Y.Z` on `main`: the `release` workflow publishes the tested build to
84
+ TestPyPI, tests it as installed from there, then
85
+ publishes it to PyPI. Run by hand, it rehearses on TestPyPI only.
@@ -0,0 +1,56 @@
1
+ # ingot-auth
2
+
3
+ [![ci](https://github.com/ak-ingots/ingot-auth/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ak-ingots/ingot-auth/actions/workflows/ci.yml)
4
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/ak-ingots/ingot-auth/blob/main/LICENSE)
5
+ [![Documentation Status](https://app.readthedocs.org/projects/ingot-auth/badge/?version=latest)](https://ingots.readthedocs.io/projects/ingot-auth/en/latest/)
6
+
7
+ <!-- Links must be absolute: this README also renders on PyPI. -->
8
+
9
+ The sign-up, the sign-in and the sessions of the users of Ingots
10
+ applications. An addon of [Ingots](https://github.com/ak-ingots/ingots).
11
+
12
+ **Status:** pre-alpha: the registries of the tags and the attributes of the
13
+ profiles and of the attributes and the presets of the sessions, with their
14
+ metadata for the consumers, all of it over gRPC; the sign-up and the
15
+ sign-in by pluggable methods in steps, a nickname and a password, over gRPC
16
+ too, and an email and a code sent to it; the policies of what a user types,
17
+ operations run together in groups; the groups of the users, declared in the
18
+ code, and their members, on the command line and over gRPC; the sessions a
19
+ sign-in opens, a token turned into a caller; all of it stored in memory or
20
+ in MongoDB.
21
+
22
+ ## For Consumers
23
+
24
+ ```sh
25
+ uv add ingot-auth
26
+ ```
27
+
28
+ The [documentation](https://ingots.readthedocs.io/projects/ingot-auth/en/latest/)
29
+ has the guide, the contrib, the caches, the storages and the transports an
30
+ application plugs in, and the Python API.
31
+
32
+ ## Development
33
+
34
+ Requires [uv](https://docs.astral.sh/uv/) and `make`; uv fetches the
35
+ interpreters it needs. `make lint` lints the gRPC contract by
36
+ [Buf](https://buf.build/docs/cli/), of the version the ecosystem pins in
37
+ [ingots-libs](https://github.com/ak-ingots/ingots-libs/blob/main/.github/actions/setup-buf/version):
38
+ cloned inside ingots-libs, as `make clone` there does, it takes that one,
39
+ fetched on the first use; alone, install that version on the `PATH`, or give
40
+ its path as `BUF`.
41
+
42
+ ```sh
43
+ make # the target list
44
+ make check # everything CI runs: lint, test, coverage, wheel-test, doc, cl-check
45
+ make format # black
46
+ make doc-serve # build the documentation and serve it
47
+ make all # build the sdist and the wheel into dist/
48
+ ```
49
+
50
+ - Every change users should know about adds a news fragment to `changelog.d/`
51
+ (see [its README](https://github.com/ak-ingots/ingot-auth/blob/main/changelog.d/README.md)).
52
+ - A release is a pull request setting the version (`uv version X.Y.Z`) and
53
+ collating the changelog (`make cl-build VERSION=X.Y.Z`), then the tag
54
+ `vX.Y.Z` on `main`: the `release` workflow publishes the tested build to
55
+ TestPyPI, tests it as installed from there, then
56
+ publishes it to PyPI. Run by hand, it rehearses on TestPyPI only.
@@ -0,0 +1,10 @@
1
+ """
2
+ ingot-auth: the sign-up, the sign-in and the sessions of the users of Ingots
3
+ applications. An application inherits from :class:`AuthProject`, or joins
4
+ the units of the addon, ``settings``, ``logging`` and ``auth``, with those of
5
+ its other addons.
6
+ """
7
+
8
+ __all__ = ("AuthProject",)
9
+
10
+ from .project import AuthProject
@@ -0,0 +1,46 @@
1
+ """
2
+ Runs the addon on its own: ``python -m ingot_auth logging info``. The
3
+ storage and the cache are in memory, so what a command stores is gone with
4
+ it.
5
+ """
6
+
7
+ import sys
8
+
9
+ from ingots.defaults.logging import configure_startup_logging
10
+ from ingots.puer import Slot
11
+ from ingots.puer.cli import CommandRunner
12
+
13
+ from .auth import AuthUnit
14
+ from .contrib.caches.memory import AuthMemoryCache
15
+ from .contrib.storages.memory import AuthMemoryStorage
16
+ from .project import AuthProject
17
+ from .sessions import AuthFixedLifetime, AuthSessionsUnit
18
+ from .sign_in import AuthNoTiming, AuthSignInUnit
19
+
20
+
21
+ class AuthMemorySessionsUnit(AuthSessionsUnit):
22
+ lifetime = Slot(AuthFixedLifetime)
23
+
24
+
25
+ class AuthMemorySignInUnit(AuthSignInUnit):
26
+ timing = Slot(AuthNoTiming)
27
+
28
+
29
+ class AuthMemoryUnit(AuthUnit):
30
+ storage = Slot(AuthMemoryStorage)
31
+ cache = Slot(AuthMemoryCache)
32
+ sessions = Slot(AuthMemorySessionsUnit)
33
+ sign_in = Slot(AuthMemorySignInUnit)
34
+
35
+
36
+ class AuthMemoryProject(AuthProject):
37
+ auth = Slot(AuthMemoryUnit)
38
+
39
+
40
+ def main() -> None:
41
+ configure_startup_logging()
42
+ sys.exit(CommandRunner(AuthMemoryProject).run())
43
+
44
+
45
+ if __name__ == "__main__":
46
+ main()
@@ -0,0 +1,29 @@
1
+ """
2
+ The access: the groups of the users, what each grants, and the members of
3
+ each. The permissions of a signed-in user are the union of what its groups
4
+ grant, by the strategy of the slot ``permissions``. An application declares
5
+ its groups in its own :class:`AuthGroupsUnit`::
6
+
7
+ class AppAccessUnit(AuthAccessUnit):
8
+ groups = Slot(AppGroupsUnit)
9
+ """
10
+
11
+ __all__ = ("AuthAccessUnit", "AuthGroupsGrants")
12
+
13
+ from ingots.puer import Slot
14
+ from ingots.puer.cli import CliUnit
15
+
16
+ from .groups import AuthGroupsUnit
17
+ from .members import AuthMembersUnit
18
+ from .strategies import AuthGroupsGrants
19
+
20
+
21
+ class AuthAccessUnit(CliUnit):
22
+ """The access: the groups, their members and the permissions of a user."""
23
+
24
+ cli_name = "access"
25
+ cli_description = "The groups of the users and their members."
26
+
27
+ groups = Slot(AuthGroupsUnit)
28
+ members = Slot(AuthMembersUnit)
29
+ permissions = Slot(AuthGroupsGrants)
@@ -0,0 +1,111 @@
1
+ """
2
+ The groups of the users, each granting permissions. The code is their
3
+ source, the first: an application declares them as slots of
4
+ :class:`AuthGroupsUnit`, the name of the slot the name of the group::
5
+
6
+ class AppGroupsUnit(AuthGroupsUnit):
7
+ admins = Slot(AdminsGroup)
8
+
9
+ The core declares one, ``signed_in``, :class:`AuthSignedInGroup`, of every
10
+ signed-in user.
11
+ """
12
+
13
+ __all__ = (
14
+ "AuthGroup",
15
+ "AuthGroupError",
16
+ "AuthGroupInfo",
17
+ "AuthGroupNotFoundError",
18
+ "AuthGroupsUnit",
19
+ "AuthGroupsPermissions",
20
+ "AuthListGroupsOperation",
21
+ "AuthListGroupsCommand",
22
+ "AuthSignedInGroup",
23
+ )
24
+
25
+ import hashlib
26
+ import json
27
+ import re
28
+ import typing as t
29
+
30
+ from ingots.puer import Factory, Slot
31
+ from ingots.puer.cli import CliUnit
32
+
33
+ from .commands import AuthListGroupsCommand
34
+ from .entities import AuthGroup, AuthSignedInGroup
35
+ from .errors import AuthGroupError, AuthGroupNotFoundError
36
+ from .items import AuthGroupInfo
37
+ from .operations import AuthListGroupsOperation
38
+ from .permissions import AuthGroupsPermissions
39
+
40
+ # a name is of the scripts and the memberships, for good
41
+ NAME_PATTERN: t.Final = re.compile(r"[a-z][a-z0-9_]*")
42
+
43
+
44
+ class AuthGroupsUnit(CliUnit):
45
+ """
46
+ The groups, ``signed_in`` here, of every signed-in user: whatever their
47
+ source, they come by :meth:`get` and :meth:`get_all`. A name of a group
48
+ is lowercase letters, digits and ``_``, checked when the class is
49
+ created.
50
+ """
51
+
52
+ cli_name = "groups"
53
+ cli_description = "The groups of the users."
54
+
55
+ op_list = Factory(AuthListGroupsOperation)
56
+
57
+ cmd_list = Slot(AuthListGroupsCommand)
58
+
59
+ signed_in = Slot(AuthSignedInGroup)
60
+
61
+ _digest: str
62
+
63
+ @t.override
64
+ @classmethod
65
+ def __init_subclass__(cls, **kwargs: t.Any) -> None:
66
+ super().__init_subclass__(**kwargs)
67
+ for name, _ in cls.slots_iter(AuthGroup):
68
+ if NAME_PATTERN.fullmatch(name) is None:
69
+ raise TypeError(
70
+ f"{cls.__qualname__}.{name}: a name of a group is lowercase "
71
+ f"letters, digits and '_'"
72
+ )
73
+
74
+ @t.final
75
+ def get_all(self) -> tuple[AuthGroup, ...]:
76
+ """The groups, in the order of their slots."""
77
+ return tuple(
78
+ self.slots_find_entity(name, AuthGroup)
79
+ for name, _ in type(self).slots_iter(AuthGroup)
80
+ )
81
+
82
+ @t.final
83
+ def get(self, name: str) -> AuthGroup:
84
+ """
85
+ The group of a name.
86
+
87
+ :raises AuthGroupNotFoundError: no group has the name.
88
+ """
89
+ try:
90
+ return self.slots_find_entity(name, AuthGroup)
91
+ except LookupError:
92
+ raise AuthGroupNotFoundError.for_name(name) from None
93
+
94
+ @t.final
95
+ def get_digest(self) -> str:
96
+ """
97
+ A digest of the groups and what each grants, computed once, as they
98
+ change with a deploy only: the key of a caller in the cache holds it,
99
+ so that a deploy changing them finds none of the callers formed
100
+ before.
101
+ """
102
+ try:
103
+ return self._digest
104
+ except AttributeError:
105
+ pass
106
+ grants = sorted(
107
+ (group.get_name(), sorted(group.get_permissions().items()))
108
+ for group in self.get_all()
109
+ )
110
+ self._digest = hashlib.sha256(json.dumps(grants).encode()).hexdigest()
111
+ return self._digest
@@ -0,0 +1,38 @@
1
+ """The commands of the groups."""
2
+
3
+ __all__ = ("AuthListGroupsCommand",)
4
+
5
+ import typing as t
6
+
7
+ from ingots.defaults.operations import BaseOperationCommand
8
+
9
+ from .items import AuthGroupInfo
10
+ from .operations import AuthListGroupsOperation
11
+
12
+ if t.TYPE_CHECKING:
13
+ from ingots.puer import BoundFactory
14
+
15
+ from ingot_auth.project import AuthProject
16
+
17
+
18
+ class AuthListGroupsCommand(BaseOperationCommand[None, tuple[AuthGroupInfo, ...]]):
19
+ """
20
+ Prints the groups, one a line: the name, then what it grants, a mask a
21
+ domain, sorted by the domain: ``auth.access.members=3``.
22
+ """
23
+
24
+ project: "AuthProject"
25
+
26
+ cli_name = "list"
27
+ cli_description = "Prints the groups and what each grants."
28
+
29
+ @t.override
30
+ def _get_operation(self) -> "BoundFactory[AuthListGroupsOperation]":
31
+ return self.project.auth.access.groups.op_list
32
+
33
+ @t.override
34
+ async def _run(self) -> None:
35
+ for group in await self.run_operation(None):
36
+ permissions = sorted(group.permissions.items())
37
+ masks = (f"{domain}={mask}" for domain, mask in permissions)
38
+ print("\t".join((group.name, *masks)))
@@ -0,0 +1,52 @@
1
+ """The groups: what each grants, declared in the code."""
2
+
3
+ __all__ = ("AuthGroup", "AuthSignedInGroup")
4
+
5
+ import typing as t
6
+
7
+ from ingots.defaults.operations import Permissions
8
+ from ingots.puer import Entity
9
+
10
+ if t.TYPE_CHECKING:
11
+ from ingot_auth.project import AuthProject
12
+
13
+
14
+ class AuthGroup(Entity):
15
+ """
16
+ A group of the users, a slot of :class:`AuthGroupsUnit`, its name the name
17
+ of the slot. What it grants is of its hook, :meth:`_get_permissions`,
18
+ nothing here: each class adds its own to ``super()``, so that an addon
19
+ and the application grant to the same group, the application declaring
20
+ the class that joins them.
21
+ """
22
+
23
+ project: "AuthProject"
24
+
25
+ @t.final
26
+ def get_name(self) -> str:
27
+ """The name of the group: the path of its slot in the groups."""
28
+ return self.project.auth.access.groups.slots_find_path(self)
29
+
30
+ @t.final
31
+ def get_permissions(self) -> Permissions:
32
+ """What the group grants: the union of the hooks of its classes."""
33
+ return self._get_permissions()
34
+
35
+ def _get_permissions(self) -> Permissions:
36
+ """What the class grants, with ``super()``: nothing here."""
37
+ return Permissions()
38
+
39
+
40
+ class AuthSignedInGroup(AuthGroup):
41
+ """
42
+ The group ``signed_in`` of the core: every signed-in user is a member,
43
+ none stored. It grants what the methods give a signed-in user by their
44
+ toggles, the ``CAN_SIGN_IN`` of each method open; what an application
45
+ and its addons grant every signed-in user, they add by the hook, the
46
+ application declaring the class that joins them in the slot.
47
+ """
48
+
49
+ @t.override
50
+ def _get_permissions(self) -> Permissions:
51
+ methods = self.project.auth.methods
52
+ return super()._get_permissions() | methods.get_signed_in_permissions()
@@ -0,0 +1,38 @@
1
+ """The errors of the groups."""
2
+
3
+ __all__ = ("AuthGroupError", "AuthGroupNotFoundError")
4
+
5
+ import typing as t
6
+
7
+
8
+ class AuthGroupError(Exception):
9
+ """
10
+ An error of a group. ``args`` are the message and the name of the
11
+ group, so the error survives pickling; create it with the class methods
12
+ of its subclasses.
13
+ """
14
+
15
+ @property
16
+ def name(self) -> str:
17
+ return t.cast(str, self.args[1])
18
+
19
+ @t.override
20
+ def __str__(self) -> str:
21
+ return str(self.args[0])
22
+
23
+
24
+ class AuthGroupNotFoundError(AuthGroupError):
25
+ """No group has the name, or the group keeps no members to tell of."""
26
+
27
+ @classmethod
28
+ def for_name(cls, name: str) -> t.Self:
29
+ """No source of the groups has one of the name."""
30
+ return cls(f"no group {name!r}", name)
31
+
32
+ @classmethod
33
+ def for_members(cls, name: str) -> t.Self:
34
+ """
35
+ The group keeps no members: every signed-in user is one, none is
36
+ added, removed or listed.
37
+ """
38
+ return cls(f"the group {name!r} has every signed-in user", name)