masks-server 0.11.0 → 0.12.0
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.
- checksums.yaml +4 -4
- data/app/controllers/masks/server/account_controller.rb +3 -0
- data/app/controllers/masks/server/app_passwords_controller.rb +41 -0
- data/app/controllers/masks/server/authorize_controller.rb +33 -2
- data/app/controllers/masks/server/forward_auth_controller.rb +104 -12
- data/app/controllers/masks/server/logins_controller.rb +4 -3
- data/app/controllers/masks/server/organization_access_controller.rb +39 -0
- data/app/graphql/masks/server/manage/mutations/base_mutation.rb +7 -0
- data/app/graphql/masks/server/manage/mutations/create_group.rb +6 -4
- data/app/graphql/masks/server/manage/mutations/decline_access.rb +27 -0
- data/app/graphql/masks/server/manage/mutations/grant_access.rb +29 -0
- data/app/graphql/masks/server/manage/mutations/group_source.rb +34 -0
- data/app/graphql/masks/server/manage/mutations/issue_ldap_credential.rb +5 -2
- data/app/graphql/masks/server/manage/mutations/refresh_group.rb +21 -0
- data/app/graphql/masks/server/manage/mutations/remove_group_member.rb +2 -0
- data/app/graphql/masks/server/manage/mutations/run_health_checks.rb +19 -0
- data/app/graphql/masks/server/manage/mutations/update_client.rb +6 -0
- data/app/graphql/masks/server/manage/mutations/update_group.rb +7 -4
- data/app/graphql/masks/server/manage/mutations/update_tenant.rb +14 -1
- data/app/graphql/masks/server/manage/types/access_request_type.rb +21 -0
- data/app/graphql/masks/server/manage/types/actor_type.rb +6 -0
- data/app/graphql/masks/server/manage/types/client_type.rb +12 -0
- data/app/graphql/masks/server/manage/types/group_condition_input.rb +16 -0
- data/app/graphql/masks/server/manage/types/group_condition_type.rb +29 -0
- data/app/graphql/masks/server/manage/types/group_member_type.rb +16 -0
- data/app/graphql/masks/server/manage/types/group_type.rb +17 -1
- data/app/graphql/masks/server/manage/types/health_check_type.rb +18 -0
- data/app/graphql/masks/server/manage/types/ldap_credential_type.rb +1 -0
- data/app/graphql/masks/server/manage/types/mutation_type.rb +4 -0
- data/app/graphql/masks/server/manage/types/query_type.rb +24 -0
- data/app/graphql/masks/server/manage/types/release_type.rb +16 -0
- data/app/graphql/masks/server/manage/types/tenant_type.rb +6 -1
- data/app/helpers/masks/server/account_helper.rb +4 -0
- data/app/jobs/masks/server/cleanup_job.rb +1 -0
- data/app/jobs/masks/server/health_check_job.rb +21 -0
- data/app/jobs/masks/server/refresh_groups_job.rb +18 -0
- data/app/jobs/masks/server/release_check_job.rb +21 -0
- data/app/ldap/masks/server/ldap/connection.rb +3 -2
- data/app/ldap/masks/server/ldap/gate.rb +31 -4
- data/app/logins/masks/server/login_states/second_factor.rb +1 -1
- data/app/mailers/masks/server/actor_mailer.rb +31 -0
- data/app/models/masks/server/access_request.rb +103 -0
- data/app/models/masks/server/actor.rb +6 -0
- data/app/models/masks/server/app_password.rb +91 -0
- data/app/models/masks/server/app_passwords.rb +82 -0
- data/app/models/masks/server/client.rb +15 -0
- data/app/models/masks/server/connection.rb +7 -0
- data/app/models/masks/server/declared.rb +10 -2
- data/app/models/masks/server/email_verification.rb +2 -2
- data/app/models/masks/server/event.rb +11 -1
- data/app/models/masks/server/federation/protocol.rb +1 -1
- data/app/models/masks/server/federation/saml.rb +1 -1
- data/app/models/masks/server/forward_auth_rules.rb +162 -0
- data/app/models/masks/server/group.rb +207 -4
- data/app/models/masks/server/group_member.rb +7 -0
- data/app/models/masks/server/group_rule.rb +63 -0
- data/app/models/masks/server/health.rb +243 -0
- data/app/models/masks/server/health_check.rb +27 -0
- data/app/models/masks/server/invitation.rb +2 -2
- data/app/models/masks/server/ldap_credential.rb +2 -2
- data/app/models/masks/server/login.rb +28 -2
- data/app/models/masks/server/mail_previews.rb +5 -0
- data/app/models/masks/server/mail_template.rb +2 -0
- data/app/models/masks/server/membership.rb +10 -3
- data/app/models/masks/server/notifications.rb +3 -1
- data/app/models/masks/server/password_reset.rb +2 -2
- data/app/models/masks/server/provider.rb +1 -0
- data/app/models/masks/server/queue.rb +60 -0
- data/app/models/masks/server/release.rb +74 -0
- data/app/models/masks/server/session.rb +8 -0
- data/app/models/masks/server/tenant.rb +39 -2
- data/app/models/masks/server/token.rb +2 -1
- data/app/views/masks/server/account/_app_passwords.html.erb +83 -0
- data/app/views/masks/server/account/_organizations.html.erb +33 -0
- data/app/views/masks/server/account/index.html.erb +5 -0
- data/app/views/masks/server/actor_mailer/access_declined.html.erb +5 -0
- data/app/views/masks/server/actor_mailer/access_declined.text.erb +5 -0
- data/app/views/masks/server/actor_mailer/access_granted.html.erb +7 -0
- data/app/views/masks/server/actor_mailer/access_granted.text.erb +7 -0
- data/app/views/masks/server/authorize/error.html.erb +25 -0
- data/config/locales/de/access_requests.yml +43 -0
- data/config/locales/de/account/app_passwords.yml +42 -0
- data/config/locales/de/events.yml +5 -0
- data/config/locales/de/flashes.yml +1 -0
- data/config/locales/de/group_sources.yml +5 -0
- data/config/locales/de/manage/access_requests.yml +12 -0
- data/config/locales/de/manage/app_passwords.yml +16 -0
- data/config/locales/de/manage/forward_auth_rules.yml +29 -0
- data/config/locales/de/manage/group_sources.yml +44 -0
- data/config/locales/de/manage/health.yml +78 -0
- data/config/locales/de/manage/links.yml +20 -0
- data/config/locales/en/access_requests.yml +43 -0
- data/config/locales/en/account/app_passwords.yml +42 -0
- data/config/locales/en/events.yml +5 -0
- data/config/locales/en/flashes.yml +1 -0
- data/config/locales/en/group_sources.yml +5 -0
- data/config/locales/en/manage/access_requests.yml +12 -0
- data/config/locales/en/manage/app_passwords.yml +16 -0
- data/config/locales/en/manage/forward_auth_rules.yml +29 -0
- data/config/locales/en/manage/group_sources.yml +44 -0
- data/config/locales/en/manage/health.yml +78 -0
- data/config/locales/en/manage/links.yml +20 -0
- data/config/locales/es/access_requests.yml +43 -0
- data/config/locales/es/account/app_passwords.yml +42 -0
- data/config/locales/es/events.yml +5 -0
- data/config/locales/es/flashes.yml +1 -0
- data/config/locales/es/group_sources.yml +5 -0
- data/config/locales/es/manage/access_requests.yml +12 -0
- data/config/locales/es/manage/app_passwords.yml +16 -0
- data/config/locales/es/manage/forward_auth_rules.yml +29 -0
- data/config/locales/es/manage/group_sources.yml +44 -0
- data/config/locales/es/manage/health.yml +78 -0
- data/config/locales/es/manage/links.yml +20 -0
- data/config/locales/fr/access_requests.yml +43 -0
- data/config/locales/fr/account/app_passwords.yml +42 -0
- data/config/locales/fr/events.yml +5 -0
- data/config/locales/fr/flashes.yml +1 -0
- data/config/locales/fr/group_sources.yml +5 -0
- data/config/locales/fr/manage/access_requests.yml +12 -0
- data/config/locales/fr/manage/app_passwords.yml +16 -0
- data/config/locales/fr/manage/forward_auth_rules.yml +29 -0
- data/config/locales/fr/manage/group_sources.yml +44 -0
- data/config/locales/fr/manage/health.yml +78 -0
- data/config/locales/fr/manage/links.yml +20 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20261020100000_create_access_requests.rb +28 -0
- data/db/migrate/20261020110000_add_app_passwords_to_clients.rb +5 -0
- data/db/migrate/20261020120000_add_forward_auth_rules_to_clients.rb +6 -0
- data/db/migrate/20261020130000_add_sources_to_groups.rb +15 -0
- data/db/migrate/20261020140000_create_health_checks.rb +25 -0
- data/db/migrate/20261020150000_add_link_lifetimes_to_tenants.rb +8 -0
- data/db/migrate/20261021100000_add_pinned_origin_to_tenants.rb +5 -0
- data/lib/generators/masks/server/install/install_generator.rb +3 -2
- data/lib/masks/server/configuration.rb +2 -11
- data/lib/masks/server/schema_reference.rb +12 -0
- data/lib/masks/server/tenancy/middleware.rb +17 -6
- data/public/masks-assets/.vite/manifest.json +13 -13
- data/public/masks-assets/assets/{account-D46qDQCo.js → account-h7I6VUPR.js} +2 -2
- data/public/masks-assets/assets/{account-D46qDQCo.js.map → account-h7I6VUPR.js.map} +1 -1
- data/public/masks-assets/assets/{app-D7W0gAyT.css → app-BXOScMjL.css} +1 -1
- data/public/masks-assets/assets/{handshake-DIFZPSAK.js → handshake-YQpRNMIs.js} +2 -2
- data/public/masks-assets/assets/{handshake-DIFZPSAK.js.map → handshake-YQpRNMIs.js.map} +1 -1
- data/public/masks-assets/assets/initial-Cn-UuAsy.js +3 -0
- data/public/masks-assets/assets/{initial-C1GpCiEh.js.map → initial-Cn-UuAsy.js.map} +1 -1
- data/public/masks-assets/assets/{login-C_6igRZ3.js → login-C21_jb6L.js} +3 -3
- data/public/masks-assets/assets/{login-C_6igRZ3.js.map → login-C21_jb6L.js.map} +1 -1
- data/public/masks-assets/assets/{manage-D4MzaDvM.js → manage-DpVxe5sv.js} +80 -51
- data/public/masks-assets/assets/manage-DpVxe5sv.js.map +1 -0
- data/public/masks-assets/assets/passkey-5UYPVD3c.js +2 -0
- data/public/masks-assets/assets/{passkey-DIj_5LCY.js.map → passkey-5UYPVD3c.js.map} +1 -1
- data/version.txt +1 -1
- metadata +87 -14
- data/public/masks-assets/assets/initial-C1GpCiEh.js +0 -3
- data/public/masks-assets/assets/manage-D4MzaDvM.js.map +0 -1
- data/public/masks-assets/assets/passkey-DIj_5LCY.js +0 -2
|
@@ -32,6 +32,8 @@ module Masks
|
|
|
32
32
|
field :tokens, [ "Masks::Server::Manage::Types::TokenType" ], null: false
|
|
33
33
|
field :memberships, [ "Masks::Server::Manage::Types::MembershipType" ], null: false
|
|
34
34
|
field :groups, [ "Masks::Server::Manage::Types::GroupType" ], null: false
|
|
35
|
+
field :group_memberships, [ "Masks::Server::Manage::Types::GroupMemberType" ], null: false,
|
|
36
|
+
description: "Each group the person is in, with what put them there."
|
|
35
37
|
field :group_labels, [ String ], null: false,
|
|
36
38
|
description: "What the groups claim carries: each group's key, and each organization role as key:role."
|
|
37
39
|
|
|
@@ -130,6 +132,10 @@ module Masks
|
|
|
130
132
|
object.memberships.includes(:organization).joins(:organization).order("organizations.name")
|
|
131
133
|
end
|
|
132
134
|
|
|
135
|
+
def group_memberships
|
|
136
|
+
object.group_members.includes(:group).joins(:group).order("groups.name")
|
|
137
|
+
end
|
|
138
|
+
|
|
133
139
|
def tokens
|
|
134
140
|
Masks::Server::Token.where(kind: TokenType::GRANTS, actor_id: object.id)
|
|
135
141
|
.live
|
|
@@ -20,6 +20,10 @@ module Masks
|
|
|
20
20
|
description: "Seconds from a sign-in until its refresh tokens stop, however often they are used. Null is 90 days."
|
|
21
21
|
field :allowed_groups, [ String ], null: false,
|
|
22
22
|
description: "Group keys, or organization roles as key:role, whose people may sign in. Empty lets everyone in."
|
|
23
|
+
field :forward_auth_rules, GraphQL::Types::JSON, null: false,
|
|
24
|
+
description: "The ordered rules forward auth follows for an app behind a proxy. Each has `paths`, `methods`, " \
|
|
25
|
+
"`networks`, and `groups` it covers, and an `outcome` of open, one_factor, two_factor, token, or deny. " \
|
|
26
|
+
"The first rule that covers a request decides it. With no rule, a signed-in person who may sign in is let through."
|
|
23
27
|
field :namespaces, [ "Masks::Server::Manage::Types::NamespaceType" ], null: false
|
|
24
28
|
field :token_endpoint_auth_method, String, null: false
|
|
25
29
|
field :subject_type, String, null: false
|
|
@@ -55,6 +59,8 @@ module Masks
|
|
|
55
59
|
description: "Where masks posts a signed LogoutRequest when a person who signed in to this SAML application signs out, and its LogoutResponse when the application asks."
|
|
56
60
|
field :require_signed_request_object, Boolean, null: false
|
|
57
61
|
field :consent_required, Boolean, null: false
|
|
62
|
+
field :app_passwords, Boolean, null: false,
|
|
63
|
+
description: "Whether people may make an app password for this client, which LDAP and forward auth accept in place of their password and second factor."
|
|
58
64
|
field :sign_in_policy, SignInPolicyType
|
|
59
65
|
field :dynamic, Boolean, null: false
|
|
60
66
|
field :approved_at, GraphQL::Types::ISO8601DateTime
|
|
@@ -65,6 +71,8 @@ module Masks
|
|
|
65
71
|
description: "The machines this app enrolled that are not archived."
|
|
66
72
|
field :last_seen_at, GraphQL::Types::ISO8601DateTime,
|
|
67
73
|
description: "When this client last got a token. Null if it never has."
|
|
74
|
+
field :access_requests, [ "Masks::Server::Manage::Types::AccessRequestType" ], null: false,
|
|
75
|
+
description: "Actors turned away from this client who asked for access and are waiting."
|
|
68
76
|
field :archived_at, GraphQL::Types::ISO8601DateTime
|
|
69
77
|
field :secret_expires_at, GraphQL::Types::ISO8601DateTime
|
|
70
78
|
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
|
|
@@ -87,6 +95,10 @@ module Masks
|
|
|
87
95
|
object.enrolled.active.order(:name)
|
|
88
96
|
end
|
|
89
97
|
|
|
98
|
+
def access_requests
|
|
99
|
+
object.access_requests.open.includes(:actor).order(:created_at)
|
|
100
|
+
end
|
|
101
|
+
|
|
90
102
|
def last_seen_at
|
|
91
103
|
Masks::Server::Token.where(kind: TokenType::GRANTS, client_id: object.id).maximum(:created_at)
|
|
92
104
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Masks
|
|
2
|
+
module Server
|
|
3
|
+
module Manage
|
|
4
|
+
module Types
|
|
5
|
+
class GroupConditionInput < GraphQL::Schema::InputObject
|
|
6
|
+
description "One condition of a group's rule."
|
|
7
|
+
|
|
8
|
+
argument :kind, String, description: "email_domain or profile."
|
|
9
|
+
argument :field, String, required: false,
|
|
10
|
+
description: "For profile: name, given_name, family_name, middle_name, nickname, gender, zoneinfo, or locale."
|
|
11
|
+
argument :value, String, description: "The domain a verified email address ends with, or the value the profile field equals."
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Masks
|
|
2
|
+
module Server
|
|
3
|
+
module Manage
|
|
4
|
+
module Types
|
|
5
|
+
class GroupConditionType < BaseObject
|
|
6
|
+
description "One condition of a group's rule. Every condition must hold for a person to be in the group."
|
|
7
|
+
|
|
8
|
+
field :kind, String, null: false, description: "email_domain or profile."
|
|
9
|
+
field :field, String, description: "The profile field a profile condition reads."
|
|
10
|
+
field :value, String, null: false,
|
|
11
|
+
description: "The domain a verified email address ends with, or the value the profile field equals. " \
|
|
12
|
+
"A profile condition matches only people whose profile a directory sets."
|
|
13
|
+
|
|
14
|
+
def kind
|
|
15
|
+
object["kind"]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def field
|
|
19
|
+
object["field"]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def value
|
|
23
|
+
object["value"]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Masks
|
|
2
|
+
module Server
|
|
3
|
+
module Manage
|
|
4
|
+
module Types
|
|
5
|
+
class GroupMemberType < BaseObject
|
|
6
|
+
description "A person's place in a group, and what put them there."
|
|
7
|
+
|
|
8
|
+
field :group, GroupType, null: false
|
|
9
|
+
field :actor, ActorType, null: false
|
|
10
|
+
field :sourced_by, String, description: "rule, provider, or group when the group's source put them in. Null when a manager added them by hand."
|
|
11
|
+
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -3,14 +3,26 @@ module Masks
|
|
|
3
3
|
module Manage
|
|
4
4
|
module Types
|
|
5
5
|
class GroupType < BaseObject
|
|
6
|
-
description "A named set of people in the tenant. The groups claim lists the key of each group a person is in."
|
|
6
|
+
description "A named set of people in the tenant. The groups claim lists the key of each group a person is in. " \
|
|
7
|
+
"A group fills by hand, from a rule, from a provider, or from other groups."
|
|
7
8
|
|
|
8
9
|
field :key, String, null: false
|
|
9
10
|
field :name, String, null: false
|
|
11
|
+
field :source, String, null: false, description: "manual, rule, provider, or group."
|
|
12
|
+
field :rule, [ GroupConditionType ], null: false, description: "The conditions a rule group checks. Empty unless the source is rule."
|
|
13
|
+
field :provider_key, String, description: "The provider a provider group reads at sign-in."
|
|
14
|
+
field :upstream_group, String, description: "The group name the provider lists for people who belong."
|
|
15
|
+
field :parent_labels, [ String ], null: false, description: "The group keys and organization roles, as key:role, a nested group holds everyone from."
|
|
16
|
+
field :refreshed_at, GraphQL::Types::ISO8601DateTime, description: "When the source last filled the group."
|
|
10
17
|
field :member_count, Integer, null: false
|
|
11
18
|
field :members, [ ActorType ], null: false
|
|
19
|
+
field :memberships, [ GroupMemberType ], null: false, description: "Each member with what put them in the group."
|
|
12
20
|
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
|
|
13
21
|
|
|
22
|
+
def provider_key
|
|
23
|
+
object.provider&.key
|
|
24
|
+
end
|
|
25
|
+
|
|
14
26
|
def member_count
|
|
15
27
|
object.members.count
|
|
16
28
|
end
|
|
@@ -18,6 +30,10 @@ module Masks
|
|
|
18
30
|
def members
|
|
19
31
|
object.actors.order(:nickname)
|
|
20
32
|
end
|
|
33
|
+
|
|
34
|
+
def memberships
|
|
35
|
+
object.members.includes(:actor).sort_by { |member| member.actor.nickname.to_s }
|
|
36
|
+
end
|
|
21
37
|
end
|
|
22
38
|
end
|
|
23
39
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Masks
|
|
2
|
+
module Server
|
|
3
|
+
module Manage
|
|
4
|
+
module Types
|
|
5
|
+
class HealthCheckType < BaseObject
|
|
6
|
+
description "The latest result of one health check. Checks run every 10 minutes."
|
|
7
|
+
|
|
8
|
+
field :name, ID, null: false, description: "jobs, worker, queue, ldap, metrics, mail, origin, domains, or keys."
|
|
9
|
+
field :status, String, null: false, description: "ok, warning, or failing."
|
|
10
|
+
field :summary, String, null: false, description: "A short word for what the check found, such as none, stale, or silent."
|
|
11
|
+
field :details, GraphQL::Types::JSON, null: false, description: "The figures and names behind the summary."
|
|
12
|
+
field :checked_at, GraphQL::Types::ISO8601DateTime, null: false
|
|
13
|
+
field :changed_at, GraphQL::Types::ISO8601DateTime, null: false, description: "When the status last changed."
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -7,6 +7,7 @@ module Masks
|
|
|
7
7
|
field :label, String, null: false
|
|
8
8
|
field :bind_dn, String, null: false, description: "The DN an app binds as, under ou=services in this tenant's directory."
|
|
9
9
|
field :issued_by, ActorType
|
|
10
|
+
field :client, ClientType, description: "The client whose app passwords bind through this credential, when one was chosen."
|
|
10
11
|
field :used_at, GraphQL::Types::ISO8601DateTime, description: "When an app last bound with it, to within five minutes."
|
|
11
12
|
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
|
|
12
13
|
|
|
@@ -28,6 +28,9 @@ module Masks
|
|
|
28
28
|
field :delete_group, mutation: Mutations::DeleteGroup
|
|
29
29
|
field :add_group_member, mutation: Mutations::AddGroupMember
|
|
30
30
|
field :remove_group_member, mutation: Mutations::RemoveGroupMember
|
|
31
|
+
field :grant_access, mutation: Mutations::GrantAccess
|
|
32
|
+
field :decline_access, mutation: Mutations::DeclineAccess
|
|
33
|
+
field :refresh_group, mutation: Mutations::RefreshGroup
|
|
31
34
|
field :disable_code_factor, mutation: Mutations::DisableCodeFactor
|
|
32
35
|
field :revoke_passkey, mutation: Mutations::RevokePasskey
|
|
33
36
|
field :upload_avatar, mutation: Mutations::UploadAvatar
|
|
@@ -97,6 +100,7 @@ module Masks
|
|
|
97
100
|
field :activate_signing_key, mutation: Mutations::ActivateSigningKey
|
|
98
101
|
field :discard_signing_key, mutation: Mutations::DiscardSigningKey
|
|
99
102
|
field :rotate_signing_key, mutation: Mutations::RotateSigningKey
|
|
103
|
+
field :run_health_checks, mutation: Mutations::RunHealthChecks
|
|
100
104
|
end
|
|
101
105
|
end
|
|
102
106
|
end
|
|
@@ -191,6 +191,13 @@ module Masks
|
|
|
191
191
|
|
|
192
192
|
field :event_actions, [ EventActionType ], null: false
|
|
193
193
|
|
|
194
|
+
field :health, [ HealthCheckType ], null: false,
|
|
195
|
+
description: "The latest result of each health check for this tenant and the server it runs on. " \
|
|
196
|
+
"Empty until the first scheduled run."
|
|
197
|
+
field :release, ReleaseType,
|
|
198
|
+
description: "The newest release when it is newer than this server. Null while the server is current, " \
|
|
199
|
+
"or while MASKS_RELEASE_CHECK is off."
|
|
200
|
+
|
|
194
201
|
LIMIT = 50
|
|
195
202
|
CEILING = 200
|
|
196
203
|
SPAN = 30
|
|
@@ -464,6 +471,23 @@ module Masks
|
|
|
464
471
|
Masks::Server::Event::ACTIONS.sort
|
|
465
472
|
end
|
|
466
473
|
|
|
474
|
+
def health
|
|
475
|
+
Masks::Server::HealthCheck.by_name
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
def release
|
|
479
|
+
found = Masks::Server::Release.available
|
|
480
|
+
|
|
481
|
+
return nil if found.nil?
|
|
482
|
+
|
|
483
|
+
{
|
|
484
|
+
version: found["version"],
|
|
485
|
+
url: found["url"],
|
|
486
|
+
operator_step: found["operator_step"] == true,
|
|
487
|
+
checked_at: Time.iso8601(found["checked_at"])
|
|
488
|
+
}
|
|
489
|
+
end
|
|
490
|
+
|
|
467
491
|
private
|
|
468
492
|
|
|
469
493
|
def actor_scope(search: nil, activated: nil, holds: nil, pending_approval: nil, recovery_requested: nil,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Masks
|
|
2
|
+
module Server
|
|
3
|
+
module Manage
|
|
4
|
+
module Types
|
|
5
|
+
class ReleaseType < BaseObject
|
|
6
|
+
description "A newer release of masks than the one this server runs."
|
|
7
|
+
|
|
8
|
+
field :version, String, null: false
|
|
9
|
+
field :url, String, null: false, description: "The release notes."
|
|
10
|
+
field :operator_step, Boolean, null: false, description: "Whether the release notes carry a line that starts with Operator:."
|
|
11
|
+
field :checked_at, GraphQL::Types::ISO8601DateTime, null: false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -9,7 +9,7 @@ module Masks
|
|
|
9
9
|
field :origins, [ String ], null: false, description: "Every origin this tenant answers on, each its own issuer."
|
|
10
10
|
|
|
11
11
|
def origins
|
|
12
|
-
[ object.templated_origin, object.custom_origin ].compact
|
|
12
|
+
[ object.templated_origin || object.held_origin, object.custom_origin ].compact
|
|
13
13
|
end
|
|
14
14
|
field :name, String, null: false
|
|
15
15
|
field :named_by, String, null: false
|
|
@@ -31,6 +31,11 @@ module Masks
|
|
|
31
31
|
def event_retention_days
|
|
32
32
|
object.event_retention.in_days.round
|
|
33
33
|
end
|
|
34
|
+
field :invitation_lifetime, Integer, null: false, description: "Seconds an invitation to an account stays valid."
|
|
35
|
+
field :organization_invitation_lifetime, Integer, null: false,
|
|
36
|
+
description: "Seconds an invitation to an organization stays open after it was last sent."
|
|
37
|
+
field :password_reset_lifetime, Integer, null: false, description: "Seconds a password reset link stays valid."
|
|
38
|
+
field :email_verification_lifetime, Integer, null: false, description: "Seconds an email confirmation link stays valid."
|
|
34
39
|
field :ldap_enabled, Boolean, null: false, description: "Whether the LDAP directory answers for this tenant.", method: :ldap?
|
|
35
40
|
field :ldap_password_only, Boolean, null: false,
|
|
36
41
|
description: "Whether a password alone binds to LDAP for an account that would otherwise need a second factor.",
|
|
@@ -29,6 +29,10 @@ module Masks
|
|
|
29
29
|
t("account.index.#{key}", **options)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
def account_access_requests(organization)
|
|
33
|
+
AccessRequest.for_organization(organization).includes(:actor, :client).order(:created_at)
|
|
34
|
+
end
|
|
35
|
+
|
|
32
36
|
def account_roster(organization)
|
|
33
37
|
organization.memberships.sort_by do |member|
|
|
34
38
|
[ member.pending? ? 1 : 0, member.owner? ? 0 : 1, Members.label(member).to_s.downcase ]
|
|
@@ -34,6 +34,7 @@ module Masks
|
|
|
34
34
|
Members.purge_lapsed!
|
|
35
35
|
Replay.where(expires_at: ...Time.current).in_batches(of: BATCH).delete_all
|
|
36
36
|
ReleasedNickname.lapsed.in_batches(of: BATCH).delete_all
|
|
37
|
+
AccessRequest.lapsed.in_batches(of: BATCH).delete_all
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
def sweep_tokens(cutoff)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Masks
|
|
2
|
+
module Server
|
|
3
|
+
class HealthCheckJob < ApplicationJob
|
|
4
|
+
queue_as :maintenance
|
|
5
|
+
across_tenants!
|
|
6
|
+
|
|
7
|
+
def perform
|
|
8
|
+
server = Health.server_results
|
|
9
|
+
failing = Hash.new { |held, name| held[name] = [] }
|
|
10
|
+
|
|
11
|
+
begin
|
|
12
|
+
each_tenant do |tenant|
|
|
13
|
+
Health.store!(server + Health.tenant_results).select(&:failing?).each { |row| failing[row.name] << tenant.subdomain }
|
|
14
|
+
end
|
|
15
|
+
ensure
|
|
16
|
+
Health.remember_all!(failing)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Masks
|
|
2
|
+
module Server
|
|
3
|
+
class RefreshGroupsJob < ApplicationJob
|
|
4
|
+
queue_as :maintenance
|
|
5
|
+
across_tenants!
|
|
6
|
+
|
|
7
|
+
def perform
|
|
8
|
+
each_tenant { refresh }
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def refresh
|
|
14
|
+
Group.sourced.find_each(&:refresh!)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Masks
|
|
2
|
+
module Server
|
|
3
|
+
class ReleaseCheckJob < ApplicationJob
|
|
4
|
+
queue_as :maintenance
|
|
5
|
+
across_tenants!
|
|
6
|
+
|
|
7
|
+
def perform
|
|
8
|
+
return unless ::Rails.configuration.masks.release_check
|
|
9
|
+
|
|
10
|
+
found = Release.check!
|
|
11
|
+
|
|
12
|
+
return if found.nil?
|
|
13
|
+
|
|
14
|
+
each_tenant do
|
|
15
|
+
Event.record!(Event::RELEASE_AVAILABLE, by: nil, version: found["version"], url: found["url"],
|
|
16
|
+
operator_step: found["operator_step"])
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -58,7 +58,7 @@ module Masks
|
|
|
58
58
|
|
|
59
59
|
def bind(message)
|
|
60
60
|
request = message.operation
|
|
61
|
-
@bound = nil
|
|
61
|
+
previous, @bound = @bound, nil
|
|
62
62
|
|
|
63
63
|
if request.version != 3
|
|
64
64
|
return write(Protocol.bind_response(message.id, Protocol::PROTOCOL_ERROR, "only LDAPv3 is spoken here"))
|
|
@@ -68,7 +68,8 @@ module Masks
|
|
|
68
68
|
return write(Protocol.bind_response(message.id, Protocol::AUTH_METHOD_NOT_SUPPORTED, "only simple binds are supported"))
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
outcome = Gate.new(ip_address: @ip_address
|
|
71
|
+
outcome = Gate.new(ip_address: @ip_address, client_id: previous&.service? ? previous.client_id : nil)
|
|
72
|
+
.bind(request.name, request.password)
|
|
72
73
|
@bound = outcome.bound
|
|
73
74
|
|
|
74
75
|
write(Protocol.bind_response(message.id, outcome.code, outcome.message))
|
|
@@ -5,7 +5,11 @@ module Masks
|
|
|
5
5
|
WINDOW = 3.minutes
|
|
6
6
|
VIA = "ldap".freeze
|
|
7
7
|
|
|
8
|
-
Bound = Data.define(:kind, :tenant, :dn, :subject) do
|
|
8
|
+
Bound = Data.define(:kind, :tenant, :dn, :subject, :client_id) do
|
|
9
|
+
def initialize(client_id: nil, **rest)
|
|
10
|
+
super(client_id: client_id, **rest)
|
|
11
|
+
end
|
|
12
|
+
|
|
9
13
|
def service?
|
|
10
14
|
kind == :service
|
|
11
15
|
end
|
|
@@ -17,8 +21,9 @@ module Masks
|
|
|
17
21
|
|
|
18
22
|
Outcome = Data.define(:code, :message, :bound)
|
|
19
23
|
|
|
20
|
-
def initialize(ip_address:)
|
|
24
|
+
def initialize(ip_address:, client_id: nil)
|
|
21
25
|
@ip_address = ip_address
|
|
26
|
+
@client_id = client_id
|
|
22
27
|
end
|
|
23
28
|
|
|
24
29
|
def bind(name, password)
|
|
@@ -80,7 +85,8 @@ module Masks
|
|
|
80
85
|
|
|
81
86
|
Outcome.new(
|
|
82
87
|
code: Protocol::SUCCESS, message: "",
|
|
83
|
-
bound: Bound.new(kind: :service, tenant: tenant, dn: directory.service_dn(credential.label), subject: credential.id
|
|
88
|
+
bound: Bound.new(kind: :service, tenant: tenant, dn: directory.service_dn(credential.label), subject: credential.id,
|
|
89
|
+
client_id: credential.client_id)
|
|
84
90
|
)
|
|
85
91
|
end
|
|
86
92
|
|
|
@@ -93,6 +99,7 @@ module Masks
|
|
|
93
99
|
end
|
|
94
100
|
|
|
95
101
|
actor = Actor.authenticate(uid, password)
|
|
102
|
+
return app_password(tenant, directory, uid, password, account) if actor.nil? && app_password?(password)
|
|
96
103
|
|
|
97
104
|
if actor.nil?
|
|
98
105
|
failed!(ip_key, account)
|
|
@@ -103,8 +110,28 @@ module Masks
|
|
|
103
110
|
return refuse(uid, reason, actor) if reason
|
|
104
111
|
|
|
105
112
|
actor.active!
|
|
113
|
+
bound(tenant, directory, actor)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def app_password?(password)
|
|
117
|
+
@client_id && AppPassword.shaped?(password)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def app_password(tenant, directory, uid, password, account)
|
|
121
|
+
client = Client.active.find_by(id: @client_id)
|
|
122
|
+
outcome = AppPasswords.authenticate(client: client, identifier: uid, secret: password, via: VIA,
|
|
123
|
+
ip_address: @ip_address, tenant: tenant)
|
|
124
|
+
|
|
125
|
+
return throttled if outcome.throttled?
|
|
126
|
+
return bound(tenant, directory, outcome.actor, factor: AppPasswords::FACTOR) if outcome.actor
|
|
127
|
+
|
|
128
|
+
failed!(ip_key, account) if outcome.wrong?
|
|
129
|
+
invalid
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def bound(tenant, directory, actor, factor: "password")
|
|
106
133
|
dn = directory.person_dn(actor)
|
|
107
|
-
Event.record!(Event::LDAP_BOUND, actor: actor, dn: dn.to_s)
|
|
134
|
+
Event.record!(Event::LDAP_BOUND, actor: actor, dn: dn.to_s, factor: factor)
|
|
108
135
|
|
|
109
136
|
Outcome.new(code: Protocol::SUCCESS, message: "", bound: Bound.new(kind: :person, tenant: tenant, dn: dn, subject: actor.id))
|
|
110
137
|
end
|
|
@@ -160,6 +160,37 @@ module Masks
|
|
|
160
160
|
)
|
|
161
161
|
end
|
|
162
162
|
|
|
163
|
+
def access_granted(asked, journey:)
|
|
164
|
+
return message unless deliverable?
|
|
165
|
+
|
|
166
|
+
journey!(journey)
|
|
167
|
+
@actor = asked.actor
|
|
168
|
+
@app = asked.client
|
|
169
|
+
@url = (@app.approved? && @app.client_uri.presence) || home
|
|
170
|
+
|
|
171
|
+
mail(
|
|
172
|
+
from: self.class.from,
|
|
173
|
+
to: @actor.email,
|
|
174
|
+
subject: customize!(:access_granted, actor: @actor, app: @app.name,
|
|
175
|
+
default: t("actor_mailer.access_granted.subject", app: @app.name))
|
|
176
|
+
)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def access_declined(asked, journey:)
|
|
180
|
+
return message unless deliverable?
|
|
181
|
+
|
|
182
|
+
journey!(journey)
|
|
183
|
+
@actor = asked.actor
|
|
184
|
+
@app = asked.client
|
|
185
|
+
|
|
186
|
+
mail(
|
|
187
|
+
from: self.class.from,
|
|
188
|
+
to: @actor.email,
|
|
189
|
+
subject: customize!(:access_declined, actor: @actor, app: @app.name,
|
|
190
|
+
default: t("actor_mailer.access_declined.subject", app: @app.name))
|
|
191
|
+
)
|
|
192
|
+
end
|
|
193
|
+
|
|
163
194
|
private
|
|
164
195
|
|
|
165
196
|
def tenant_lede(manager)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
module Masks
|
|
2
|
+
module Server
|
|
3
|
+
class AccessRequest < ApplicationRecord
|
|
4
|
+
include TenantScoped
|
|
5
|
+
|
|
6
|
+
class Refused < StandardError; end
|
|
7
|
+
|
|
8
|
+
LIFETIME = 30.days
|
|
9
|
+
|
|
10
|
+
belongs_to :actor
|
|
11
|
+
belongs_to :client
|
|
12
|
+
belongs_to :decided_by, class_name: "Actor", optional: true
|
|
13
|
+
|
|
14
|
+
scope :open, -> { where(granted_at: nil, declined_at: nil) }
|
|
15
|
+
scope :lapsed, -> { where(created_at: ...LIFETIME.ago) }
|
|
16
|
+
scope :newest_first, -> { order(created_at: :desc) }
|
|
17
|
+
|
|
18
|
+
class << self
|
|
19
|
+
def ask!(actor:, client:)
|
|
20
|
+
return nil if client.admits?(actor)
|
|
21
|
+
|
|
22
|
+
open.find_by(actor: actor, client: client) || begin
|
|
23
|
+
created = create!(actor: actor, client: client)
|
|
24
|
+
Event.record!(Event::ACCESS_REQUESTED, actor: actor, client: client)
|
|
25
|
+
created
|
|
26
|
+
end
|
|
27
|
+
rescue ActiveRecord::RecordNotUnique
|
|
28
|
+
open.find_by!(actor: actor, client: client)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def for_organization(organization)
|
|
32
|
+
open.joins(:client).where("EXISTS (SELECT 1 FROM unnest(clients.allowed_groups) AS held WHERE held LIKE ?)",
|
|
33
|
+
"#{sanitize_sql_like(organization.key)}:%")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def open?
|
|
38
|
+
granted_at.nil? && declined_at.nil?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def grant!(label: nil, by:, journey:)
|
|
42
|
+
raise Refused, "#{actor.identifier} is already admitted to #{client.name}" if client.admits?(actor)
|
|
43
|
+
raise Refused, "this request is already decided" unless open?
|
|
44
|
+
|
|
45
|
+
chosen = label.presence || client.allowed_groups.first
|
|
46
|
+
raise Refused, "#{chosen} is not one of the groups #{client.name} allows" unless client.allowed_groups.include?(chosen)
|
|
47
|
+
|
|
48
|
+
transaction do
|
|
49
|
+
admit!(chosen, by: by)
|
|
50
|
+
update!(granted_at: Time.current, decided_by: by, label: chosen)
|
|
51
|
+
Event.record!(Event::ACCESS_GRANTED, actor: actor, by: by, client: client, label: chosen)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
ActorMailer.access_granted(self, journey: journey).deliver_later if actor.email.present?
|
|
55
|
+
|
|
56
|
+
self
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def decline!(by:, journey:)
|
|
60
|
+
raise Refused, "this request is already decided" unless open?
|
|
61
|
+
|
|
62
|
+
transaction do
|
|
63
|
+
update!(declined_at: Time.current, decided_by: by)
|
|
64
|
+
Event.record!(Event::ACCESS_DECLINED, actor: actor, by: by, client: client)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
ActorMailer.access_declined(self, journey: journey).deliver_later if actor.email.present?
|
|
68
|
+
|
|
69
|
+
self
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def organization_roles
|
|
73
|
+
client.allowed_groups.filter_map do |held|
|
|
74
|
+
key, role = held.split(":", 2)
|
|
75
|
+
[ key, role ] if role
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
private
|
|
80
|
+
|
|
81
|
+
def admit!(label, by:)
|
|
82
|
+
key, role = label.split(":", 2)
|
|
83
|
+
|
|
84
|
+
if role.nil?
|
|
85
|
+
group = Group.find_by(key: key) || raise(Refused, "there is no group keyed #{key}")
|
|
86
|
+
group.add!(actor, by: by)
|
|
87
|
+
else
|
|
88
|
+
organization = Organization.active.find_by(key: key) || raise(Refused, "there is no organization keyed #{key}")
|
|
89
|
+
held = organization.memberships.find_by(actor: actor)
|
|
90
|
+
held = held.destroy! && nil if held&.pending?
|
|
91
|
+
|
|
92
|
+
if held.nil?
|
|
93
|
+
Members.enroll!(organization, actor, role: role, by: by)
|
|
94
|
+
elsif held.role != role
|
|
95
|
+
Members.assign!(held, role: role, by: by)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
rescue Members::Refused => e
|
|
99
|
+
raise Refused, e.message
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -30,6 +30,7 @@ module Masks
|
|
|
30
30
|
has_many :approvals, class_name: "Client", foreign_key: :approved_by_id, dependent: :nullify
|
|
31
31
|
has_one :avatar, dependent: :destroy
|
|
32
32
|
has_many :group_members, dependent: :delete_all
|
|
33
|
+
has_many :access_requests, dependent: :delete_all
|
|
33
34
|
has_many :groups, through: :group_members
|
|
34
35
|
|
|
35
36
|
before_destroy :sign_out_everywhere!, prepend: true
|
|
@@ -61,6 +62,7 @@ module Masks
|
|
|
61
62
|
after_save :release_previous_nickname, if: :saved_change_to_nickname?
|
|
62
63
|
before_save :forget_code_factors_for_new_addresses
|
|
63
64
|
after_update :forget_mailed_links, if: :saved_change_to_email?
|
|
65
|
+
after_commit :settle_sourced_groups, on: %i[create update], if: -> { saved_changes.keys.intersect?(Group::WATCHED) }
|
|
64
66
|
|
|
65
67
|
normalizes :nickname, with: ->(value) { value.to_s.strip.presence }
|
|
66
68
|
normalizes :email, with: ->(value) { value.to_s.strip.downcase.presence }
|
|
@@ -469,6 +471,10 @@ module Masks
|
|
|
469
471
|
|
|
470
472
|
private
|
|
471
473
|
|
|
474
|
+
def settle_sourced_groups
|
|
475
|
+
Group.ruled.find_each { |group| group.settle!(self) }
|
|
476
|
+
end
|
|
477
|
+
|
|
472
478
|
def forget_mailed_links
|
|
473
479
|
[ PasswordReset, Invitation, EmailVerification ].each do |kind|
|
|
474
480
|
kind.where(actor_id: id).live.find_each(&:consume!)
|