virtuatable-core 1.3.0 → 1.5.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: 13712af3f0db1598191b3a51bb599c93f512da5e074ef504288dc498f45602a4
4
- data.tar.gz: c886c91f0698d97ebcfe6c0538ed35023e2472b03db28d625745794ac4a18c05
3
+ metadata.gz: d95c03cd13525c1a5326004d88c62a806c0e991ef8dd0766f0f2465078f2b23e
4
+ data.tar.gz: d217b7fd979676aa8b61cd58fb8ad54a3abd352fe105713700c12edc39abfdd6
5
5
  SHA512:
6
- metadata.gz: eec95c84abcc9093600b0d3d73279924e6d77095e246fad33a513868aaac08798dd2c4dc850406d47a93810deed2bc6750d0fd0f8349cbffaf72815223ab3280
7
- data.tar.gz: c798211dda3d35be799be2ef21589a67e86dc1d646f6168e6f39d8ed4bc458b1a6418cecf04f15311e681cd41efd48d7fb5497f0e85baf11287196f2ba6a77c1
6
+ metadata.gz: 4c180ac1d407073cc75d81a8d08f9394ef6d025cb899c4971a94ee6daa213ca5bcf4d240bd491b2374c60c7e2abfab80729226af37b0b7bdc60c0d7c3b2af326
7
+ data.tar.gz: d2c695ecb5ad843dc18789f84e6028bde42fb74949351f9f3308018d2c57cd29ef87a9ecc1d2cc8b4cf29a87c6ac73eab12b29177c32c6f0ba915798bc24bbd3
@@ -13,8 +13,9 @@ module Core
13
13
  # Includes the custom errors throwers and responses helpers.
14
14
  include Core::Helpers::Errors
15
15
  include Core::Helpers::Responses
16
- # Includes the checking methods for sessions.
17
- include Core::Helpers::Sessions
16
+ # Includes the checking methods for access tokens.
17
+ include Core::Helpers::Tokens
18
+ include Core::Helpers::Scopes
18
19
  # Include the checkers and getters for OAuth apps
19
20
  include Core::Helpers::Applications
20
21
  # Include checkers for field requirement and check
@@ -0,0 +1,20 @@
1
+ module Core
2
+ module Decorators
3
+ class Campaign < Draper::Decorator
4
+ delegate_all
5
+
6
+ def to_simple_h
7
+ {
8
+ id: id.to_s,
9
+ title: title,
10
+ description: description,
11
+ tags: tags,
12
+ players: {
13
+ current: invitations.where(status: :accepted).count,
14
+ max: max_players
15
+ }
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Core
2
+ module Decorators
3
+ autoload :Campaign, 'core/decorators/campaign'
4
+ end
5
+ end
@@ -10,8 +10,8 @@ module Core
10
10
  def account
11
11
  return @account unless @account.nil?
12
12
 
13
- session_id_required if !respond_to?(:session) || session.nil?
14
- @account = session.account
13
+ @account = token.authorization.account
14
+ @account
15
15
  end
16
16
 
17
17
  def account_id_not_found
@@ -6,9 +6,6 @@ module Core
6
6
  # to declare routes whithin a service, performing needed checks and filters.
7
7
  # @author Vincent Courtois <courtois.vincent@outlook.com>
8
8
  module Declarators
9
- # @!attribute [r] routes
10
- # @return [Array<Core::Models::Permissions::Route>] the currently declared routes.
11
- attr_reader :api_routes
12
9
 
13
10
  # Main method to declare new routes, persisting them in the database and
14
11
  # declaring it in the Sinatra application with the needed before checks.
@@ -16,68 +13,15 @@ module Core
16
13
  # @param verb [String] the HTTP method for the route.
17
14
  # @param path [String] the whole URI with parameters for the route.
18
15
  # @param options [Hash] the additional options for the route.
19
- def api_route(verb, path, options: {}, &block)
20
- options = default_options.merge(options)
21
- route = add_route(verb: verb, path: path, options: options)
22
-
23
- # TODO : do everything in the #send itself to avoid
24
- # route reload issues when premium is changed. It will
25
- # add some treatments but avoid many problems if route.premium
26
- send(route.verb, route.path) do
27
- application(premium: current_route.premium)
28
- session if current_route.authenticated
16
+ def api_route(verb, path, premium: false, scopes: [], &block)
17
+ send(verb, path) do
18
+ scope_objects = fetch_scopes(scopes + ['data::usage'])
19
+ appli = application(premium: premium)
20
+ check_app_scopes(appli, scope_objects)
21
+ check_token_scopes(token, scope_objects)
29
22
  instance_eval(&block)
30
23
  end
31
24
  end
32
-
33
- # Add a route to the database, then to the routes array.
34
- # @param verb [String] the HTTP method used to request this route.
35
- # @param path [String] the path used to request this route.
36
- # @return [Core::Models::Permissions::Route] the created route.
37
- def add_route(verb:, path:, options:)
38
- route = Core::Models::Permissions::Route.find_or_create_by!(
39
- path: path,
40
- verb: verb.downcase,
41
- premium: options[:premium],
42
- authenticated: options[:authenticated]
43
- )
44
- api_routes.nil? ? @api_routes = [route] : push_route(route)
45
- add_permissions(route)
46
- route
47
- end
48
-
49
- # Pushes the route in the api routes list, by creating it if needed
50
- # @param route [Core::Models::Permissions::Route] the route to push in the list of routes.
51
- def push_route(route)
52
- @api_routes << route if api_routes.none? do |tmp_route|
53
- route.id == tmp_route.id
54
- end
55
- end
56
-
57
- # Add the default access permissions to a route. Any group tagged superuser
58
- # can automatically access any newly declared_route.
59
- # params route [Core::Models::Permissions::Route] the route to add the permissions to.
60
- def add_permissions(route)
61
- groups = Core::Models::Permissions::Group.where(is_superuser: true)
62
- groups.each do |group|
63
- unless route.groups.where(id: group.id).exists?
64
- route.groups << group
65
- route.save!
66
- end
67
- end
68
- end
69
-
70
- # The default options for a route, being the most used value for each key.
71
- # @return [Hash] the default options as a hash.
72
- def default_options
73
- {
74
- # If TRUE the application MUST be premium to access the route.
75
- # Mainly used to protect administration routes against illegal accesses.
76
- premium: false,
77
- # If TRUE the user MUST be authenticated to access the route.
78
- authenticated: true
79
- }
80
- end
81
25
  end
82
26
  end
83
27
  end
@@ -0,0 +1,22 @@
1
+ module Core
2
+ module Helpers
3
+ module Scopes
4
+
5
+ def fetch_scopes(names)
6
+ (names.map { |n| Core::Models::OAuth::Scope.find_by(name: n) }).select { |s| !s.nil? }
7
+ end
8
+
9
+ def check_token_scopes(token, scopes)
10
+ scopes.each do |scope|
11
+ api_forbidden 'scope.forbidden' if !token.scopes.include? scope
12
+ end
13
+ end
14
+
15
+ def check_app_scopes(application, scopes)
16
+ scopes.each do |scope|
17
+ api_forbidden 'scope.forbidden' if !application.scopes.include? scope
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Core
4
+ module Helpers
5
+ # This helper aims at providing vanity methods concerning OAuth tokens.
6
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
7
+ module Tokens
8
+ # Returns the database object representing the current OAuth token, or
9
+ # raises an error if the token seems to be invalid for any reason.
10
+ # @return [Core::Models::Oauth::AccessToken] the token if everything went well.
11
+ # @raise [Core::Helpers::Errors::BadRequest] if the token is not given.
12
+ # @raise [Core::Helpers::Errors::NotFound] if the token is not found in the
13
+ # database searching for the value passed as parameter.
14
+ # @raise [Core::Helpers::Errors::Forbidden] if the token belongs to another
15
+ # application.
16
+ def token
17
+ return @token unless @token.nil?
18
+
19
+ check_presence 'token'
20
+ @token = Core::Models::OAuth::AccessToken.find_by(value: params['token'])
21
+ api_not_found 'token.unknown' if @token.nil?
22
+ token_app_id = token.authorization.application.id.to_s
23
+ api_forbidden 'token.mismatch' if token_app_id != application.id.to_s
24
+ @token
25
+ end
26
+ end
27
+ end
28
+ end
data/lib/core/helpers.rb CHANGED
@@ -13,6 +13,7 @@ module Core
13
13
  autoload :Parameters, 'core/helpers/parameters'
14
14
  autoload :Responses, 'core/helpers/responses'
15
15
  autoload :Routes, 'core/helpers/routes'
16
- autoload :Sessions, 'core/helpers/sessions'
16
+ autoload :Scopes, 'core/helpers/scopes'
17
+ autoload :Tokens, 'core/helpers/tokens'
17
18
  end
18
19
  end
@@ -37,10 +37,6 @@ module Core
37
37
  # @!attribute [w] password_confirmation
38
38
  # @return [String] the confirmation of the password, do not get, just set it ; it must be the same as the password.
39
39
  has_secure_password validations: false
40
-
41
- # @!attribute [rw] groups
42
- # @return [Array<Core::Models::Permissions::Group>] the groups giving their corresponding rights to the current account.
43
- has_and_belongs_to_many :groups, class_name: 'Core::Models::Permissions::Group', inverse_of: :accounts
44
40
 
45
41
  # @!attribute [rw] applications
46
42
  # @return [Array<Core::Models::OAuth::Application] the applications this user has created and owns.
@@ -8,7 +8,7 @@ module Core
8
8
  include Mongoid::Document
9
9
  include Mongoid::Timestamps
10
10
 
11
- store_in collection: 'oauth_access_token'
11
+ store_in collection: 'oauth_access_tokens'
12
12
 
13
13
  # @!attribute [rw] value
14
14
  # @return [String] the value of the token, returned to the application when built.
@@ -7,7 +7,7 @@ module Core
7
7
  include Mongoid::Document
8
8
  include Mongoid::Timestamps
9
9
 
10
- store_in collection: 'oauth_application'
10
+ store_in collection: 'oauth_applications'
11
11
 
12
12
  # @!attribute [rw] name
13
13
  # @return [String] the unique name of the application, mainly used to identify and display it.
@@ -10,7 +10,7 @@ module Core
10
10
  include Mongoid::Document
11
11
  include Mongoid::Timestamps
12
12
 
13
- store_in collection: 'oauth_authorization'
13
+ store_in collection: 'oauth_authorizations'
14
14
 
15
15
  # @!attribute [rw] code
16
16
  # @return [String] the value corresponding to the authentication code in the RFC of OAuth2.0, kep for historic purpose.
@@ -7,7 +7,7 @@ module Core
7
7
  include Mongoid::Document
8
8
  include Mongoid::Timestamps
9
9
 
10
- store_in collection: 'oauth_refresh_token'
10
+ store_in collection: 'oauth_refresh_tokens'
11
11
 
12
12
  # @!attribute [rw] value
13
13
  # @return [String] the value of the token, returned to the application when built.
@@ -8,7 +8,7 @@ module Core
8
8
  include Mongoid::Document
9
9
  include Mongoid::Timestamps
10
10
 
11
- store_in collection: 'scopes'
11
+ store_in collection: 'oauth_scopes'
12
12
 
13
13
  # @!attribute [rw] name
14
14
  # @return [String] the name of the scope, used to get its translation on the frontend.
data/lib/core/models.rb CHANGED
@@ -16,7 +16,6 @@ module Core
16
16
  autoload :Files, 'core/models/files'
17
17
  autoload :Notification, 'core/models/notification'
18
18
  autoload :OAuth, 'core/models/oauth'
19
- autoload :Permissions, 'core/models/permissions'
20
19
  autoload :Ruleset, 'core/models/ruleset'
21
20
  end
22
21
  end
@@ -1,6 +1,8 @@
1
1
  module Core
2
2
  module Services
3
- class Accounts < Core::Services::Base
3
+ class Accounts
4
+ include Singleton
5
+
4
6
  def get_by_username(username)
5
7
  account = Core::Models::Account.find_by(username: username)
6
8
  if account.nil?
@@ -0,0 +1,26 @@
1
+ module Core
2
+ module Services
3
+ class Campaigns
4
+ include Singleton
5
+
6
+ # Lists all the campaigns of a user identified by its account.
7
+ #
8
+ # @param account [Core::Models::Account] the user requesting its campaigns.
9
+ # @param page [Integer] the page in the list of campaigns to return to the users.
10
+ # @param per_page [Integer] the number of campaigns per page.
11
+ #
12
+ # @return [Array<Hash>] an array of hash representing campaigns.
13
+ def list(account, page: 0, per_page: 20, **ignored)
14
+ campaigns = campaigns(account).skip(page * per_page).limit(per_page)
15
+ campaigns.map do |campaign|
16
+ Core::Decorators::Campaign.new(campaign).to_simple_h
17
+ end
18
+ end
19
+
20
+ def campaigns(account)
21
+ invitations = account.invitations.where(enum_status: 'creator')
22
+ Core::Models::Campaign.where(:id.in => invitations.map(&:campaign_id))
23
+ end
24
+ end
25
+ end
26
+ end
@@ -3,12 +3,14 @@ module Core
3
3
  # The registry holds references to all the services accessible in the library. To access
4
4
  # all services and be able to manage resources easily, just instanciate the
5
5
  class Registry
6
+ include Singleton
6
7
 
7
- attr_reader :accounts, :sessions
8
+ attr_reader :accounts, :sessions, :campaigns
8
9
 
9
10
  def initialize
10
- @accounts = Core::Services::Accounts.new(self)
11
- @sessions = Core::Services::Sessions.new(self)
11
+ @accounts = Core::Services::Accounts.instance
12
+ @sessions = Core::Services::Sessions.instance
13
+ @campaigns = Core::Services::Campaigns.instance
12
14
  end
13
15
  end
14
16
  end
@@ -5,7 +5,8 @@ module Core
5
5
  module Services
6
6
  # Service concerning sessions (log in and log out)
7
7
  # @author Vincent Courtois <courtois.vincent@outlook.com>
8
- class Sessions < Core::Services::Base
8
+ class Sessions
9
+ include Singleton
9
10
  # Creates a new session from the given user credentials. IT will
10
11
  # * check that the user exists in the database
11
12
  # * check that the password matches the user encrypted password
@@ -16,7 +17,7 @@ module Core
16
17
  # @param password [string] the password the user has provided
17
18
  # @return [Core::Models::Authentication::Session] the login session
18
19
  def create(username, password)
19
- account = services.accounts.get_by_username(username)
20
+ account = Core.svc.accounts.get_by_username(username)
20
21
  if BCrypt::Password.new(account.password_digest) != password
21
22
  raise Core::Helpers::Errors::Forbidden.new(
22
23
  field: 'password',
data/lib/core/services.rb CHANGED
@@ -5,8 +5,8 @@ module Core
5
5
  # @author Vincent Courtois <courtois.vincent@outlook.com>
6
6
  module Services
7
7
  autoload :Accounts, 'core/services/accounts'
8
- autoload :Base, 'core/services/base'
9
8
  autoload :Registry, 'core/services/registry'
10
9
  autoload :Sessions, 'core/services/sessions'
10
+ autoload :Campaigns, 'core/services/campaigns'
11
11
  end
12
12
  end
data/lib/core/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Core
4
- VERSION = '1.3.0'
4
+ VERSION = '1.5.0'
5
5
  end
data/lib/core.rb CHANGED
@@ -1,12 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- %w[active_model mongoid active_support].each { |g| require g }
3
+ %w[active_model mongoid active_support draper].each { |g| require g }
4
4
 
5
5
  # Main module of the application, holding all the subsequent classes.
6
6
  # @author Vincent Courtois <courtois.vincent@outlook.com>
7
7
  module Core
8
8
  autoload :Controllers, 'core/controllers'
9
+ autoload :Decorators, 'core/decorators'
9
10
  autoload :Helpers, 'core/helpers'
10
11
  autoload :Models, 'core/models'
11
12
  autoload :Services, 'core/services'
13
+
14
+ # Returns the registry of services for easier access to each of them.
15
+ def self.svc
16
+ Core::Services::Registry.instance
17
+ end
12
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtuatable-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Courtois
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-24 00:00:00.000000000 Z
11
+ date: 2022-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: database_cleaner
@@ -276,6 +276,20 @@ dependencies:
276
276
  - - '='
277
277
  - !ruby/object:Gem::Version
278
278
  version: 2.1.0
279
+ - !ruby/object:Gem::Dependency
280
+ name: draper
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - ">="
284
+ - !ruby/object:Gem::Version
285
+ version: '0'
286
+ type: :runtime
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - ">="
291
+ - !ruby/object:Gem::Version
292
+ version: '0'
279
293
  description: This gem holds the model layer for my table-top RPG games application.
280
294
  email: courtois.vincent@outlook.com
281
295
  executables: []
@@ -285,6 +299,8 @@ files:
285
299
  - lib/core.rb
286
300
  - lib/core/controllers.rb
287
301
  - lib/core/controllers/base.rb
302
+ - lib/core/decorators.rb
303
+ - lib/core/decorators/campaign.rb
288
304
  - lib/core/helpers.rb
289
305
  - lib/core/helpers/accounts.rb
290
306
  - lib/core/helpers/applications.rb
@@ -298,7 +314,8 @@ files:
298
314
  - lib/core/helpers/parameters.rb
299
315
  - lib/core/helpers/responses.rb
300
316
  - lib/core/helpers/routes.rb
301
- - lib/core/helpers/sessions.rb
317
+ - lib/core/helpers/scopes.rb
318
+ - lib/core/helpers/tokens.rb
302
319
  - lib/core/models.rb
303
320
  - lib/core/models/account.rb
304
321
  - lib/core/models/authentication.rb
@@ -333,15 +350,10 @@ files:
333
350
  - lib/core/models/oauth/authorization.rb
334
351
  - lib/core/models/oauth/refresh_token.rb
335
352
  - lib/core/models/oauth/scope.rb
336
- - lib/core/models/permissions.rb
337
- - lib/core/models/permissions/category.rb
338
- - lib/core/models/permissions/group.rb
339
- - lib/core/models/permissions/right.rb
340
- - lib/core/models/permissions/route.rb
341
353
  - lib/core/models/ruleset.rb
342
354
  - lib/core/services.rb
343
355
  - lib/core/services/accounts.rb
344
- - lib/core/services/base.rb
356
+ - lib/core/services/campaigns.rb
345
357
  - lib/core/services/registry.rb
346
358
  - lib/core/services/sessions.rb
347
359
  - lib/core/version.rb
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Core
4
- module Helpers
5
- # This helper gives access to methods about user's session on the API.
6
- # @author Vincent Courtois <courtois.vincent@outlook.com>
7
- module Sessions
8
- # Checks the session of the user requesting the API and returns an error
9
- # if it either not exists with the given token, or the token is not given.
10
- #
11
- # @raise [Virtuatable::API::Errors::NotFound] if the session is not found
12
- # or the token not given in the parameters of the request.
13
- # @raise [Virtuatable::API::Errors::BadRequest] if the session token is
14
- # not correctly given in the parameters.
15
- #
16
- # @return [Core::Models::Authentication::Session] the current session of the user.
17
- def session
18
- return @session unless @session.nil?
19
-
20
- check_presence 'session_id'
21
- @session = session_model.find_by(token: params['session_id'])
22
- @session.nil? ? api_not_found('session_id.unknown') : @session
23
- end
24
-
25
- def session_model
26
- Core::Models::Authentication::Session
27
- end
28
- end
29
- end
30
- end
@@ -1,17 +0,0 @@
1
- module Core
2
- module Models
3
- module Permissions
4
- # A category of rights regroups one or several rights for convenience purposes.
5
- # @author Vincent Courtois <courtois.vincent@outlook.com>
6
- class Category
7
- include Mongoid::Document
8
- include Mongoid::Timestamps
9
- include Core::Models::Concerns::Sluggable
10
-
11
- store_in collection: 'categories'
12
-
13
- has_many :rights, class_name: 'Core::Models::Permissions::Right', inverse_of: :category
14
- end
15
- end
16
- end
17
- end
@@ -1,32 +0,0 @@
1
- module Core
2
- module Models
3
- module Permissions
4
- # A group gathers one or several users to give them the same rights for conviniency purposes.
5
- # @author Vincent Courtois <courtois.vincent@outlook.com>
6
- class Group
7
- include Mongoid::Document
8
- include Mongoid::Timestamps
9
- include Core::Models::Concerns::Sluggable
10
-
11
- store_in collection: 'groups'
12
-
13
- # @!attribute [rw] is_default
14
- # @return [Boolean] a boolean indicating whether this group is given when a new user registered or not.
15
- field :is_default, type: Mongoid::Boolean, default: false
16
- # @!attribute [rw] is_superuser
17
- # @return [Boolean] a boolean indicating whether this group should have access to all groups and rights or not.
18
- field :is_superuser, type: Mongoid::Boolean, default: false
19
-
20
- # @!attribute [rw] accounts
21
- # @return [Array<Core::Models::Account>] the accounts having the rights granted by this group.
22
- has_and_belongs_to_many :accounts, class_name: 'Core::Models::Account', inverse_of: :groups
23
- # @!attribute [rw] rights
24
- # @return [Array<Core::Models::Permissions::Right>] the rights granted by belonging to this group.
25
- has_and_belongs_to_many :rights, class_name: 'Core::Models::Permissions::Right', inverse_of: :groups
26
- # @!attribute [rw] routes
27
- # @return [Array<Core::Models::Monitoring::Route>] the routes this group can access in the API.
28
- has_and_belongs_to_many :routes, class_name: 'Core::Models::Permissions::Route', inverse_of: :groups
29
- end
30
- end
31
- end
32
- end
@@ -1,21 +0,0 @@
1
- module Core
2
- module Models
3
- module Permissions
4
- # A right is the access to one or several features in the application. It's applied to a group, and transitively to an account.
5
- # @author Vincent Courtois <courtois;vincent@outlook.com>
6
- class Right
7
- include Mongoid::Document
8
- include Mongoid::Timestamps
9
- include Core::Models::Concerns::Sluggable
10
-
11
- store_in collection: 'rights'
12
-
13
- # @!attribute [rw] groups
14
- # @return [Array<Core::Models::Permissions::Group>] the groups granted with the permission to access features opened by this right.
15
- has_and_belongs_to_many :groups, class_name: 'Core::Models::Permissions::Group', inverse_of: :rights
16
-
17
- belongs_to :category, class_name: 'Core::Models::Permissions::Category', inverse_of: :rights
18
- end
19
- end
20
- end
21
- end
@@ -1,35 +0,0 @@
1
- module Core
2
- module Models
3
- module Permissions
4
- # A route is an endpoint accessible in the API. Each route has to have an associated endpoint in the deployed instances.
5
- # @param Vincent Courtois <courtois.vincent@outlook.com>
6
- class Route
7
- include Mongoid::Document
8
- include Mongoid::Timestamps
9
- include Core::Models::Concerns::Premiumable
10
- include Core::Models::Concerns::Activable
11
-
12
- store_in collection: 'routes'
13
-
14
- # @!attribute [rw] path
15
- # @return [String] the path (URI) of the route in the API.
16
- field :path, type: String, default: '/'
17
- # @!attribute [rw] verb
18
- # @return [String] the verb (HTTP method) of this route in the API.
19
- field :verb, type: String, default: 'get'
20
- # @!attribute [rw] authenticated
21
- # @return [Boolean] if true, the session_id is needed for this route, if false it is not.
22
- field :authenticated, type: Mongoid::Boolean, default: true
23
- # @!attribute [rw] groups
24
- # @return [Array<Core::Models::Permissions::Group>] the groups having permission to access this route.
25
- has_and_belongs_to_many :groups, class_name: 'Core::Models::Permissions::Group', inverse_of: :groups
26
-
27
- validates :path,
28
- format: {with: /\A(\/|((\/:?[a-zA-Z0-9_]+)+))\z/, message: 'pattern', if: :path?}
29
-
30
- validates :verb,
31
- inclusion: {message: 'unknown', in: ['get', 'post', 'put', 'delete', 'patch', 'option']}
32
- end
33
- end
34
- end
35
- end
@@ -1,13 +0,0 @@
1
- module Core
2
- module Models
3
- # This module holds the logic for all the classes concerning the permissions abd rights for the user.
4
- # A permission is restricting the access to one or several features to the users having it.
5
- # @author Vincent Courtois <courtois.vincent@outlook.com>
6
- module Permissions
7
- autoload :Right , 'core/models/permissions/right'
8
- autoload :Group , 'core/models/permissions/group'
9
- autoload :Category, 'core/models/permissions/category'
10
- autoload :Route , 'core/models/permissions/route'
11
- end
12
- end
13
- end
@@ -1,11 +0,0 @@
1
- module Core
2
- module Services
3
- class Base
4
- attr_reader :services
5
-
6
- def initialize(registry)
7
- @services = registry
8
- end
9
- end
10
- end
11
- end