atomic_admin 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1da63f4d8a28afb38eb29f1cd355f7bf60ce16c3dc242db8d7466124a9675012
|
4
|
+
data.tar.gz: 77291046495aaec1f9952da7fc91d4e7760f99cb0f28c70b3bf2f57d7798d493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5402d08f0cd92d4721ace8bc07bc30a110153b5a13c9d69dfe85f5a779b5149df32143819f5daec659e5a7f11a1443429be783581dfe9e5dc6588e962e0dacd0
|
7
|
+
data.tar.gz: 4411b3bd84e9e0d22181a449debeb5f9d814220a6412c4e83e98ca935f715a8076a1059be06a2158ca03126c4cee79cb578dc3a58ddf5fe0f7db275acebb015d
|
@@ -2,15 +2,12 @@ module AtomicAdmin
|
|
2
2
|
class ApplicationController < ActionController::API
|
3
3
|
include AtomicAdmin::JwtToken
|
4
4
|
# before_action :authenticate_user! # Use validate_token instead for now
|
5
|
-
before_action :validate_admin_app_token
|
6
5
|
before_action :validate_token
|
7
6
|
before_action :only_admins!
|
8
7
|
|
9
8
|
private
|
10
9
|
|
11
10
|
def only_admins!
|
12
|
-
return if @admin_app_validated
|
13
|
-
|
14
11
|
user_not_authorized unless current_user.admin?
|
15
12
|
end
|
16
13
|
|
@@ -9,35 +9,38 @@ module AtomicAdmin
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def search
|
12
|
-
tenant_deployments = AtomicTenant::LtiDeployment
|
13
|
-
|
14
|
-
.
|
15
|
-
|
12
|
+
tenant_deployments = AtomicTenant::LtiDeployment.
|
13
|
+
where(application_instance_id: params[:application_instance_id]).
|
14
|
+
joins("LEFT OUTER JOIN public.atomic_lti_deployments"\
|
15
|
+
" ON atomic_tenant_lti_deployments.iss = atomic_lti_deployments.iss"\
|
16
|
+
" AND atomic_tenant_lti_deployments.deployment_id = atomic_lti_deployments.deployment_id").
|
17
|
+
order(:id).
|
18
|
+
paginate(page: params[:page], per_page: 30)
|
16
19
|
|
17
|
-
|
20
|
+
rows = tenant_deployments.pluck(
|
21
|
+
"atomic_tenant_lti_deployments.id",
|
22
|
+
"atomic_tenant_lti_deployments.iss",
|
23
|
+
"atomic_tenant_lti_deployments.deployment_id",
|
24
|
+
"atomic_tenant_lti_deployments.application_instance_id",
|
25
|
+
"atomic_lti_deployments.client_id",
|
26
|
+
"atomic_lti_deployments.platform_guid",
|
27
|
+
)
|
18
28
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
page = pairs.reduce([]) do |acc, pair|
|
30
|
-
iss = pair[0]
|
31
|
-
deployment_ids = pair[1]
|
32
|
-
|
33
|
-
deployments = AtomicLti.get_deployments(iss: iss, deployment_ids: deployment_ids)
|
34
|
-
acc.concat(deployments)
|
29
|
+
page = rows.map do |row|
|
30
|
+
{
|
31
|
+
id: row[0],
|
32
|
+
iss: row[1],
|
33
|
+
deployment_id: row[2],
|
34
|
+
application_instance_id: row[3],
|
35
|
+
client_id: row[4],
|
36
|
+
platform_guid: row[5],
|
37
|
+
}
|
35
38
|
end
|
36
39
|
|
37
40
|
render json: {
|
38
41
|
deployments: page,
|
39
42
|
page: params[:page],
|
40
|
-
total_pages: tenant_deployments.total_pages
|
43
|
+
total_pages: tenant_deployments.total_pages,
|
41
44
|
}
|
42
45
|
end
|
43
46
|
|
@@ -30,8 +30,6 @@ module AtomicAdmin
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def validate_token
|
33
|
-
return if @admin_app_validated
|
34
|
-
|
35
33
|
token = decoded_jwt_token(request)
|
36
34
|
raise InvalidTokenError if Rails.application.secrets.auth0_client_id != token["aud"]
|
37
35
|
|
@@ -52,16 +50,6 @@ module AtomicAdmin
|
|
52
50
|
raise GraphQL::ExecutionError, "Unauthorized: Invalid token."
|
53
51
|
end
|
54
52
|
end
|
55
|
-
|
56
|
-
def validate_admin_app_token
|
57
|
-
_bearer, jwt = request.headers['Authorization'].split(' ')
|
58
|
-
@atomic_admin_params = AtomicAdmin::JwtToken.decode(jwt, Rails.application.secrets.atomic_admin_shared_key)
|
59
|
-
@admin_app_validated = true
|
60
|
-
rescue JWT::DecodeError, InvalidTokenError => e
|
61
|
-
# fall back to regular app jwt
|
62
|
-
Rails.logger.error "JWT Error occured with admin app token #{e.inspect}"
|
63
|
-
@admin_app_validated = false
|
64
|
-
end
|
65
53
|
|
66
54
|
protected
|
67
55
|
|
@@ -78,4 +66,4 @@ module AtomicAdmin
|
|
78
66
|
end
|
79
67
|
|
80
68
|
end
|
81
|
-
end
|
69
|
+
end
|
data/lib/atomic_admin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atomic_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Benoit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
|
-
rubygems_version: 3.
|
74
|
+
rubygems_version: 3.3.7
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
77
|
summary: Engine to provide apis that power the atomic jolt admin app
|