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: 8ed8016c6474ebe66207d09ec1c66e42da12989c862dd1b7cdab433f8556b717
4
- data.tar.gz: f6e57e1aa7917a06ce6854c2edcf77310526a402f5f709d43462bd45936e2e6e
3
+ metadata.gz: 1da63f4d8a28afb38eb29f1cd355f7bf60ce16c3dc242db8d7466124a9675012
4
+ data.tar.gz: 77291046495aaec1f9952da7fc91d4e7760f99cb0f28c70b3bf2f57d7798d493
5
5
  SHA512:
6
- metadata.gz: 106d1dd8d2682945e602ac85eb5eab431f8fff57f83f9849e36a99c50b0cd462e50607afef5e2eb9889683b8009eef30db0ce6dca61bada38edd7f83d20983d0
7
- data.tar.gz: 8ddda300ce1e5d949349c8ac20802153236a3742bff41cff35ea31500fb5b5502606f0df544e2dfe006b766ba02e847d85fd2d74c845565cf135e3b32f890a82
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
- .where(application_instance_id: params[:application_instance_id])
14
- .order(:id)
15
- .paginate(page: params[:page], per_page: 30)
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
- page_ids = tenant_deployments.pluck(:iss, :deployment_id)
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
- pairs = page_ids.reduce({}) do |acc, c|
20
- iss = c[0]
21
- deployment_id = c[1]
22
-
23
- acc[iss] = [] if acc[iss].nil?
24
-
25
- acc[iss].push(deployment_id)
26
- acc
27
- end
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
@@ -1,3 +1,3 @@
1
1
  module AtomicAdmin
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.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: 2023-08-17 00:00:00.000000000 Z
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.4.15
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