Class: Ci::JobToken::Scope

Inherits:
Object
  • Object
show all
Defined in:
app/models/ci/job_token/scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_project) ⇒ Scope

Returns a new instance of Scope.



23
24
25
# File 'app/models/ci/job_token/scope.rb', line 23

def initialize(current_project)
  @current_project = current_project
end

Instance Attribute Details

#current_projectObject (readonly)

Returns the value of attribute current_project.



21
22
23
# File 'app/models/ci/job_token/scope.rb', line 21

def current_project
  @current_project
end

Instance Method Details

#accessible?(accessed_project) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
# File 'app/models/ci/job_token/scope.rb', line 27

def accessible?(accessed_project)
  self_referential?(accessed_project) || (
    outbound_accessible?(accessed_project) &&
    inbound_accessible?(accessed_project)
  )
end

#add!(added_project, user:, direction:) ⇒ Object



42
43
44
45
46
47
48
49
# File 'app/models/ci/job_token/scope.rb', line 42

def add!(added_project, user:, direction:)
  case direction
  when :inbound
    inbound_allowlist.add!(added_project, user: user)
  when :outbound
    outbound_allowlist.add!(added_project, user: user)
  end
end

#inbound_projectsObject



38
39
40
# File 'app/models/ci/job_token/scope.rb', line 38

def inbound_projects
  inbound_allowlist.projects
end

#outbound_projectsObject



34
35
36
# File 'app/models/ci/job_token/scope.rb', line 34

def outbound_projects
  outbound_allowlist.projects
end