Repository navigation
Let the collector be the OpenID Connect provider of the om3 clusters - #194
Merged
Merged
Conversation
The services status update used to insert again, with its status columns only, a service deleted while a daemon status job held it. The feed of its cluster then failed at each run: dbCreateServices objectCreate aaa/svc/bbb: sql: Scan error on column index 0, name "svcname": converting NULL to string is unsupported 876fbc9 stopped those inserts and repairs such rows on the fly. The rows left go: the next daemon status of a service still there creates it again with the same svc_id, from service_ids. The column then refuses a row without a name.
An om3 cluster can take the collector as the issuer of the tokens of its
webapp and CLI users: each cluster is a client, its client_id being the
cluster id, so a token is only valid for the cluster it was asked for.
The protocol is served under /api/oidc, public: discovery, jwks,
authorize, token (authorization code with PKCE S256 only, refresh
tokens rotated, a reused one revokes its family), userinfo, revoke. The
redirect URIs accepted are the https callback paths of the node names,
fqdn and routable IPs of the cluster, and of the hosts allowed by
server.oidc_provider.redirect_hosts, plus the http loopback of the CLI.
/api/oidc/authorize keeps the request in redis and sends the browser to
the SPA, which approves it for the signed-in user (or asks when prompt
is consent or no grant applies) through /oidc_provider/requests/{id}.
An impersonated session cannot approve.
The om3 grants of the token come from the oidc_provider_grants table:
a team, a cluster or all of them, and the grants given. The Manager
administers them through /oidc_provider/grants; migration 0038 seeds
root on all clusters for the Manager team.
Configuration: server.oidc_provider.{enable, issuer, ui_url,
signing_key_files (RSA or EC PEM, kid from the key thumbprint),
access_token_ttl, refresh_token.{idle_timeout, max_lifetime},
redirect_hosts}.
Without InterpolateParams every query with arguments costs a server side Prepare and Close round trip, about 15% of the DB time of the agent-sim 1000 nodes run.
The daemon ping rewrote every svcmon, svcmon_log_last, resmon and resmon_log_last row of the nodes of the cluster on each ping, the 30s guard being shorter than the 60s ping interval: about 25% of the DB time of the agent-sim 1000 nodes run, growing with the resources. The ping now only updates nodes.last_comm, as it already did. The time an instance, a resource or their current status log was last confirmed is the latest of its own column and of the last_comm of its node, which only the daemon status and ping feeds write: the scrubs, the "not updated" log and alert, the encap peers, the compliance variables, the status periods, the resource logs and the mon_updated/updated API props read it. A resource deleted gets its res_end set then, so the purge of the logs of the resources gone still counts from when they went.
- "hardware|os obsolescence warning|alert date not set": written for the nodes whose model or operating system has no such date, as cron_dash_obs_without(), not only purged. - "node frozen" and "service frozen": from nodes and svcmon, by the alert_frozen task, every minute. - "duplicate uid" and "duplicate gid": on the system feed of a node. - "compliance differences in cluster": by the hourly alert_compliance_differences_in_cluster task, among the nodes of a service seen in the last day. - "slow task": the feeds waiting for a worker for more than 5 minutes, every minute. The feeder now values the elements of the pending hashes with the unix time they were queued at. The MariaDB tests run when OC3_TEST_MYSQL_DSN names a server.
As the historical collector's api_networks.py:
- GET, POST and DELETE /networks/{net_id}: read, change or delete a
network, its segments and their responsibles going with it. A new
network/netmask must be a network address, not declared already and
still hold the segments of the network.
- GET /networks/{net_id}/segments, GET, POST and DELETE
/networks/{net_id}/segments/{seg_id}: the range of a segment stays in
its network and does not overlap another.
- GET /networks/{net_id}/segments/{seg_id}/responsibles, POST and DELETE
.../responsibles/{group_id}: the organisational groups whose members
allocate the addresses of a segment.
- GET /networks/{net_id}/ips: the addresses of the segments the groups of
the caller are responsible for, or of the whole network without
segment, with the nodes reporting them, up to 65536 addresses.
The writes take the NetworkManager privilege and the team responsible for
the network, or a group responsible for the segment for its changes and
responsibles, as before; a manager takes any. The allocation and the
release of addresses, which wrote DNS records, are not ported.
Port the sysreport admin handlers of the historical collector:
GET/POST /sysreport/secure_patterns, GET/DELETE /sysreport/secure_patterns/{id},
GET/POST /sysreport/authorizations, GET/DELETE /sysreport/authorizations/{id}.
The writes need the Manager privilege, the reads a user authentication. The
patterns are validated with the engine of the sysreport access checks (Go
RE2, anchored at the start of the path). A duplicate is a 409 rather than the
info message of the historical collector, an unknown id a 404. An
authorization names its group by group_id or group_name and its filterset by
fset_id or fset_name, the lists joining auth_group and gen_filtersets for
their names instead of the v_sysrep_allow view. Each write is logged
(sysreport.secure_pattern.create/delete, sysreport.authorization.create/delete)
and the table changes notified. The menu entry adm-sysreport can be hidden by
the groups.
…work The team owning a segmented network could not list its addresses unless one of its groups was also responsible for a segment.
An automation signing in with the access tokens of a service account of the
provider never signs in through the browser, where an identity is linked to
an account, and a Bearer token never creates nor links one: its requests
were refused as "bearer token of an identity unknown to the collector".
- GET, POST /users/{user_id}/identities and DELETE
/users/{user_id}/identities/{identity_id}: list, link and unlink the
identities of an account. The issuer defaults to, and must be, the one of
the collector's provider; an identity already linked is refused with a 409.
The UserManager privilege is required, and a Manager for the account of a
Manager, whose privileges the identity would take. Each link and unlink is
logged.
- The refusal of a Bearer token of an unknown identity logs its issuer and
subject, what an administrator links.
An identity linked by hand next to another one gave a second way to sign in
as the account, easy to set on the wrong one. POST /users/{user_id}/identities
refuses an account having an identity with a 409: replacing it takes
unlinking it first. The link by verified email of a browser sign-in refuses
the same. The link and unlink log actions are named users.identity.* as the
one of the sign-in.
GET /topology?node_ids=&svc_ids=&app_ids=&display= returns the graph controllers/topo.py built for vis.js: the vertices of the layers asked for (nodes, services, apps, envs, resources, disks, arrays, san, and the locations from the hypervisor to the country) and the edges relating them, with the availability of the instances and resources and the speeds of the SAN links. The graph is semantic, kinds and statuses, the client chooses the look. As before, it starts from the objects given, those of the applications the caller's groups are responsible for unless a manager, then takes the services of those nodes and the nodes of those services. More than 1000 nodes and services are refused.
Each daemon status rewrote the svcmon, svcmon_log_last, resmon and resmon_log_last rows of the instances it reported unchanged, as the ping did before 4539227: the job already writes the last_comm of their nodes, which confirms them (cdb.lastSeen). Those rows were rewritten so the purge of the resources a report no longer holds, by resmon.updated, would keep theirs: it now leaves out the instances reported unchanged, node by node, still by its node_id, updated index.
DashboardObjectWithTypeDelete deleted WHERE (svc_id, dash_type) IN (...). With a few thousand pairs, the range optimizer of MariaDB 12.3 gives up the indexes of the dashboard (svc_id, dash_type, and the svc_id and dash_type prefixed ones) and scans it whole: 99k rows examined for 2000 pairs on a 100k alerts table, where 50 pairs use k_svc_id. It now deletes by type, dash_type = ? AND svc_id IN (...), 1000 services a statement, which stays on k_svc_id, and announces the change of the dashboard.
The server checked a value submitted to a strict input with dynamic candidates against a list called with search and search_props, which the oc3 lists ignore, and without the historical "filters" of the Args, which they ignore too: only the browser translated them. A value the form filters out, a DEV node where the form offers the PRD ones, was accepted from the API as long as the submitter could see it. The Args are now sent as the browser sends them, the "filters" translated into oc3 list filters (legacyFilter, as in the frontend form-engine.ts), a key given several times sent several times, with limit=0 and a filter on the submitted value. When the list cannot filter on the key, the whole filtered list is fetched. The comparison stays exact. The error no longer lists every candidate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The collector can now issue the tokens of the om3 webapp and CLI users. Users
sign in once on the collector, and what they may do on each cluster comes from
grants administered in the collector, per team.
The frontend pages are in opensvc/oc3-frontend PR "Administer the om3 grants
and approve the OpenID Connect requests".
This branch also carries a fix: the migration that deletes the services
without svcname and makes the column NOT NULL (see its commit).
Model
client_idis the cluster id, so a token isonly valid for the cluster it was asked for (
aud).oidc_provider_grantsmaps a team to a cluster, orto every cluster when
cluster_idis NULL, and to the om3 grants it gives(
root,admin:<ns>,guest:*…). The grants of a user on a cluster arethose of their teams, and they go into the token as its entitlements.
Protocol (
/api/oidc, public, CORS *)/.well-known/openid-configuration,/jwks,/authorize,/token,/userinfo,/revoke. These routes are registered with echo outside api.yaml.Authorization code flow, with PKCE S256 only.
Refresh tokens are stored by their sha256 and rotated on each use. Reusing
one revokes its whole family. Their lifetime is bounded by an idle timeout
and a maximum lifetime.
Accepted redirect URIs:
*/auth-callbackand*/silent-renewon the names, fqdn and routableIPs of the cluster nodes;
redirect_hosts;/callbackfor the CLI.Loopback, link-local and multicast node IPs are not accepted.
Signing keys: RSA 2048+ or ECDSA P-256/P-384, and the kid is the key
thumbprint. The first key signs and all keys are published, so keys can be
rotated.
Sign-in flow
/api/oidc/authorizechecks the client and the redirect URI, keeps therequest in redis, and sends the browser to the SPA at
/oidc/authorize?request=ID.approves the request through
/oidc_provider/requests/{id}/approve, ordenies it with
/deny. It asks the user first when the client wantsconsent, and it cannot approve when the user has no grant on the cluster.
API (api.yaml)
GET /oidc_provider: whether the provider is enabled, and its issuer.GET /oidc_provider/requests/{id},POST …/approve,POST …/deny./oidc_provider/grants,/oidc_provider/grants/{id}: CRUD for theManager.
adm-om3-grants.