Class: Gitlab::Audit::NullAuthor
- Inherits:
-
Object
- Object
- Gitlab::Audit::NullAuthor
- Defined in:
- lib/gitlab/audit/null_author.rb
Direct Known Subclasses
CiRunnerTokenAuthor, DeletedAuthor, DeployKeyAuthor, DeployTokenAuthor, UnauthenticatedAuthor
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.for(id, audit_event) ⇒ Gitlab::Audit::UnauthenticatedAuthor, ...
Creates an Author.
Instance Method Summary collapse
- #current_sign_in_ip ⇒ Object
- #full_path ⇒ Object
- #impersonated? ⇒ Boolean
-
#initialize(id:, name:) ⇒ NullAuthor
constructor
A new instance of NullAuthor.
- #to_global_id ⇒ Object
Constructor Details
#initialize(id:, name:) ⇒ NullAuthor
Returns a new instance of NullAuthor.
37 38 39 40 |
# File 'lib/gitlab/audit/null_author.rb', line 37 def initialize(id:, name:) @id = id @name = name end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/gitlab/audit/null_author.rb', line 6 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/gitlab/audit/null_author.rb', line 6 def name @name end |
Class Method Details
.for(id, audit_event) ⇒ Gitlab::Audit::UnauthenticatedAuthor, ...
Creates an Author
While tracking events that could take place even when a user is not logged in, (eg: downloading repo of a public project), we set the author_id of such events as -1
rubocop: disable Layout/LineLength
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gitlab/audit/null_author.rb', line 18 def self.for(id, audit_event) name = audit_event[:author_name] || audit_event.details[:author_name] if audit_event.target_type == ::Ci::Runner.name Gitlab::Audit::CiRunnerTokenAuthor.new( entity_type: audit_event.entity_type, entity_path: audit_event.entity_path, **audit_event.details.slice(:runner_authentication_token, :runner_registration_token).symbolize_keys ) elsif id == -1 Gitlab::Audit::UnauthenticatedAuthor.new(name: name) elsif id == -2 Gitlab::Audit::DeployTokenAuthor.new(name: name) elsif id == -3 Gitlab::Audit::DeployKeyAuthor.new(name: name) else Gitlab::Audit::DeletedAuthor.new(id: id, name: name) end end |
Instance Method Details
#current_sign_in_ip ⇒ Object
46 47 48 |
# File 'lib/gitlab/audit/null_author.rb', line 46 def current_sign_in_ip nil end |
#full_path ⇒ Object
50 51 52 |
# File 'lib/gitlab/audit/null_author.rb', line 50 def full_path nil end |
#impersonated? ⇒ Boolean
54 55 56 |
# File 'lib/gitlab/audit/null_author.rb', line 54 def impersonated? false end |
#to_global_id ⇒ Object
42 43 44 |
# File 'lib/gitlab/audit/null_author.rb', line 42 def to_global_id "gid://gitlab/ComplianceManagement::NullAuthor/@id" end |