Commit Graph

13287 Commits

Author SHA1 Message Date
Ken Sternberg f0742ab313 web: do not parse the UUID
The UUID -> Number -> UUID transformation was lossy and incorrect.
This commit preserves the UUID as-is, but parses the inbound element
into a number if the API being called (i.e. anything but Mobile)
requires a number for its PK.
2023-12-22 13:52:05 -08:00
Ken Sternberg afdf269869 web: funnel an API down to a single module
**Summary:**

Calls to _retrieve_, _create_, and _update_ Authenticators have been isolated into a module
functions and code accessing those features have been revised to use those functions.

**This commit**

Isolates the Authenticators APIs for `authenticatorsAllList`, `authenticatorsAdminAllList`,
`authenticators<Type>Destroy` and `authenticators<Type>Update` into a connector module, and updates
client code to use them. This eliminates the duplication of `deleteAuthenticatorDevice`, the code
for which was in both *Admin* and *User*, and creates a single source of truth for the DeviceType
strings that identify Device subtypes.

**Details**

One thing that's bothered me a lot is the way our APIs, starting on the Django side, start with a
base model and then "spread out" to incorporate many different inheritance models: different kinds
of Providers, different kinds of Outposts, and different kinds of authentication devices.

In a proper object-oriented system, we'd be granted access to the base class and have the power to
use it effectively as a generic, switchboarding on some RTTI or value type to handle the differences
between the concrete child types. The code generator we use does not provide that base model to UI
clients; "funnelling down" to create a sort of artificial base class on the client and then fanning
back out is an impractical and error-prone exercise.

But we still do a lot of switchboarding, which has three problems:

- Adding subtypes touches a lot of different code
- Distant implementations can miss a specific instance of a subtype
- Repeated use of strings as type handles can introduce spelling errors
- The [last line effect](https://link.springer.com/article/10.1007/s10664-016-9489-6) can introduce
  new and subtle bugs when cut-and-pasting prior examples
- Instances of the *same code* in multiple locations make for maintenance headaches

This patch introduces the concept of **connectors**, modules that provide CRUD functions for common
operations performed on objects of a specific subtype. It is *not* meant to replace concrete class
displays or manipulations, such as (using providers as an example) `ProxyProviderViewPage` or HTML
that is customized for a specific concrete type of provider.

For retrieving lists, deleting instances that can be addressed from the base class, or updating
objects — any place where which call among a collection of isomorphic APIs must be specifieda using
`switch/case` statements — the connector provides a single source of truth for how to recognize the
child types, which `switch/case` statements provide the utility, and what must be done to update
them.
2023-12-22 13:33:23 -08:00
Jens Langhammer 47a1fc62b9
fix API
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-21 19:49:38 +01:00
Jens Langhammer 15e653c0c0
use main pypi
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:28:35 +01:00
Jens Langhammer e38aa6e401
don't log mobiledevicetoken
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:25 +01:00
Jens Langhammer ac6fc38488
use uuid for mobile token
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:25 +01:00
Jens Langhammer 91d025e7f2
fix mobile users/me auth
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:25 +01:00
Jens Langhammer 2c1d1c0075
fix web to support string for device uuid
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:25 +01:00
Jens Langhammer 82b9d337d4
add slight workaround
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:25 +01:00
Jens Langhammer 6bb180b144
handle grpc error
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:25 +01:00
Jens Langhammer 63ae6f4904
revert to old method of checking
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:25 +01:00
Jens Langhammer c5b93407b6
fix channel creation
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:25 +01:00
Jens Langhammer 6eb070ff4d
fix incorrect usage of ssl_channel_credentials
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:25 +01:00
Jens Langhammer 36bd3858e4
fix tests and lint
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:25 +01:00
Jens Langhammer 3ed2800883
bump client
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:25 +01:00
Jens Langhammer fe05ea6048
get enterprise token
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:16 +01:00
Jens Langhammer 0d45b36cf2
use + addressing for enterprise feedback emails
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:16 +01:00
Jens Langhammer 8c1d7b712e
add UI for hosted
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:15 +01:00
Jens Langhammer dfe7e8641e
switch to text field, add debug mode
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:10 +01:00
Jens Langhammer 245153c6de
migrate to cloud gateway
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:10 +01:00
Jens Langhammer 247b7a7c87
add UI to show code, add validation
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:20:04 +01:00
Jens Langhammer ac1e16675c
start re-writing validation for item matching
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:37 +01:00
Jens Langhammer 7599d48a25
re-gen migrations, implement one half of number matching
this also treats accept/deny as "number" matching (we call it item matching to make it more general), since it's just a more static version of selecting the correct thing

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:37 +01:00
Jens Langhammer 9180bb6328
include numbers for testing
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer fd22e1f08d
allow mobile device token to retrieve user info
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer ba4dd7f1d2
placeholder device_id
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer 76ac14cb5a
create app correctly
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer 7a70f7ccb4
fix enroll
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer 713f8d6a19
only consider non expired tokens
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer 94ffb224e3
generate device with random name as we need to create them in the database
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer bbfefc40d4
fix lint
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer 591f2b8c4e
move firebase config to db for testing
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer 51e4623214
lazy import firebase
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer 587a57a11e
fix user settings
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer 57bf4398f0
fix import
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer 64c48285d2
set auth_via when using mobile token
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer 268c5c7c6d
add logic for checkin
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer d7725ced6f
have schema in a more general place
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer ae290f87e9
add mobile only subset schema
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer 5e2ed504bf
implement more
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer 628b130122
set device name from hostname
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer cda379f4ba
add transaction states
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:36 +01:00
Jens Langhammer a84f76be4d
move sending code into mobiletransaction model
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:35 +01:00
Jens Langhammer 7515567882
start checkin
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:35 +01:00
Jens Langhammer b5723bcee2
fix more stuff
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:35 +01:00
Jens Langhammer aba225f223
fix web
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:35 +01:00
Jens Langhammer b1023fbc01
fix inheritance
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:35 +01:00
Jens Langhammer d905b1438f
update defaults
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:35 +01:00
Jens Langhammer 14ab9a9f1b
strings
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:35 +01:00
Jens Langhammer f4a18d1778
more fixes, start implementing validate
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-12-19 14:19:35 +01:00