maestrano-rails 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +43 -38
  4. data/README.md +4 -7
  5. data/lib/generators/maestrano/templates/maestrano.rb +6 -139
  6. data/lib/maestrano/rails/routing/routes.rb +1 -9
  7. data/maestrano-rails.gemspec +8 -9
  8. data/test/dummy_activerecord/config/initializers/maestrano.rb +7 -85
  9. data/test/dummy_activerecord/log/test.log +2947 -0
  10. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/1Y/1YNesTg9JO8EmKnsQ5o2QuHPY1_SoBI4IzPgjGbNDtg.cache +1 -0
  11. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/2E/2EMDck6E8hnJgftO6NKYnFBF3I7OY1XxmBhGYJx9hVU.cache +1 -0
  12. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/2J/2JXGkjZ38teJKsoxInZDvaepp3CkHBoDSogY8mrjnz4.cache +0 -0
  13. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/2y/2yOKmCmlo43TKFToC7sDi79zv1sEaKuRhPT-9RwLexo.cache +1 -0
  14. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/5g/5g7dhxVp4YbZmFw_-T3aU2oYq2Z9Jgtps0CKneXYSS0.cache +0 -0
  15. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/6C/6CJDEgEqVZ6WWB28_UrOgZXJ7imhTkyPfJCnjZaeHQo.cache +0 -0
  16. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/9v/9vZgtlozMnArb7R4KXZgyLUlc2hAKYMVeczENURRLfk.cache +0 -0
  17. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/BD/BD9vS-VA_G0ByKRS5cM8hNg17DhxAUCnbjirsC7QZT8.cache +0 -0
  18. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/BQ/BQtyJR3ccqed7_s43p3BPj3IL18LWu1Fo1ZnzWC3qcc.cache +0 -0
  19. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/Br/BrPxwjWI-O7aKFPR9IHgVHTz--0ve7HgO1xAHOSorxw.cache +1 -0
  20. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/D0/D0oQIDvZMxs7K1-bwAjXYaRTXNnKIB-vk4wDO3Mw3d4.cache +0 -0
  21. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/Eg/Eg9dsjuoufOcT1ojGffj56kcFY4ujQHBl4iBxaHNywQ.cache +0 -0
  22. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/GN/GN7EpxkaiDaaLFjlptcIZ0BjIwz4SQv-J6Si_qHNtRQ.cache +0 -0
  23. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/GX/GXBrspUeZnBiwFADWDaNmSYt9wkavup0id1nDW51SwI.cache +3 -0
  24. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/J7/J7Oklw3hOELd9594tXtFa2w66T4_zffVHzJ8TfX9uwc.cache +1 -0
  25. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/Lg/LgG4iMjI9pzWwqLjXp3JvB3xs8j14SUJzG4eRCYOWrU.cache +1 -0
  26. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/MJ/MJ2lcrIryOfzt2cWGx3d8LeFOJoLuIAlrL7SCdGMaik.cache +1 -0
  27. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/Oa/OaJik9XhKBzY7AT4At2irZpA2GTHO3p4_hUa1ORSzjc.cache +1 -0
  28. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/PJ/PJU52zcAkrMbEOmlo13u_i04nf-PXPCL_i6_ybo2AYo.cache +0 -0
  29. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/VN/VNCapNKJLeponthNeFJhaBYs92UBT3P8PugENHP0474.cache +0 -0
  30. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/VO/VOqmZhoZgNGgBPBfKq2xsc37yyNBBqntTUWteHs1VVc.cache +1 -0
  31. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/Vl/VlVHSjm74GkjWDuZlfcI6KAaQ9xjg8meWAssVwt-YMI.cache +1 -0
  32. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/Vt/VtysXvEqJf4LwL6kuKUSWHZbeR_jKoYj_z1L99d5Yzk.cache +1 -0
  33. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/W1/W1I750hXtFauIXfdF_h8f0H6Eh9fPjn1nb3WDnJGJ_0.cache +0 -0
  34. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/W_/W_AqS_Ihb1uBTP5eubT7Ep7vc3CcoUzol5J0T4xQsL0.cache +1 -0
  35. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/Yc/YcfvUdqaxEInuhPH8QMPNyhWsGLwtIx76o-tR_VUc_0.cache +1 -0
  36. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/_S/_SiC-nT_xG9vCIPkHUmC7GfAGNufVJLYqHQ4vQLOjvs.cache +1 -0
  37. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/_m/_m7Yy9Dl3hfylyoF91XSCvlOZ3762vGWH_ZhkTvreMU.cache +0 -0
  38. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/ak/akBxy_qeJ5hlUAP5G80qm_ZsKBlpXViO9rGg95rWx8U.cache +0 -0
  39. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/b7/b7lBpkBxQaCxHBBRf-QF0CiQKnRE8kYGLUzgAPTjf_k.cache +0 -0
  40. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/c2/c2LxqcKRpYH4PIKJj0RIMbpQeONqcvmk8zRZ3qAd4no.cache +0 -0
  41. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/dp/dplQ3jBb_bBGoJ4xMRKxYbJR5YoZjuyamwFopJb07Xo.cache +3 -0
  42. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/eZ/eZWyKd8Y-LcqrovIoB-YJiklulQC0CGG0d22eCJcYuU.cache +1 -0
  43. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/em/emPaz2829mOOQZolLXyEoXP73X44t4p-YUUA763b_1k.cache +1 -0
  44. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/fk/fkliCI8v5fyy_CObCj5Va9hEnO4JqIPX6WBhUYUJS4k.cache +1 -0
  45. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/hk/hkWnysQ9aaUtcEVLGt9gkfzIPrFfFqnR1P4LlriYD40.cache +1 -0
  46. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/j3/j3F-bQu56g8H580zxIStr369Vt2DEbb0BQJ21ie2eoI.cache +0 -0
  47. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/jK/jK6-bONOghUmAYu3DkuJ2MLIlLa8P9kbTE3tc1wBheg.cache +1 -0
  48. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/jm/jmJh54mguyD0TmNGQ4ExIqEW4jR1jQeJcO5mhggpfMs.cache +0 -0
  49. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/jt/jtrPJEzuZbLsfLK4SZphEu2PPyopSCtRfXQwj2AyAZg.cache +0 -0
  50. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/kQ/kQZfXHFhuNUcLTvh4QzLL6fKDZc-8XkwCwT8eMIW8ns.cache +1 -0
  51. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/l_/l_tJ9WwBL9Q8XjxQN56nGuGtCrP7kGBvE8e76g8tRC0.cache +0 -0
  52. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/my/mybo3dsRj5MFU0orUFY47lfsYuIuBB_KL1Z4aNANxYI.cache +1 -0
  53. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/qo/qob9eyRuMnynEh3V1dqTC-rEE-j5mOlG7t6EamNVBFY.cache +3 -0
  54. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/rf/rfsxw1dZNQvrAvAmqFP8bFeBcVIAPuvqozFzw80eS-4.cache +0 -0
  55. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/rm/rmsobLUxsQY2_hRp-ygb9dlbdoHpFlV6FMPnhxqpA1k.cache +3 -0
  56. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/sm/sm0X5aOvu10an00TtKAEtdF3Wpi08DQrHKEe3XXNHtk.cache +1 -0
  57. data/test/dummy_activerecord/tmp/cache/assets/sprockets/v3.0/x_/x_ZYCJrtiH6rATOiHF1QuxobPhpt7IRQUwciwGdXOxo.cache +0 -0
  58. data/test/dummy_mongoid/config/initializers/maestrano.rb +7 -85
  59. data/test/tmp/app/controllers/maestrano/account/group_users_controller.rb +27 -0
  60. data/test/tmp/app/controllers/maestrano/account/groups_controller.rb +37 -0
  61. data/test/tmp/app/controllers/maestrano/auth/saml_controller.rb +57 -0
  62. data/test/tmp/config/initializers/maestrano.rb +7 -0
  63. data/test/tmp/config/routes.rb +60 -0
  64. metadata +99 -10
  65. data/app/controllers/maestrano/rails/metadata_controller.rb +0 -10
  66. data/test/controllers/metadata_controller_test.rb +0 -24
  67. data/test/tmp/app/models/monster.rb +0 -19
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&id=4956bec4bde2ef41030bd0fc3f486fb445d4669c08c2c7e154556a27b99a7202:ET
@@ -0,0 +1 @@
1
+ "%C6������ܦ�M=��Qu���/�,"c�5u
@@ -0,0 +1 @@
1
+ I"}app/assets/stylesheets/application.css?type=text/css&id=b1b22d0cea5648ce45803371c746c2bcf79bd3db02e23763ea1a035b24e22ea5:ET
@@ -0,0 +1 @@
1
+ "%xJ�g&k��"��U���m��X�V�;Fj
@@ -0,0 +1,3 @@
1
+ [o:Set:
2
+ @hash{
3
+ I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"ofile-digest:///home/bruno/.rvm/gems/ruby-2.2.5/gems/jquery-rails-4.2.2/vendor/assets/javascripts/jquery.js;TT
@@ -0,0 +1 @@
1
+ I"}app/assets/stylesheets/application.css?type=text/css&id=6c90dbc7aa88f45057b3068ff27f73ede5b0901db39f36077794d52f683425af:ET
@@ -0,0 +1 @@
1
+ I"�/home/bruno/.rvm/gems/ruby-2.3.1/gems/jquery-rails-4.2.2/vendor/assets/javascripts/jquery.js?type=application/javascript&pipeline=self&id=03f3de24261a7de4de17340cd6b747bc40433856d7aaed331b2bec91e2d62ad4:ET
@@ -0,0 +1 @@
1
+ I"�/home/bruno/.rvm/gems/ruby-2.2.5/gems/jquery-rails-4.2.2/vendor/assets/javascripts/jquery_ujs.js?type=application/javascript&pipeline=self&id=3b627ce5e981d0d20ac62579499caa5da37fc717e6e33e34e7c2ea3e1cd06ec4:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/pages.css?type=text/css&pipeline=self&id=5fe282f8c041cf39665bcf1bd06160801627a49dffe5e1773965debafd14a276:ET
@@ -0,0 +1 @@
1
+ I"�/home/bruno/.rvm/gems/ruby-2.2.5/gems/jquery-rails-4.2.2/vendor/assets/javascripts/jquery.js?type=application/javascript&pipeline=self&id=a1edac6d7059f4ba0b20a4599c371db9e970344f618f697f87c851bdd148296d:ET
@@ -0,0 +1 @@
1
+ "%uW��l��j��Z� xU��>�?]��pc��s
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=89d26aa586cfb648307c87b23ccf13971251f6b71ba3cdf5933aa7d2b52d3913:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=47bec25081299e8e51978cb97cde72312cf393ba7acf9a7a324d075126fbb502:ET
@@ -0,0 +1 @@
1
+ I"�/home/bruno/.rvm/gems/ruby-2.3.1/gems/jquery-rails-4.2.2/vendor/assets/javascripts/jquery_ujs.js?type=application/javascript&pipeline=self&id=df1277523069abfa5b1557a89d84fb9b79f764ee30a903349a3aba4b1a05394b:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=44c544dfd20ea18f6046d68133ce04e2fc422cde45bbef6c3118e5f4afd0ed6e:ET
@@ -0,0 +1,3 @@
1
+ [o:Set:
2
+ @hash}
3
+ I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"sfile-digest:///home/bruno/.rvm/gems/ruby-2.3.1/gems/jquery-rails-4.2.2/vendor/assets/javascripts/jquery_ujs.js;TTF
@@ -0,0 +1 @@
1
+ "%uW��l��j��Z� xU��>�?]��pc��s
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/pages.js?type=application/javascript&pipeline=self&id=bc521424c58698c5a076e1bd49d89b228caa78a9a19e75b130af073584b06308:ET
@@ -0,0 +1 @@
1
+ "%xJ�g&k��"��U���m��X�V�;Fj
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/pages.css?type=text/css&pipeline=self&id=d5611ecf8d9cf969495e33b9d646463e0eb0a408225c0db609a31c9f7ae2ef69:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/pages.js?type=application/javascript&pipeline=self&id=4ff005ba9515424185c5dc3160f65b4c72e6b062da2166461aa362ce12ef44bf:ET
@@ -0,0 +1 @@
1
+ "%C6������ܦ�M=��Qu���/�,"c�5u
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=a61a07e813e5b61cacad673b337b2325af07bc3b4a9f430760eb98fbcff2b45f:ET
@@ -0,0 +1,3 @@
1
+ [o:Set:
2
+ @hash}
3
+ I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"ofile-digest:///home/bruno/.rvm/gems/ruby-2.3.1/gems/jquery-rails-4.2.2/vendor/assets/javascripts/jquery.js;TTF
@@ -0,0 +1,3 @@
1
+ [o:Set:
2
+ @hash{
3
+ I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"sfile-digest:///home/bruno/.rvm/gems/ruby-2.2.5/gems/jquery-rails-4.2.2/vendor/assets/javascripts/jquery_ujs.js;TT
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&id=463aa6f05a83fffc5766a6d1b3836129b43711061d2d4f16f2aabaa64127fa42:ET
@@ -1,85 +1,7 @@
1
- # Use this block to configure the behaviour of Maestrano
2
- # in your app
3
- Maestrano.configure do |config|
4
-
5
- # ==> Environment configuration
6
- # The environment to connect to.
7
- # If set to 'production' then all Single Sign-On (SSO) and API requests
8
- # will be made to maestrano.com
9
- # If set to 'test' then requests will be made to api-sandbox.maestrano.io
10
- # The api-sandbox allows you to easily test integration scenarios.
11
- # More details on http://api-sandbox.maestrano.io
12
- config.environment = Rails.env.production? ? 'production' : 'test'
13
-
14
- # ==> App ID & API key
15
- # Your application App ID and API key which you can retrieve on http://maestrano.com
16
- # via your cloud partner dashboard.
17
- # For testing you can retrieve/generate an api_key from the API Sandbox directly
18
- # on http://api-sandbox.maestrano.io
19
- config.app_id = Rails.env.production? ? 'prod_app_id' : 'sandbox_app_id'
20
- config.api_key = Rails.env.production? ? 'prod_api_key' : 'sandbox_api_key'
21
-
22
- # ==> Single Sign-On activation
23
- # Enable/Disable single sign-on. When troubleshooting authentication issues
24
- # you might want to disable SSO temporarily
25
- config.sso_enabled = true
26
-
27
- # ==> Application host
28
- # This is your application host (e.g: mysuperapp.com) which is ultimately
29
- # used to redirect users to the right SAML url during SSO handshake.
30
- config.app_host = Rails.env.production? ? 'https://my-production-app.com' : 'http://localhost::3000'
31
-
32
- # ==> SSO Initialization endpoint
33
- # This is your application path to the SAML endpoint that allows users to
34
- # initialize SSO authentication. Upon reaching this endpoint users your
35
- # application will automatically create a SAML request and redirect the user
36
- # to Maestrano. Maestrano will then authenticate and authorize the user. Upon
37
- # authorization the user gets redirected to your application consumer endpoint
38
- # (see below) for initial setup and/or login.
39
- # The controller for this path is automatically
40
- # generated when you run 'rake maestrano:install' and is available at
41
- # <rails_root>/app/controllers/maestrano/auth/saml.rb
42
- config.sso_app_init_path = '/maestrano/auth/saml/init'
43
-
44
- # ==> SSO Consumer endpoint
45
- # This is your application path to the SAML endpoint that allows users to
46
- # finalize SSO authentication. During the 'consume' action your application
47
- # sets users (and associated group) up and/or log them in.
48
- # The controller for this path is automatically
49
- # generated when you run 'rake maestrano:install' and is available at
50
- # <rails_root>/app/controllers/maestrano/auth/saml.rb
51
- config.sso_app_consume_path = '/maestrano/auth/saml/consume'
52
-
53
- # ==> SSO User creation mode
54
- # !IMPORTANT
55
- # On Maestrano users can take several "instances" of your service. You can consider
56
- # each "instance" as 1) a billing entity and 2) a collaboration group (this is
57
- # equivalent to a 'customer account' in a commercial world). When users login to
58
- # your application via single sign-on they actually login via a specific group which
59
- # is then supposed to determine which data they have access to inside your application.
60
- #
61
- # E.g: John and Jack are part of group 1. They should see the same data when they login to
62
- # your application (employee info, analytics, sales etc..). John is also part of group 2
63
- # but not Jack. Therefore only John should be able to see the data belonging to group 2.
64
- #
65
- # In most application this is done via collaboration/sharing/permission groups which is
66
- # why a group is required to be created when a new user logs in via a new group (and
67
- # also for billing purpose - you charge a group, not a user directly).
68
- #
69
- # == mode: 'real'
70
- # In an ideal world a user should be able to belong to several groups in your application.
71
- # In this case you would set the 'sso.creation_mode' to 'real' which means that the uid
72
- # and email we pass to you are the actual user email and maestrano universal id.
73
- #
74
- # == mode: 'virtual'
75
- # Now let's say that due to technical constraint your application cannot authorize a user
76
- # to belong to several groups. Well next time John logs in via a different group there will
77
- # be a problem: the user already exists (based on uid or email) and cannot be assigned
78
- # to a second group. To fix this you can set the 'sso.creation_mode' to 'virtual'. In this
79
- # mode users get assigned a truly unique uid and email across groups. So next time John logs
80
- # in a whole new user account can be created for him without any validation problem. In this
81
- # mode the email we assign to him looks like "usr-sdf54.cld-45aa2@mail.maestrano.com". But don't
82
- # worry we take care of forwarding any email you would send to this address
83
- #
84
- config.sso.creation_mode = 'virtual' # or 'real'
85
- end
1
+ if Rails.env.test?
2
+ Maestrano.configure do |config|
3
+ config.environment = 'local'
4
+ end
5
+ else
6
+ Maestrano.auto_configure
7
+ end
@@ -0,0 +1,27 @@
1
+ class Maestrano::Account::GroupUsersController < Maestrano::Rails::WebHookController
2
+
3
+ # DELETE /maestrano/account/groups/cld-1/users/usr-1/:tenant
4
+ # Remove a user from a group
5
+ def destroy
6
+ # Set the right uid based on Maestrano.param('sso.creation_mode')
7
+ user_uid = Maestrano.mask_user(params[:id],params[:group_id])
8
+ group_uid = params[:group_id]
9
+ tenant = params[:tenant]
10
+
11
+ # Perform association deletion steps here
12
+ # --
13
+ # If Maestrano.param('sso.creation_mode') is set to virtual
14
+ # then you might want to just delete/cancel/block the user
15
+ #
16
+ # E.g
17
+ # user = User.find_by_tenant_and_uid(tenant, user_uid)
18
+ # organization = Organization.find_by_tenant_and_uid(tenant ,group_uid)
19
+ #
20
+ # if Maestrano.param('sso.creation_mode') == 'virtual'
21
+ # user.destroy
22
+ # else
23
+ # organization.remove_user(user)
24
+ # user.block_access! if user.reload.organizations.empty?
25
+ # end
26
+ end
27
+ end
@@ -0,0 +1,37 @@
1
+ class Maestrano::Account::GroupsController < Maestrano::Rails::WebHookController
2
+
3
+ # DELETE /maestrano/account/groups/cld-1/:tenant
4
+ # Delete an entire group
5
+ def destroy
6
+ group_uid = params[:id]
7
+ tenant = params[:tenant]
8
+
9
+ # Perform deletion steps here
10
+ # --
11
+ # If you need to perform a final checkout
12
+ # then you can call Maestrano::Account::Bill.create({.. final checkout details ..})
13
+ # --
14
+ # If Maestrano.param('sso.creation_mode') is set to virtual
15
+ # then you might want to delete/cancel/block all users under
16
+ # that group
17
+ # --
18
+ # E.g:
19
+ # organization = Organization.find_by_tenant_and_uid(tenant, group_uid)
20
+ #
21
+ # amount_cents = organization.calculate_total_due_remaining
22
+ # Maestrano::Account::Bill.create({
23
+ # group_id: group_uid,
24
+ # price_cents: amount_cents,
25
+ # description: "Final Payout"
26
+ # })
27
+ #
28
+ # if Maestrano.param('sso.creation_mode') == 'virtual'
29
+ # organization.members.where(provider:'maestrano').each do |user|
30
+ # user.destroy
31
+ # end
32
+ #
33
+ # organization.destroy
34
+ # render json: {success: true}
35
+ #
36
+ end
37
+ end
@@ -0,0 +1,57 @@
1
+ class Maestrano::Auth::SamlController < Maestrano::Rails::SamlBaseController
2
+
3
+ #== POST '/maestrano/auth/saml/consume/:tenant'
4
+ # Final phase of the Single Sign-On handshake. Find or create
5
+ # the required resources (user and group) and sign the user
6
+ # in
7
+ #
8
+ # This action is left to you to customize based on your application
9
+ # requirements. Below is presented a potential way of writing
10
+ # the action.
11
+ #
12
+ # Assuming you have enabled maestrano on a user model
13
+ # called 'User' and a group model called 'Organization'
14
+ # the action could be written the following way
15
+ def consume
16
+ ### 1)Find or create the user and the group
17
+ ### --
18
+ ### The class method 'find_or_create_for_maestrano' is provided
19
+ ### by the maestrano-rails gem on the model you have maestrano-ized.
20
+ ### The method uses the mapping defined in the model 'maestrano_*_via'
21
+ ### block to create the resource if it does not exist
22
+ ### The 'user_auth_hash' and 'group_auth_hash' methods are provided
23
+ ### by the controller.
24
+ ### --
25
+ # user = User.find_or_create_for_maestrano(user_auth_hash)
26
+ # organization = Organization.find_or_create_for_maestrano(group_auth_hash)
27
+ #
28
+ # user.tenant = params[:tenant]
29
+ # user.save
30
+ # organization.tenant = params[:tenant]
31
+ # organization.save
32
+ #
33
+ #
34
+ ### 2) Add the user to the group if not already a member
35
+ ### --
36
+ ### The 'user_group_rel_hash' method is provided by the controller.
37
+ ### The role attribute provided by maestrano is one of the following:
38
+ ### 'Member', 'Power User', 'Admin', 'Super Admin'
39
+ ### The 'member_of?' and 'add_member' methods are not provided by
40
+ ### maestrano and are left to you to implement on your models
41
+ ### --
42
+ # unless user.member_of?(organization)
43
+ # organization.add_member(user,role: user_group_rel_hash[:role])
44
+ # end
45
+ #
46
+ #
47
+ ### Sign the user in and redirect to application root
48
+ ### --
49
+ ### The 'sign_in' method is not provided by maestrano but should already
50
+ ### be there if you are using an authentication framework like Devise
51
+ ### --
52
+ # sign_in(user)
53
+ # redirect_to root_path
54
+
55
+ raise NotImplemented.new("The consume action should be customized to fit your application needs")
56
+ end
57
+ end
@@ -0,0 +1,7 @@
1
+ if Rails.env.test?
2
+ Maestrano.configure do |config|
3
+ config.environment = 'local'
4
+ end
5
+ else
6
+ Maestrano.auto_configure
7
+ end
@@ -0,0 +1,60 @@
1
+ Dummy::Application.routes.draw do
2
+ maestrano_routes
3
+
4
+ # The priority is based upon order of creation:
5
+ # first created -> highest priority.
6
+
7
+ # Sample of regular route:
8
+ # match 'products/:id' => 'catalog#view'
9
+ # Keep in mind you can assign values other than :controller and :action
10
+
11
+ # Sample of named route:
12
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
13
+ # This route can be invoked with purchase_url(:id => product.id)
14
+
15
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
16
+ # resources :products
17
+
18
+ # Sample resource route with options:
19
+ # resources :products do
20
+ # member do
21
+ # get 'short'
22
+ # post 'toggle'
23
+ # end
24
+ #
25
+ # collection do
26
+ # get 'sold'
27
+ # end
28
+ # end
29
+
30
+ # Sample resource route with sub-resources:
31
+ # resources :products do
32
+ # resources :comments, :sales
33
+ # resource :seller
34
+ # end
35
+
36
+ # Sample resource route with more complex sub-resources
37
+ # resources :products do
38
+ # resources :comments
39
+ # resources :sales do
40
+ # get 'recent', :on => :collection
41
+ # end
42
+ # end
43
+
44
+ # Sample resource route within a namespace:
45
+ # namespace :admin do
46
+ # # Directs /admin/products/* to Admin::ProductsController
47
+ # # (app/controllers/admin/products_controller.rb)
48
+ # resources :products
49
+ # end
50
+
51
+ # You can have the root of your site routed with "root"
52
+ # just remember to delete public/index.html.
53
+ # root :to => 'welcome#index'
54
+
55
+ # See how all your routes lay out with "rake routes"
56
+
57
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
58
+ # Note: This route will make all actions in every controller accessible via GET requests.
59
+ # match ':controller(/:action(/:id))(.:format)'
60
+ end