Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
e3aaa56c
Commit
e3aaa56c
authored
Jul 24, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce PolicyCheckable for checking policies
parent
3f14c56b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
4 deletions
+38
-4
app/models/deploy_token.rb
app/models/deploy_token.rb
+1
-4
app/policies/concerns/policy_checkable.rb
app/policies/concerns/policy_checkable.rb
+36
-0
config/application.rb
config/application.rb
+1
-0
No files found.
app/models/deploy_token.rb
View file @
e3aaa56c
class
DeployToken
<
ActiveRecord
::
Base
include
Expirable
include
TokenAuthenticatable
include
PolicyCheckable
add_authentication_token_field
:token
AVAILABLE_SCOPES
=
%i(read_repository read_registry)
.
freeze
...
...
@@ -58,10 +59,6 @@ class DeployToken < ActiveRecord::Base
write_attribute
(
:expires_at
,
value
.
presence
||
Forever
.
date
)
end
def
admin?
false
end
private
def
ensure_at_least_one_scope
...
...
app/policies/concerns/policy_checkable.rb
0 → 100644
View file @
e3aaa56c
# frozen_string_literal: true
# Include this module if we want to pass something else than the user to
# check policies. This defines several methods which the policy checker
# would call and check.
module
PolicyCheckable
extend
ActiveSupport
::
Concern
def
blocked?
false
end
def
admin?
false
end
def
external?
false
end
def
internal?
false
end
def
access_locked?
false
end
def
required_terms_not_accepted?
false
end
def
can_create_group
false
end
end
config/application.rb
View file @
e3aaa56c
...
...
@@ -43,6 +43,7 @@ module Gitlab
#{
config
.
root
}
/app/models/members
#{
config
.
root
}
/app/models/project_services
#{
config
.
root
}
/app/workers/concerns
#{
config
.
root
}
/app/policies/concerns
#{
config
.
root
}
/app/services/concerns
#{
config
.
root
}
/app/serializers/concerns
#{
config
.
root
}
/app/finders/concerns
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment