virtuatable-core 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/core/controllers/base.rb +2 -4
- data/lib/core/helpers/applications.rb +6 -6
- data/lib/core/helpers/declarators.rb +6 -6
- data/lib/core/helpers/routes.rb +2 -2
- data/lib/core/helpers/sessions.rb +2 -2
- data/lib/core/models/campaign.rb +1 -1
- data/lib/core/models/chatrooms/message.rb +1 -1
- data/lib/core/models/concerns/activable.rb +1 -1
- data/lib/core/models/concerns/premiumable.rb +1 -1
- data/lib/core/models/concerns/sluggable.rb +9 -15
- data/lib/core/models/notification.rb +1 -1
- data/lib/core/models/oauth/access_token.rb +23 -0
- data/lib/core/models/oauth/application.rb +14 -5
- data/lib/core/models/oauth/authorization.rb +12 -0
- data/lib/core/models/oauth/refresh_token.rb +8 -1
- data/lib/core/models/oauth/scope.rb +32 -0
- data/lib/core/models/oauth.rb +1 -0
- data/lib/core/models/permissions/category.rb +0 -2
- data/lib/core/models/permissions/group.rb +2 -4
- data/lib/core/models/permissions/right.rb +0 -2
- data/lib/core/models/permissions/route.rb +1 -1
- data/lib/core/models.rb +17 -19
- data/lib/core/services.rb +5 -1
- data/lib/core/version.rb +4 -2
- data/lib/core.rb +4 -5
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13712af3f0db1598191b3a51bb599c93f512da5e074ef504288dc498f45602a4
|
4
|
+
data.tar.gz: c886c91f0698d97ebcfe6c0538ed35023e2472b03db28d625745794ac4a18c05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eec95c84abcc9093600b0d3d73279924e6d77095e246fad33a513868aaac08798dd2c4dc850406d47a93810deed2bc6750d0fd0f8349cbffaf72815223ab3280
|
7
|
+
data.tar.gz: c798211dda3d35be799be2ef21589a67e86dc1d646f6168e6f39d8ed4bc458b1a6418cecf04f15311e681cd41efd48d7fb5497f0e85baf11287196f2ba6a77c1
|
@@ -55,10 +55,8 @@ module Core
|
|
55
55
|
api_forbidden exception.message
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
api_error 500, "unknown_field.#{error.class.name}"
|
61
|
-
end
|
58
|
+
error StandardError do |error|
|
59
|
+
api_error 500, "unknown_field.#{error.class.name}"
|
62
60
|
end
|
63
61
|
end
|
64
62
|
end
|
@@ -6,20 +6,20 @@ module Core
|
|
6
6
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
7
7
|
module Applications
|
8
8
|
# Looks for the application sending the API's request, and raises error if not found.
|
9
|
-
# @param [
|
9
|
+
# @param [Core::Models::OAuth::Application] the application requesting the service.
|
10
10
|
def application(premium: false)
|
11
11
|
return @application unless @application.nil?
|
12
12
|
|
13
|
-
check_presence '
|
14
|
-
@application = application_model.find_by(
|
15
|
-
api_not_found '
|
16
|
-
api_forbidden '
|
13
|
+
check_presence 'client_id'
|
14
|
+
@application = application_model.find_by(client_id: params['client_id'])
|
15
|
+
api_not_found 'client_id.unknown' if @application.nil?
|
16
|
+
api_forbidden 'client_id.forbidden' if premium && !@application.premium
|
17
17
|
|
18
18
|
@application
|
19
19
|
end
|
20
20
|
|
21
21
|
def application_model
|
22
|
-
|
22
|
+
Core::Models::OAuth::Application
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -7,7 +7,7 @@ module Core
|
|
7
7
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
8
8
|
module Declarators
|
9
9
|
# @!attribute [r] routes
|
10
|
-
# @return [Array<
|
10
|
+
# @return [Array<Core::Models::Permissions::Route>] the currently declared routes.
|
11
11
|
attr_reader :api_routes
|
12
12
|
|
13
13
|
# Main method to declare new routes, persisting them in the database and
|
@@ -33,9 +33,9 @@ module Core
|
|
33
33
|
# Add a route to the database, then to the routes array.
|
34
34
|
# @param verb [String] the HTTP method used to request this route.
|
35
35
|
# @param path [String] the path used to request this route.
|
36
|
-
# @return [
|
36
|
+
# @return [Core::Models::Permissions::Route] the created route.
|
37
37
|
def add_route(verb:, path:, options:)
|
38
|
-
route =
|
38
|
+
route = Core::Models::Permissions::Route.find_or_create_by!(
|
39
39
|
path: path,
|
40
40
|
verb: verb.downcase,
|
41
41
|
premium: options[:premium],
|
@@ -47,7 +47,7 @@ module Core
|
|
47
47
|
end
|
48
48
|
|
49
49
|
# Pushes the route in the api routes list, by creating it if needed
|
50
|
-
# @param route [
|
50
|
+
# @param route [Core::Models::Permissions::Route] the route to push in the list of routes.
|
51
51
|
def push_route(route)
|
52
52
|
@api_routes << route if api_routes.none? do |tmp_route|
|
53
53
|
route.id == tmp_route.id
|
@@ -56,9 +56,9 @@ module Core
|
|
56
56
|
|
57
57
|
# Add the default access permissions to a route. Any group tagged superuser
|
58
58
|
# can automatically access any newly declared_route.
|
59
|
-
# params route [
|
59
|
+
# params route [Core::Models::Permissions::Route] the route to add the permissions to.
|
60
60
|
def add_permissions(route)
|
61
|
-
groups =
|
61
|
+
groups = Core::Models::Permissions::Group.where(is_superuser: true)
|
62
62
|
groups.each do |group|
|
63
63
|
unless route.groups.where(id: group.id).exists?
|
64
64
|
route.groups << group
|
data/lib/core/helpers/routes.rb
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
module Core
|
4
4
|
module Helpers
|
5
5
|
# This module provides the #current_route method to get the current
|
6
|
-
#
|
6
|
+
# Core::Models::Monitoring::Route object from whithin sinatra routes.
|
7
7
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
8
8
|
module Routes
|
9
9
|
# The currently requested API route, used to see inside the block
|
10
10
|
# if the route is premium or not, authenticated or not.
|
11
|
-
# @return [
|
11
|
+
# @return [Core::Models::Monitoring::Route] the currently requested route.
|
12
12
|
def current_route
|
13
13
|
splitted = request.env['sinatra.route'].split(' ')
|
14
14
|
verb = splitted.first.downcase
|
@@ -13,7 +13,7 @@ module Core
|
|
13
13
|
# @raise [Virtuatable::API::Errors::BadRequest] if the session token is
|
14
14
|
# not correctly given in the parameters.
|
15
15
|
#
|
16
|
-
# @return [
|
16
|
+
# @return [Core::Models::Authentication::Session] the current session of the user.
|
17
17
|
def session
|
18
18
|
return @session unless @session.nil?
|
19
19
|
|
@@ -23,7 +23,7 @@ module Core
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def session_model
|
26
|
-
|
26
|
+
Core::Models::Authentication::Session
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
data/lib/core/models/campaign.rb
CHANGED
@@ -16,7 +16,7 @@ module Core
|
|
16
16
|
field :description, type: String
|
17
17
|
# @!attribute [rw] is_private
|
18
18
|
# @return [Boolean] TRUE if the campaign can be joined only by being invited by the creator, FALSE if it's publicly displayed and accessible.
|
19
|
-
field :is_private, type: Boolean, default: true
|
19
|
+
field :is_private, type: Mongoid::Boolean, default: true
|
20
20
|
# @!attribute [rw] tags
|
21
21
|
# @return [Array<String>] an array of tags describing characteristics of this campaign.
|
22
22
|
field :tags, type: Array, default: []
|
@@ -21,7 +21,7 @@ module Core
|
|
21
21
|
field :raw, type: String, default: ''
|
22
22
|
# @!attribute [rw] deleted
|
23
23
|
# @return [Boolean] TRUE if the message has been marked as deleted by its user, FALSE otherwise.
|
24
|
-
field :deleted, type: Boolean, default: false
|
24
|
+
field :deleted, type: Mongoid::Boolean, default: false
|
25
25
|
|
26
26
|
# @!attribute [rw] campaign
|
27
27
|
# @return [Core::Models::Chatrooms::Campaign] the chatroom in which the message has been emitted.
|
@@ -9,7 +9,7 @@ module Core
|
|
9
9
|
included do
|
10
10
|
# @!attribute [rw] active
|
11
11
|
# @return [Boolean] the active status of the instance, indicating if someone has deactivated it or not.
|
12
|
-
field :active, type: Boolean, default: true
|
12
|
+
field :active, type: Mongoid::Boolean, default: true
|
13
13
|
|
14
14
|
scope :active , ->{ where(active: true) }
|
15
15
|
scope :inactive, ->{ where(active: false) }
|
@@ -9,7 +9,7 @@ module Core
|
|
9
9
|
included do
|
10
10
|
# @!attribute [rw] premium
|
11
11
|
# @return [Boolean] TRUE if the entity is made to be accessible only to premiuma pplications, FALSE otherwise.
|
12
|
-
field :premium, type: Boolean, default: false
|
12
|
+
field :premium, type: Mongoid::Boolean, default: false
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -6,22 +6,16 @@ module Core
|
|
6
6
|
module Sluggable
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# @param entity_type [String,Symbol] the name of the model including it, to be included in the error messages.
|
14
|
-
def make_sluggable(entity_type)
|
15
|
-
# @!attribute [rw] slug
|
16
|
-
# @return [String] the slug of the current entity ; it must be snake-cased, longer than four characters, unique for the entity and given.
|
17
|
-
field :slug, type: String
|
9
|
+
included do
|
10
|
+
# @!attribute [rw] slug
|
11
|
+
# @return [String] the slug of the current entity ; it must be snake-cased, longer than four characters, unique for the entity and given.
|
12
|
+
field :slug, type: String
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
14
|
+
validates :slug,
|
15
|
+
length: {minimum: 4, message: 'minlength', if: :slug?},
|
16
|
+
format: {with: /\A[a-z]+(_[a-z]+)*\z/, message: 'pattern', if: :slug?},
|
17
|
+
uniqueness: {message: 'uniq', if: :slug?},
|
18
|
+
presence: {message: 'required'}
|
25
19
|
end
|
26
20
|
end
|
27
21
|
end
|
@@ -11,7 +11,7 @@ module Core
|
|
11
11
|
field :type, type: String, default: 'NOTIFICATIONS.DEFAULT'
|
12
12
|
# @!attribute [rw] read
|
13
13
|
# @return [Boolean] TRUE if the notification has been read (seen by the user), FALSE otherwise.
|
14
|
-
field :read, type: Boolean, default: false
|
14
|
+
field :read, type: Mongoid::Boolean, default: false
|
15
15
|
# @!attribute [rw] data
|
16
16
|
# @return [Hash] the custom data that can be attached to this notification, for example for an invitation it can be the invited username.
|
17
17
|
field :data, type: Hash, default: {}
|
@@ -21,6 +21,12 @@ module Core
|
|
21
21
|
# @return [Core::Models::OAuth::Authorization] the authorization code that issued this token to the application for this user.
|
22
22
|
belongs_to :authorization, class_name: 'Core::Models::OAuth::Authorization', inverse_of: :tokens
|
23
23
|
|
24
|
+
|
25
|
+
# A refresh token is attached to each and every refresh token so that it can be used to deliver a new access token.
|
26
|
+
# @!attribute [rx] refresh_token
|
27
|
+
# @return [Core::Models::OAuth::RefreshToken] the refresh token linked to this token
|
28
|
+
has_one :refresh_token, class_name: 'Core::Models::OAuth::RefreshToken', inverse_of: :token
|
29
|
+
|
24
30
|
validates :value,
|
25
31
|
presence: {message: 'required'},
|
26
32
|
uniqueness: {message: 'uniq'}
|
@@ -28,8 +34,25 @@ module Core
|
|
28
34
|
# Checks if the current date is inferior to the creation date + expiration period
|
29
35
|
# @return [Boolean] TRUE if the token is expired, FALSE otherwise.
|
30
36
|
def expired?
|
37
|
+
# Handles the case where the token is given to a premium app (our apps have infinite tokens).
|
38
|
+
return false if premium?
|
39
|
+
return true if refresh_token.used?
|
40
|
+
|
31
41
|
created_at.to_time.to_i + expiration < Time.now.to_i
|
32
42
|
end
|
43
|
+
|
44
|
+
# Returns the scopes this access token can use to access the application
|
45
|
+
# @return [Array<Core::Models::OAuth::Scope>] the array of scopes from the linked authorization
|
46
|
+
def scopes
|
47
|
+
# Premium applications (our applications) have all the rights on the API.
|
48
|
+
return Core::Models::OAuth::Scope.all.to_a if premium?
|
49
|
+
|
50
|
+
authorization.scopes
|
51
|
+
end
|
52
|
+
|
53
|
+
def premium?
|
54
|
+
authorization.application.premium
|
55
|
+
end
|
33
56
|
end
|
34
57
|
end
|
35
58
|
end
|
@@ -12,12 +12,15 @@ module Core
|
|
12
12
|
# @!attribute [rw] name
|
13
13
|
# @return [String] the unique name of the application, mainly used to identify and display it.
|
14
14
|
field :name, type: String
|
15
|
-
# @!attribute [rw]
|
15
|
+
# @!attribute [rw] client_id
|
16
16
|
# @return [String] the unique key for the application, identifying it when requesting a token for the API.
|
17
|
-
field :
|
17
|
+
field :client_id, type: String, default: ->{ SecureRandom.hex }
|
18
|
+
# @!attribute [rw] client_secret
|
19
|
+
# @return [String] the "password" of the application, used to identify it when requesting tokens.
|
20
|
+
field :client_secret, type: String, default: ->{ SecureRandom.hex }
|
18
21
|
# @!attribute [rw] premium
|
19
22
|
# @return [Boolean] a value indicating whether the application should automatically receive a token when an account is created, or not.
|
20
|
-
field :premium, type: Boolean, default: false
|
23
|
+
field :premium, type: Mongoid::Boolean, default: false
|
21
24
|
# @!attirbute [rw] redirect_uris
|
22
25
|
# @return [Array<String>] the redirection URIs used for this application.
|
23
26
|
field :redirect_uris, type: Array, default: []
|
@@ -28,16 +31,22 @@ module Core
|
|
28
31
|
# @!attribute [rw] authorizations
|
29
32
|
# @return [Array<Core::Models::OAuth::Authorization>] the authorizations linked to the accounts this application can get the data from.
|
30
33
|
has_many :authorizations, class_name: 'Core::Models::OAuth::Authorization', inverse_of: :application
|
34
|
+
# @!attribute [rw]
|
35
|
+
# @return [Array<Core::Models::OAuth::Scope>] the scopes this application will transmit to its token
|
36
|
+
has_and_belongs_to_many :scopes, class_name: 'Core::Models::OAuth::Scope', inverse_of: :applications
|
31
37
|
|
32
38
|
validates :name,
|
33
39
|
presence: {message: 'required'},
|
34
40
|
length: {minimum: 6, message: 'minlength'},
|
35
41
|
uniqueness: {message: 'uniq'}
|
36
42
|
|
37
|
-
validates :
|
43
|
+
validates :client_id,
|
38
44
|
presence: {message: 'required'},
|
39
45
|
uniqueness: {message: 'uniq'}
|
40
46
|
|
47
|
+
validates :client_secret,
|
48
|
+
presence: {message: 'required'}
|
49
|
+
|
41
50
|
validate :redirect_uris_values
|
42
51
|
|
43
52
|
# Checks the URIs to get sure they are correct, a URI is correct if :
|
@@ -48,7 +57,7 @@ module Core
|
|
48
57
|
if !uri.is_a? String
|
49
58
|
errors.add(:redirect_uris, 'type')
|
50
59
|
break
|
51
|
-
elsif uri.match(/\
|
60
|
+
elsif uri.match(/\Ahttps?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*)\z/).nil?
|
52
61
|
errors.add(:redirect_uris, 'format')
|
53
62
|
break
|
54
63
|
end
|
@@ -15,6 +15,9 @@ module Core
|
|
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.
|
17
17
|
field :code, type: String, default: ->{ SecureRandom.hex }
|
18
|
+
# @!attribute [rw] expiration
|
19
|
+
# @return [Integer] the time, in seconds, after which the authorization is declared expired.
|
20
|
+
field :expiration, type: Integer, default: 86400
|
18
21
|
|
19
22
|
# @!attribute [rw] account
|
20
23
|
# @return [Arkaaan::Account] the account granting the authorization to access its data to the application.
|
@@ -25,10 +28,19 @@ module Core
|
|
25
28
|
# @!attribute [rw] token
|
26
29
|
# @return [Core::Models::OAuth::AccessToken] the access token used further in the application process to access private data of the account.
|
27
30
|
has_many :tokens, class_name: 'Core::Models::OAuth::AccessToken', inverse_of: :authorization
|
31
|
+
# @!attribute [rw]
|
32
|
+
# @return [Array<Core::Models::OAuth::Scope>] the scopes this access token has.
|
33
|
+
has_and_belongs_to_many :scopes, class_name: 'Core::Models::OAuth::Scope', inverse_of: :authorizations
|
28
34
|
|
29
35
|
validates :code,
|
30
36
|
presence: {message: 'required'},
|
31
37
|
uniqueness: {message: 'uniq'}
|
38
|
+
|
39
|
+
# Checks if the current date is inferior to the creation date + expiration period
|
40
|
+
# @return [Boolean] TRUE if the authorization is expired, FALSE otherwise.
|
41
|
+
def expired?
|
42
|
+
created_at.to_time.to_i + expiration < Time.now.to_i
|
43
|
+
end
|
32
44
|
end
|
33
45
|
end
|
34
46
|
end
|
@@ -12,10 +12,17 @@ module Core
|
|
12
12
|
# @!attribute [rw] value
|
13
13
|
# @return [String] the value of the token, returned to the application when built.
|
14
14
|
field :value, type: String, default: ->{ SecureRandom.hex }
|
15
|
+
# @!attribute [rw] used_at
|
16
|
+
# @return [DateTime] the date and time at which this refresh token has been useds to create a new access token.
|
17
|
+
field :used_at, type: DateTime, default: nil
|
15
18
|
|
16
19
|
# @!attribute [rw] authorization
|
17
20
|
# @return [Core::Models::OAuth::Authorization] the authorization code that issued this token to the application for this user.
|
18
|
-
belongs_to :
|
21
|
+
belongs_to :token, class_name: 'Core::Models::OAuth::AccessToken', inverse_of: :refresh_token
|
22
|
+
|
23
|
+
def used?
|
24
|
+
!used_at.nil? && used_at < DateTime.now
|
25
|
+
end
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Core
|
2
|
+
module Models
|
3
|
+
module OAuth
|
4
|
+
# A scope gives access to some parts of the API, for example to the management of campaigns,
|
5
|
+
# applications or for account profile management.
|
6
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
7
|
+
class Scope
|
8
|
+
include Mongoid::Document
|
9
|
+
include Mongoid::Timestamps
|
10
|
+
|
11
|
+
store_in collection: 'scopes'
|
12
|
+
|
13
|
+
# @!attribute [rw] name
|
14
|
+
# @return [String] the name of the scope, used to get its translation on the frontend.
|
15
|
+
field :name, type: String, default: ''
|
16
|
+
|
17
|
+
# @!attribute [rw] applications
|
18
|
+
# @return [Array<Core::Models::OAuth::Application>] the applications that want to have access to this
|
19
|
+
# scope from the users of the platform. These rights will be carried on to the tokens and frozen.
|
20
|
+
has_and_belongs_to_many :applications, class_name: 'Core::Models::OAuth::Application', inverse_of: :scopes
|
21
|
+
# @!attribute [rw] tokeauthorizationsns
|
22
|
+
# @return [Array<Core::Models::OAuth::Authorization] the tokens having these scopes.
|
23
|
+
has_and_belongs_to_many :authorizations, class_name: 'Core::Models::OAuth::Authorization', inverse_of: :scopes
|
24
|
+
|
25
|
+
validates :name,
|
26
|
+
presence: {message: 'required'},
|
27
|
+
length: {minimum: 6, if: :name?, message: 'minlength'},
|
28
|
+
uniqueness: {id: :name?, message: 'uniq'}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/core/models/oauth.rb
CHANGED
@@ -12,10 +12,10 @@ module Core
|
|
12
12
|
|
13
13
|
# @!attribute [rw] is_default
|
14
14
|
# @return [Boolean] a boolean indicating whether this group is given when a new user registered or not.
|
15
|
-
field :is_default, type: Boolean, default: false
|
15
|
+
field :is_default, type: Mongoid::Boolean, default: false
|
16
16
|
# @!attribute [rw] is_superuser
|
17
17
|
# @return [Boolean] a boolean indicating whether this group should have access to all groups and rights or not.
|
18
|
-
field :is_superuser, type: Boolean, default: false
|
18
|
+
field :is_superuser, type: Mongoid::Boolean, default: false
|
19
19
|
|
20
20
|
# @!attribute [rw] accounts
|
21
21
|
# @return [Array<Core::Models::Account>] the accounts having the rights granted by this group.
|
@@ -26,8 +26,6 @@ module Core
|
|
26
26
|
# @!attribute [rw] routes
|
27
27
|
# @return [Array<Core::Models::Monitoring::Route>] the routes this group can access in the API.
|
28
28
|
has_and_belongs_to_many :routes, class_name: 'Core::Models::Permissions::Route', inverse_of: :groups
|
29
|
-
|
30
|
-
make_sluggable 'group'
|
31
29
|
end
|
32
30
|
end
|
33
31
|
end
|
@@ -15,8 +15,6 @@ module Core
|
|
15
15
|
has_and_belongs_to_many :groups, class_name: 'Core::Models::Permissions::Group', inverse_of: :rights
|
16
16
|
|
17
17
|
belongs_to :category, class_name: 'Core::Models::Permissions::Category', inverse_of: :rights
|
18
|
-
|
19
|
-
make_sluggable 'right'
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
@@ -19,7 +19,7 @@ module Core
|
|
19
19
|
field :verb, type: String, default: 'get'
|
20
20
|
# @!attribute [rw] authenticated
|
21
21
|
# @return [Boolean] if true, the session_id is needed for this route, if false it is not.
|
22
|
-
field :authenticated, type: Boolean, default: true
|
22
|
+
field :authenticated, type: Mongoid::Boolean, default: true
|
23
23
|
# @!attribute [rw] groups
|
24
24
|
# @return [Array<Core::Models::Permissions::Group>] the groups having permission to access this route.
|
25
25
|
has_and_belongs_to_many :groups, class_name: 'Core::Models::Permissions::Group', inverse_of: :groups
|
data/lib/core/models.rb
CHANGED
@@ -1,24 +1,22 @@
|
|
1
|
-
|
2
|
-
require 'active_model'
|
3
|
-
require 'active_support'
|
4
|
-
require 'dotenv/load'
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
6
|
-
# Main module of the application, holding all the subsequent classes.
|
7
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
8
3
|
module Core
|
4
|
+
# Module holding the representations of the business objects we're manipulating
|
5
|
+
# in the database. Models are declared as Mongoid classes to connect to MongoDB
|
6
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
9
7
|
module Models
|
10
|
-
autoload :Account
|
8
|
+
autoload :Account, 'core/models/account'
|
11
9
|
autoload :Authentication, 'core/models/authentication'
|
12
|
-
autoload :Campaign
|
13
|
-
autoload :Campaigns
|
14
|
-
autoload :Chatroom
|
15
|
-
autoload :Chatrooms
|
16
|
-
autoload :Concerns
|
17
|
-
autoload :Event
|
18
|
-
autoload :Files
|
19
|
-
autoload :Notification
|
20
|
-
autoload :OAuth
|
21
|
-
autoload :Permissions
|
22
|
-
autoload :Ruleset
|
10
|
+
autoload :Campaign, 'core/models/campaign'
|
11
|
+
autoload :Campaigns, 'core/models/campaigns'
|
12
|
+
autoload :Chatroom, 'core/models/chatroom'
|
13
|
+
autoload :Chatrooms, 'core/models/chatrooms'
|
14
|
+
autoload :Concerns, 'core/models/concerns'
|
15
|
+
autoload :Event, 'core/models/event'
|
16
|
+
autoload :Files, 'core/models/files'
|
17
|
+
autoload :Notification, 'core/models/notification'
|
18
|
+
autoload :OAuth, 'core/models/oauth'
|
19
|
+
autoload :Permissions, 'core/models/permissions'
|
20
|
+
autoload :Ruleset, 'core/models/ruleset'
|
23
21
|
end
|
24
|
-
end
|
22
|
+
end
|
data/lib/core/services.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Core
|
4
|
+
# Services are orchestrating models to provide more high-level operations.
|
5
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
2
6
|
module Services
|
3
7
|
autoload :Accounts, 'core/services/accounts'
|
4
8
|
autoload :Base, 'core/services/base'
|
5
9
|
autoload :Registry, 'core/services/registry'
|
6
10
|
autoload :Sessions, 'core/services/sessions'
|
7
11
|
end
|
8
|
-
end
|
12
|
+
end
|
data/lib/core/version.rb
CHANGED
data/lib/core.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require 'dotenv/load'
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
%w[active_model mongoid active_support].each { |g| require g }
|
5
4
|
|
6
5
|
# Main module of the application, holding all the subsequent classes.
|
7
6
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
@@ -10,4 +9,4 @@ module Core
|
|
10
9
|
autoload :Helpers, 'core/helpers'
|
11
10
|
autoload :Models, 'core/models'
|
12
11
|
autoload :Services, 'core/services'
|
13
|
-
end
|
12
|
+
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.
|
4
|
+
version: 1.3.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-
|
11
|
+
date: 2022-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: database_cleaner
|
@@ -240,14 +240,14 @@ dependencies:
|
|
240
240
|
requirements:
|
241
241
|
- - '='
|
242
242
|
- !ruby/object:Gem::Version
|
243
|
-
version: 7.
|
243
|
+
version: 7.4.0
|
244
244
|
type: :runtime
|
245
245
|
prerelease: false
|
246
246
|
version_requirements: !ruby/object:Gem::Requirement
|
247
247
|
requirements:
|
248
248
|
- - '='
|
249
249
|
- !ruby/object:Gem::Version
|
250
|
-
version: 7.
|
250
|
+
version: 7.4.0
|
251
251
|
- !ruby/object:Gem::Dependency
|
252
252
|
name: sinatra
|
253
253
|
requirement: !ruby/object:Gem::Requirement
|
@@ -332,6 +332,7 @@ files:
|
|
332
332
|
- lib/core/models/oauth/application.rb
|
333
333
|
- lib/core/models/oauth/authorization.rb
|
334
334
|
- lib/core/models/oauth/refresh_token.rb
|
335
|
+
- lib/core/models/oauth/scope.rb
|
335
336
|
- lib/core/models/permissions.rb
|
336
337
|
- lib/core/models/permissions/category.rb
|
337
338
|
- lib/core/models/permissions/group.rb
|