descope 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yaml +54 -0
  3. data/.gitignore +59 -0
  4. data/.release-please-manifest.json +3 -0
  5. data/.rubocop.yml +10 -0
  6. data/.rubocop_todo.yml +10 -0
  7. data/.ruby-version +1 -0
  8. data/CHANGELOG.md +90 -0
  9. data/Gemfile +22 -0
  10. data/Gemfile.lock +204 -0
  11. data/LICENSE +21 -0
  12. data/README.md +1171 -0
  13. data/Rakefile +31 -0
  14. data/descope.gemspec +34 -0
  15. data/examples/ruby/Gemfile +4 -0
  16. data/examples/ruby/Gemfile.lock +41 -0
  17. data/examples/ruby/access_key_app.rb +45 -0
  18. data/examples/ruby/enchantedlink_app.rb +65 -0
  19. data/examples/ruby/magiclink_app.rb +81 -0
  20. data/examples/ruby/management/Gemfile +5 -0
  21. data/examples/ruby/management/Gemfile.lock +38 -0
  22. data/examples/ruby/management/access_key_app.rb +71 -0
  23. data/examples/ruby/management/audit_app.rb +25 -0
  24. data/examples/ruby/management/authz_app.rb +135 -0
  25. data/examples/ruby/management/authz_files.json +229 -0
  26. data/examples/ruby/management/flow_app.rb +57 -0
  27. data/examples/ruby/management/permission_app.rb +56 -0
  28. data/examples/ruby/management/role_app.rb +58 -0
  29. data/examples/ruby/management/tenant_app.rb +60 -0
  30. data/examples/ruby/management/user_app.rb +60 -0
  31. data/examples/ruby/oauth_app.rb +39 -0
  32. data/examples/ruby/otp_app.rb +50 -0
  33. data/examples/ruby/password_app.rb +76 -0
  34. data/examples/ruby/saml_app.rb +38 -0
  35. data/examples/ruby-on-rails-api/descope/.dockerignore +37 -0
  36. data/examples/ruby-on-rails-api/descope/.gitattributes +9 -0
  37. data/examples/ruby-on-rails-api/descope/.gitignore +40 -0
  38. data/examples/ruby-on-rails-api/descope/.node-version +1 -0
  39. data/examples/ruby-on-rails-api/descope/.ruby-version +1 -0
  40. data/examples/ruby-on-rails-api/descope/Dockerfile +75 -0
  41. data/examples/ruby-on-rails-api/descope/Gemfile +67 -0
  42. data/examples/ruby-on-rails-api/descope/Gemfile.lock +284 -0
  43. data/examples/ruby-on-rails-api/descope/Procfile.dev +3 -0
  44. data/examples/ruby-on-rails-api/descope/README.md +54 -0
  45. data/examples/ruby-on-rails-api/descope/Rakefile +6 -0
  46. data/examples/ruby-on-rails-api/descope/app/assets/builds/.keep +0 -0
  47. data/examples/ruby-on-rails-api/descope/app/assets/config/manifest.js +3 -0
  48. data/examples/ruby-on-rails-api/descope/app/assets/images/.keep +0 -0
  49. data/examples/ruby-on-rails-api/descope/app/assets/images/descope.jpeg +0 -0
  50. data/examples/ruby-on-rails-api/descope/app/assets/images/favicon.ico +0 -0
  51. data/examples/ruby-on-rails-api/descope/app/assets/images/logo192.png +0 -0
  52. data/examples/ruby-on-rails-api/descope/app/assets/images/logo512.png +0 -0
  53. data/examples/ruby-on-rails-api/descope/app/assets/stylesheets/application.bootstrap.scss +67 -0
  54. data/examples/ruby-on-rails-api/descope/app/channels/application_cable/channel.rb +4 -0
  55. data/examples/ruby-on-rails-api/descope/app/channels/application_cable/connection.rb +4 -0
  56. data/examples/ruby-on-rails-api/descope/app/controllers/application_controller.rb +2 -0
  57. data/examples/ruby-on-rails-api/descope/app/controllers/concerns/.keep +0 -0
  58. data/examples/ruby-on-rails-api/descope/app/controllers/homepage_controller.rb +4 -0
  59. data/examples/ruby-on-rails-api/descope/app/controllers/session_controller.rb +66 -0
  60. data/examples/ruby-on-rails-api/descope/app/helpers/application_helper.rb +2 -0
  61. data/examples/ruby-on-rails-api/descope/app/helpers/homepage_helper.rb +2 -0
  62. data/examples/ruby-on-rails-api/descope/app/helpers/session_helper.rb +2 -0
  63. data/examples/ruby-on-rails-api/descope/app/javascript/App.css +53 -0
  64. data/examples/ruby-on-rails-api/descope/app/javascript/application.js +5 -0
  65. data/examples/ruby-on-rails-api/descope/app/javascript/components/App.jsx +4 -0
  66. data/examples/ruby-on-rails-api/descope/app/javascript/components/Dashboard.jsx +60 -0
  67. data/examples/ruby-on-rails-api/descope/app/javascript/components/Home.jsx +27 -0
  68. data/examples/ruby-on-rails-api/descope/app/javascript/components/Login.jsx +45 -0
  69. data/examples/ruby-on-rails-api/descope/app/javascript/components/Profile.jsx +81 -0
  70. data/examples/ruby-on-rails-api/descope/app/javascript/components/index.html +11 -0
  71. data/examples/ruby-on-rails-api/descope/app/javascript/components/index.jsx +24 -0
  72. data/examples/ruby-on-rails-api/descope/app/javascript/controllers/application.js +9 -0
  73. data/examples/ruby-on-rails-api/descope/app/javascript/controllers/index.js +5 -0
  74. data/examples/ruby-on-rails-api/descope/app/javascript/reportWebVitals.js +13 -0
  75. data/examples/ruby-on-rails-api/descope/app/javascript/routes/index.jsx +17 -0
  76. data/examples/ruby-on-rails-api/descope/app/jobs/application_job.rb +7 -0
  77. data/examples/ruby-on-rails-api/descope/app/mailers/application_mailer.rb +4 -0
  78. data/examples/ruby-on-rails-api/descope/app/models/application_record.rb +3 -0
  79. data/examples/ruby-on-rails-api/descope/app/models/concerns/.keep +0 -0
  80. data/examples/ruby-on-rails-api/descope/app/views/homepage/index.html.erb +2 -0
  81. data/examples/ruby-on-rails-api/descope/app/views/layouts/application.html.erb +16 -0
  82. data/examples/ruby-on-rails-api/descope/app/views/layouts/mailer.html.erb +13 -0
  83. data/examples/ruby-on-rails-api/descope/app/views/layouts/mailer.text.erb +1 -0
  84. data/examples/ruby-on-rails-api/descope/app/views/session/index.html.erb +2 -0
  85. data/examples/ruby-on-rails-api/descope/bin/bundle +109 -0
  86. data/examples/ruby-on-rails-api/descope/bin/dev +11 -0
  87. data/examples/ruby-on-rails-api/descope/bin/docker-entrypoint +8 -0
  88. data/examples/ruby-on-rails-api/descope/bin/rails +4 -0
  89. data/examples/ruby-on-rails-api/descope/bin/rake +4 -0
  90. data/examples/ruby-on-rails-api/descope/bin/setup +36 -0
  91. data/examples/ruby-on-rails-api/descope/build.js +30 -0
  92. data/examples/ruby-on-rails-api/descope/config/application.rb +42 -0
  93. data/examples/ruby-on-rails-api/descope/config/boot.rb +4 -0
  94. data/examples/ruby-on-rails-api/descope/config/cable.yml +10 -0
  95. data/examples/ruby-on-rails-api/descope/config/config.yml +9 -0
  96. data/examples/ruby-on-rails-api/descope/config/credentials.yml.enc +1 -0
  97. data/examples/ruby-on-rails-api/descope/config/database.yml +25 -0
  98. data/examples/ruby-on-rails-api/descope/config/environment.rb +5 -0
  99. data/examples/ruby-on-rails-api/descope/config/environments/development.rb +76 -0
  100. data/examples/ruby-on-rails-api/descope/config/environments/production.rb +97 -0
  101. data/examples/ruby-on-rails-api/descope/config/environments/test.rb +64 -0
  102. data/examples/ruby-on-rails-api/descope/config/initializers/assets.rb +13 -0
  103. data/examples/ruby-on-rails-api/descope/config/initializers/content_security_policy.rb +25 -0
  104. data/examples/ruby-on-rails-api/descope/config/initializers/filter_parameter_logging.rb +8 -0
  105. data/examples/ruby-on-rails-api/descope/config/initializers/inflections.rb +16 -0
  106. data/examples/ruby-on-rails-api/descope/config/initializers/load_config.rb +12 -0
  107. data/examples/ruby-on-rails-api/descope/config/initializers/permissions_policy.rb +13 -0
  108. data/examples/ruby-on-rails-api/descope/config/locales/en.yml +31 -0
  109. data/examples/ruby-on-rails-api/descope/config/puma.rb +35 -0
  110. data/examples/ruby-on-rails-api/descope/config/routes.rb +18 -0
  111. data/examples/ruby-on-rails-api/descope/config/storage.yml +34 -0
  112. data/examples/ruby-on-rails-api/descope/config.ru +6 -0
  113. data/examples/ruby-on-rails-api/descope/db/seeds.rb +9 -0
  114. data/examples/ruby-on-rails-api/descope/lib/assets/.keep +0 -0
  115. data/examples/ruby-on-rails-api/descope/lib/tasks/.keep +0 -0
  116. data/examples/ruby-on-rails-api/descope/log/.keep +0 -0
  117. data/examples/ruby-on-rails-api/descope/package-lock.json +19680 -0
  118. data/examples/ruby-on-rails-api/descope/package.json +51 -0
  119. data/examples/ruby-on-rails-api/descope/public/404.html +67 -0
  120. data/examples/ruby-on-rails-api/descope/public/422.html +67 -0
  121. data/examples/ruby-on-rails-api/descope/public/500.html +66 -0
  122. data/examples/ruby-on-rails-api/descope/public/apple-touch-icon-precomposed.png +0 -0
  123. data/examples/ruby-on-rails-api/descope/public/apple-touch-icon.png +0 -0
  124. data/examples/ruby-on-rails-api/descope/public/favicon.ico +0 -0
  125. data/examples/ruby-on-rails-api/descope/public/robots.txt +1 -0
  126. data/examples/ruby-on-rails-api/descope/storage/.keep +0 -0
  127. data/examples/ruby-on-rails-api/descope/tmp/.keep +0 -0
  128. data/examples/ruby-on-rails-api/descope/tmp/pids/.keep +0 -0
  129. data/examples/ruby-on-rails-api/descope/tmp/storage/.keep +0 -0
  130. data/examples/ruby-on-rails-api/descope/vendor/.keep +0 -0
  131. data/examples/ruby-on-rails-api/descope/yarn.lock +10780 -0
  132. data/lib/descope/api/v1/auth/enchantedlink.rb +156 -0
  133. data/lib/descope/api/v1/auth/magiclink.rb +170 -0
  134. data/lib/descope/api/v1/auth/oauth.rb +72 -0
  135. data/lib/descope/api/v1/auth/otp.rb +186 -0
  136. data/lib/descope/api/v1/auth/password.rb +100 -0
  137. data/lib/descope/api/v1/auth/saml.rb +48 -0
  138. data/lib/descope/api/v1/auth/totp.rb +72 -0
  139. data/lib/descope/api/v1/auth.rb +452 -0
  140. data/lib/descope/api/v1/management/access_key.rb +81 -0
  141. data/lib/descope/api/v1/management/audit.rb +82 -0
  142. data/lib/descope/api/v1/management/authz.rb +165 -0
  143. data/lib/descope/api/v1/management/common.rb +147 -0
  144. data/lib/descope/api/v1/management/flow.rb +55 -0
  145. data/lib/descope/api/v1/management/password.rb +58 -0
  146. data/lib/descope/api/v1/management/permission.rb +48 -0
  147. data/lib/descope/api/v1/management/project.rb +53 -0
  148. data/lib/descope/api/v1/management/role.rb +48 -0
  149. data/lib/descope/api/v1/management/scim.rb +206 -0
  150. data/lib/descope/api/v1/management/sso_settings.rb +153 -0
  151. data/lib/descope/api/v1/management/tenant.rb +71 -0
  152. data/lib/descope/api/v1/management/user.rb +619 -0
  153. data/lib/descope/api/v1/management.rb +38 -0
  154. data/lib/descope/api/v1/session.rb +84 -0
  155. data/lib/descope/api/v1.rb +13 -0
  156. data/lib/descope/client.rb +6 -0
  157. data/lib/descope/exception.rb +50 -0
  158. data/lib/descope/mixins/common.rb +129 -0
  159. data/lib/descope/mixins/headers.rb +15 -0
  160. data/lib/descope/mixins/http.rb +133 -0
  161. data/lib/descope/mixins/initializer.rb +80 -0
  162. data/lib/descope/mixins/logging.rb +30 -0
  163. data/lib/descope/mixins/validation.rb +79 -0
  164. data/lib/descope/mixins.rb +22 -0
  165. data/lib/descope/version.rb +7 -0
  166. data/lib/descope.rb +9 -0
  167. data/lib/descope_client.rb +5 -0
  168. data/release-please-config.json +18 -0
  169. data/renovate.json +6 -0
  170. data/spec/factories/user.rb +16 -0
  171. data/spec/lib.descope/api/v1/auth/enchantedlink_spec.rb +159 -0
  172. data/spec/lib.descope/api/v1/auth/magiclink_spec.rb +282 -0
  173. data/spec/lib.descope/api/v1/auth/oauth_spec.rb +117 -0
  174. data/spec/lib.descope/api/v1/auth/otp_spec.rb +285 -0
  175. data/spec/lib.descope/api/v1/auth/password_spec.rb +124 -0
  176. data/spec/lib.descope/api/v1/auth/saml_spec.rb +55 -0
  177. data/spec/lib.descope/api/v1/auth/totp_spec.rb +70 -0
  178. data/spec/lib.descope/api/v1/auth_spec.rb +372 -0
  179. data/spec/lib.descope/api/v1/management/access_key_spec.rb +118 -0
  180. data/spec/lib.descope/api/v1/management/audit_spec.rb +78 -0
  181. data/spec/lib.descope/api/v1/management/authz_spec.rb +336 -0
  182. data/spec/lib.descope/api/v1/management/flow_spec.rb +78 -0
  183. data/spec/lib.descope/api/v1/management/password_spec.rb +25 -0
  184. data/spec/lib.descope/api/v1/management/permission_spec.rb +81 -0
  185. data/spec/lib.descope/api/v1/management/project_spec.rb +63 -0
  186. data/spec/lib.descope/api/v1/management/role_spec.rb +85 -0
  187. data/spec/lib.descope/api/v1/management/scim_spec.rb +312 -0
  188. data/spec/lib.descope/api/v1/management/sso_settings_spec.rb +172 -0
  189. data/spec/lib.descope/api/v1/management/tenant_spec.rb +141 -0
  190. data/spec/lib.descope/api/v1/management/user_spec.rb +667 -0
  191. data/spec/lib.descope/api/v1/session_spec.rb +117 -0
  192. data/spec/lib.descope/client_spec.rb +40 -0
  193. data/spec/spec_helper.rb +72 -0
  194. data/spec/support/client_config.rb +14 -0
  195. data/spec/support/dummy_class.rb +36 -0
  196. data/spec/support/utils.rb +32 -0
  197. metadata +420 -0
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'descope'
5
+
6
+ @logger = Logger.new($stdout)
7
+
8
+ @project_id = ENV['DESCOPE_PROJECT_ID']
9
+ @management_key = ENV['DESCOPE_MANAGEMENT_KEY']
10
+
11
+ @logger.info("Initializing Descope API with project_id: #{@project_id} and base_uri: #{@base_uri}")
12
+
13
+ @client = Descope::Client.new({ project_id: @project_id, management_key: @management_key })
14
+
15
+ begin
16
+ @logger.info('Going to login with SAML auth method')
17
+ @logger.info('make sure to configure your SAML for the tenant you are going to use')
18
+ @logger.info('https://docs.descope.com/tutorials/sso/')
19
+ puts 'Enter tenant id:'
20
+ tenant_id = gets.chomp
21
+ @logger.info('CMD click the url and then copy the code from the browser')
22
+ response = @client.saml_sign_in(tenant: tenant_id, redirect_url: 'https://www.google.com')
23
+ @logger.info("SAML response: #{response}")
24
+
25
+ puts 'Enter code:'
26
+ code = gets.chomp
27
+ @logger.info("Exchanging code: #{code}")
28
+ jwt_response = @client.saml_exchange_token(code)
29
+ refresh_token = jwt_response[Descope::Mixins::Common::REFRESH_SESSION_TOKEN_NAME].fetch('jwt')
30
+
31
+ res = @client.me(refresh_token)
32
+ @logger.info("Me response: #{res}")
33
+
34
+ @logger.info('signing out...')
35
+ @client.sign_out(refresh_token)
36
+ rescue Descope::AuthException => e
37
+ @logger.error("Error: #{e.message}")
38
+ end
@@ -0,0 +1,37 @@
1
+ # See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
2
+
3
+ # Ignore git directory.
4
+ /.git/
5
+
6
+ # Ignore bundler config.
7
+ /.bundle
8
+
9
+ # Ignore all environment files (except templates).
10
+ /.env*
11
+ !/.env*.erb
12
+
13
+ # Ignore all default key files.
14
+ /config/master.key
15
+ /config/credentials/*.key
16
+
17
+ # Ignore all logfiles and tempfiles.
18
+ /log/*
19
+ /tmp/*
20
+ !/log/.keep
21
+ !/tmp/.keep
22
+
23
+ # Ignore pidfiles, but keep the directory.
24
+ /tmp/pids/*
25
+ !/tmp/pids/.keep
26
+
27
+ # Ignore storage (uploaded files in development and any SQLite databases).
28
+ /storage/*
29
+ !/storage/.keep
30
+ /tmp/storage/*
31
+ !/tmp/storage/.keep
32
+
33
+ # Ignore assets.
34
+ /node_modules/
35
+ /app/assets/builds/*
36
+ !/app/assets/builds/.keep
37
+ /public/assets
@@ -0,0 +1,9 @@
1
+ # See https://git-scm.com/docs/gitattributes for more about git attribute files.
2
+
3
+ # Mark the database schema as having been generated.
4
+ db/schema.rb linguist-generated
5
+
6
+ # Mark any vendored files as having been vendored.
7
+ vendor/* linguist-vendored
8
+ config/credentials/*.yml.enc diff=rails_credentials
9
+ config/credentials.yml.enc diff=rails_credentials
@@ -0,0 +1,40 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore all environment files (except templates).
11
+ /.env*
12
+ !/.env*.erb
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*
16
+ /tmp/*
17
+ !/log/.keep
18
+ !/tmp/.keep
19
+
20
+ # Ignore pidfiles, but keep the directory.
21
+ /tmp/pids/*
22
+ !/tmp/pids/
23
+ !/tmp/pids/.keep
24
+
25
+ # Ignore storage (uploaded files in development and any SQLite databases).
26
+ /storage/*
27
+ !/storage/.keep
28
+ /tmp/storage/*
29
+ !/tmp/storage/
30
+ !/tmp/storage/.keep
31
+
32
+ /public/assets
33
+
34
+ # Ignore master key for decrypting credentials and more.
35
+ /config/master.key
36
+
37
+ /app/assets/builds/*
38
+ !/app/assets/builds/.keep
39
+
40
+ /node_modules
@@ -0,0 +1 @@
1
+ 20.11.0
@@ -0,0 +1 @@
1
+ ruby-3.3.0
@@ -0,0 +1,75 @@
1
+ # syntax = docker/dockerfile:1
2
+
3
+ # Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
4
+ ARG RUBY_VERSION=3.3.0
5
+ FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
6
+
7
+ # Rails app lives here
8
+ WORKDIR /rails
9
+
10
+ # Set production environment
11
+ ENV RAILS_ENV="production" \
12
+ BUNDLE_DEPLOYMENT="1" \
13
+ BUNDLE_PATH="/usr/local/bundle" \
14
+ BUNDLE_WITHOUT="development"
15
+
16
+
17
+ # Throw-away build stage to reduce size of final image
18
+ FROM base as build
19
+
20
+ # Install packages needed to build gems and node modules
21
+ RUN apt-get update -qq && \
22
+ apt-get install --no-install-recommends -y build-essential curl git libvips node-gyp pkg-config python-is-python3
23
+
24
+ # Install JavaScript dependencies
25
+ ARG NODE_VERSION=20.11.0
26
+ ARG YARN_VERSION=1.22.19
27
+ ENV PATH=/usr/local/node/bin:$PATH
28
+ RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
29
+ /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
30
+ npm install -g yarn@$YARN_VERSION && \
31
+ rm -rf /tmp/node-build-master
32
+
33
+ # Install application gems
34
+ COPY Gemfile Gemfile.lock ./
35
+ RUN bundle install && \
36
+ rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
37
+ bundle exec bootsnap precompile --gemfile
38
+
39
+ # Install node modules
40
+ COPY package.json yarn.lock ./
41
+ RUN yarn install --frozen-lockfile
42
+
43
+ # Copy application code
44
+ COPY . .
45
+
46
+ # Precompile bootsnap code for faster boot times
47
+ RUN bundle exec bootsnap precompile app/ lib/
48
+
49
+ # Precompiling assets for production without requiring secret RAILS_MASTER_KEY
50
+ RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
51
+
52
+
53
+ # Final stage for app image
54
+ FROM base
55
+
56
+ # Install packages needed for deployment
57
+ RUN apt-get update -qq && \
58
+ apt-get install --no-install-recommends -y curl libsqlite3-0 libvips && \
59
+ rm -rf /var/lib/apt/lists /var/cache/apt/archives
60
+
61
+ # Copy built artifacts: gems, application
62
+ COPY --from=build /usr/local/bundle /usr/local/bundle
63
+ COPY --from=build /rails /rails
64
+
65
+ # Run and own only the runtime files as a non-root user for security
66
+ RUN useradd rails --create-home --shell /bin/bash && \
67
+ chown -R rails:rails db log storage tmp
68
+ USER rails:rails
69
+
70
+ # Entrypoint prepares the database.
71
+ ENTRYPOINT ["/rails/bin/docker-entrypoint"]
72
+
73
+ # Start the server by default, this can be overwritten at runtime
74
+ EXPOSE 3000
75
+ CMD ["./bin/rails", "server"]
@@ -0,0 +1,67 @@
1
+ source "https://rubygems.org"
2
+
3
+ ruby "3.3.0"
4
+
5
+ # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
6
+ gem "rails", "~> 7.1.3"
7
+
8
+ gem 'descope', path: '../../../..'
9
+
10
+ # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
11
+ gem "sprockets-rails"
12
+
13
+ # Use sqlite3 as the database for Active Record
14
+ gem "sqlite3", "~> 1.4"
15
+
16
+ # Use the Puma web server [https://github.com/puma/puma]
17
+ gem "puma", ">= 5.0"
18
+
19
+ # Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
20
+ gem "jsbundling-rails"
21
+
22
+ # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
23
+ gem "turbo-rails"
24
+
25
+ # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
26
+ gem "stimulus-rails"
27
+
28
+ # Bundle and process CSS [https://github.com/rails/cssbundling-rails]
29
+ gem "cssbundling-rails"
30
+
31
+ # Build JSON APIs with ease [https://github.com/rails/jbuilder]
32
+ gem "jbuilder"
33
+
34
+ # Use Redis adapter to run Action Cable in production
35
+ # gem "redis", ">= 4.0.1"
36
+
37
+ # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
38
+ # gem "kredis"
39
+
40
+ # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
41
+ # gem "bcrypt", "~> 3.1.7"
42
+
43
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
44
+ gem "tzinfo-data", platforms: %i[ windows jruby ]
45
+
46
+ # Reduces boot times through caching; required in config/boot.rb
47
+ gem "bootsnap", require: false
48
+
49
+ # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
50
+ # gem "image_processing", "~> 1.2"
51
+
52
+ group :development, :test do
53
+ # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
54
+ gem "debug", platforms: %i[ mri windows ]
55
+ end
56
+
57
+ group :development do
58
+ # Use console on exceptions pages [https://github.com/rails/web-console]
59
+ gem "web-console"
60
+
61
+ # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
62
+ # gem "rack-mini-profiler"
63
+
64
+ # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
65
+ # gem "spring"
66
+ end
67
+
@@ -0,0 +1,284 @@
1
+ PATH
2
+ remote: ../../../..
3
+ specs:
4
+ descope (1.0.3)
5
+ addressable (~> 2.8)
6
+ jwt (~> 2.7)
7
+ rest-client (~> 2.1)
8
+ retryable (~> 3.0)
9
+ zache (~> 0.12)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ actioncable (7.1.3)
15
+ actionpack (= 7.1.3)
16
+ activesupport (= 7.1.3)
17
+ nio4r (~> 2.0)
18
+ websocket-driver (>= 0.6.1)
19
+ zeitwerk (~> 2.6)
20
+ actionmailbox (7.1.3)
21
+ actionpack (= 7.1.3)
22
+ activejob (= 7.1.3)
23
+ activerecord (= 7.1.3)
24
+ activestorage (= 7.1.3)
25
+ activesupport (= 7.1.3)
26
+ mail (>= 2.7.1)
27
+ net-imap
28
+ net-pop
29
+ net-smtp
30
+ actionmailer (7.1.3)
31
+ actionpack (= 7.1.3)
32
+ actionview (= 7.1.3)
33
+ activejob (= 7.1.3)
34
+ activesupport (= 7.1.3)
35
+ mail (~> 2.5, >= 2.5.4)
36
+ net-imap
37
+ net-pop
38
+ net-smtp
39
+ rails-dom-testing (~> 2.2)
40
+ actionpack (7.1.3)
41
+ actionview (= 7.1.3)
42
+ activesupport (= 7.1.3)
43
+ nokogiri (>= 1.8.5)
44
+ racc
45
+ rack (>= 2.2.4)
46
+ rack-session (>= 1.0.1)
47
+ rack-test (>= 0.6.3)
48
+ rails-dom-testing (~> 2.2)
49
+ rails-html-sanitizer (~> 1.6)
50
+ actiontext (7.1.3)
51
+ actionpack (= 7.1.3)
52
+ activerecord (= 7.1.3)
53
+ activestorage (= 7.1.3)
54
+ activesupport (= 7.1.3)
55
+ globalid (>= 0.6.0)
56
+ nokogiri (>= 1.8.5)
57
+ actionview (7.1.3)
58
+ activesupport (= 7.1.3)
59
+ builder (~> 3.1)
60
+ erubi (~> 1.11)
61
+ rails-dom-testing (~> 2.2)
62
+ rails-html-sanitizer (~> 1.6)
63
+ activejob (7.1.3)
64
+ activesupport (= 7.1.3)
65
+ globalid (>= 0.3.6)
66
+ activemodel (7.1.3)
67
+ activesupport (= 7.1.3)
68
+ activerecord (7.1.3)
69
+ activemodel (= 7.1.3)
70
+ activesupport (= 7.1.3)
71
+ timeout (>= 0.4.0)
72
+ activestorage (7.1.3)
73
+ actionpack (= 7.1.3)
74
+ activejob (= 7.1.3)
75
+ activerecord (= 7.1.3)
76
+ activesupport (= 7.1.3)
77
+ marcel (~> 1.0)
78
+ activesupport (7.1.3)
79
+ base64
80
+ bigdecimal
81
+ concurrent-ruby (~> 1.0, >= 1.0.2)
82
+ connection_pool (>= 2.2.5)
83
+ drb
84
+ i18n (>= 1.6, < 2)
85
+ minitest (>= 5.1)
86
+ mutex_m
87
+ tzinfo (~> 2.0)
88
+ addressable (2.8.6)
89
+ public_suffix (>= 2.0.2, < 6.0)
90
+ base64 (0.2.0)
91
+ bigdecimal (3.1.6)
92
+ bindex (0.8.1)
93
+ bootsnap (1.17.1)
94
+ msgpack (~> 1.2)
95
+ builder (3.2.4)
96
+ concurrent-ruby (1.2.3)
97
+ connection_pool (2.4.1)
98
+ crass (1.0.6)
99
+ cssbundling-rails (1.4.0)
100
+ railties (>= 6.0.0)
101
+ date (3.3.4)
102
+ debug (1.9.1)
103
+ irb (~> 1.10)
104
+ reline (>= 0.3.8)
105
+ domain_name (0.6.20240107)
106
+ drb (2.2.0)
107
+ ruby2_keywords
108
+ erubi (1.12.0)
109
+ globalid (1.2.1)
110
+ activesupport (>= 6.1)
111
+ http-accept (1.7.0)
112
+ http-cookie (1.0.5)
113
+ domain_name (~> 0.5)
114
+ i18n (1.14.1)
115
+ concurrent-ruby (~> 1.0)
116
+ io-console (0.7.2)
117
+ irb (1.11.1)
118
+ rdoc
119
+ reline (>= 0.4.2)
120
+ jbuilder (2.11.5)
121
+ actionview (>= 5.0.0)
122
+ activesupport (>= 5.0.0)
123
+ jsbundling-rails (1.3.0)
124
+ railties (>= 6.0.0)
125
+ jwt (2.7.1)
126
+ loofah (2.22.0)
127
+ crass (~> 1.0.2)
128
+ nokogiri (>= 1.12.0)
129
+ mail (2.8.1)
130
+ mini_mime (>= 0.1.1)
131
+ net-imap
132
+ net-pop
133
+ net-smtp
134
+ marcel (1.0.2)
135
+ mime-types (3.5.2)
136
+ mime-types-data (~> 3.2015)
137
+ mime-types-data (3.2023.1205)
138
+ mini_mime (1.1.5)
139
+ minitest (5.21.2)
140
+ msgpack (1.7.2)
141
+ mutex_m (0.2.0)
142
+ net-imap (0.4.9.1)
143
+ date
144
+ net-protocol
145
+ net-pop (0.1.2)
146
+ net-protocol
147
+ net-protocol (0.2.2)
148
+ timeout
149
+ net-smtp (0.4.0.1)
150
+ net-protocol
151
+ netrc (0.11.0)
152
+ nio4r (2.7.0)
153
+ nokogiri (1.16.2-aarch64-linux)
154
+ racc (~> 1.4)
155
+ nokogiri (1.16.2-arm-linux)
156
+ racc (~> 1.4)
157
+ nokogiri (1.16.2-arm64-darwin)
158
+ racc (~> 1.4)
159
+ nokogiri (1.16.2-x86-linux)
160
+ racc (~> 1.4)
161
+ nokogiri (1.16.2-x86_64-darwin)
162
+ racc (~> 1.4)
163
+ nokogiri (1.16.2-x86_64-linux)
164
+ racc (~> 1.4)
165
+ psych (5.1.2)
166
+ stringio
167
+ public_suffix (5.0.4)
168
+ puma (6.4.2)
169
+ nio4r (~> 2.0)
170
+ racc (1.7.3)
171
+ rack (3.0.8)
172
+ rack-session (2.0.0)
173
+ rack (>= 3.0.0)
174
+ rack-test (2.1.0)
175
+ rack (>= 1.3)
176
+ rackup (2.1.0)
177
+ rack (>= 3)
178
+ webrick (~> 1.8)
179
+ rails (7.1.3)
180
+ actioncable (= 7.1.3)
181
+ actionmailbox (= 7.1.3)
182
+ actionmailer (= 7.1.3)
183
+ actionpack (= 7.1.3)
184
+ actiontext (= 7.1.3)
185
+ actionview (= 7.1.3)
186
+ activejob (= 7.1.3)
187
+ activemodel (= 7.1.3)
188
+ activerecord (= 7.1.3)
189
+ activestorage (= 7.1.3)
190
+ activesupport (= 7.1.3)
191
+ bundler (>= 1.15.0)
192
+ railties (= 7.1.3)
193
+ rails-dom-testing (2.2.0)
194
+ activesupport (>= 5.0.0)
195
+ minitest
196
+ nokogiri (>= 1.6)
197
+ rails-html-sanitizer (1.6.0)
198
+ loofah (~> 2.21)
199
+ nokogiri (~> 1.14)
200
+ railties (7.1.3)
201
+ actionpack (= 7.1.3)
202
+ activesupport (= 7.1.3)
203
+ irb
204
+ rackup (>= 1.0.0)
205
+ rake (>= 12.2)
206
+ thor (~> 1.0, >= 1.2.2)
207
+ zeitwerk (~> 2.6)
208
+ rake (13.1.0)
209
+ rdoc (6.6.2)
210
+ psych (>= 4.0.0)
211
+ reline (0.4.2)
212
+ io-console (~> 0.5)
213
+ rest-client (2.1.0)
214
+ http-accept (>= 1.7.0, < 2.0)
215
+ http-cookie (>= 1.0.2, < 2.0)
216
+ mime-types (>= 1.16, < 4.0)
217
+ netrc (~> 0.8)
218
+ retryable (3.0.5)
219
+ ruby2_keywords (0.0.5)
220
+ sprockets (4.2.1)
221
+ concurrent-ruby (~> 1.0)
222
+ rack (>= 2.2.4, < 4)
223
+ sprockets-rails (3.4.2)
224
+ actionpack (>= 5.2)
225
+ activesupport (>= 5.2)
226
+ sprockets (>= 3.0.0)
227
+ sqlite3 (1.7.0-aarch64-linux)
228
+ sqlite3 (1.7.0-arm-linux)
229
+ sqlite3 (1.7.0-arm64-darwin)
230
+ sqlite3 (1.7.0-x86-linux)
231
+ sqlite3 (1.7.0-x86_64-darwin)
232
+ sqlite3 (1.7.0-x86_64-linux)
233
+ stimulus-rails (1.3.3)
234
+ railties (>= 6.0.0)
235
+ stringio (3.1.0)
236
+ thor (1.3.0)
237
+ timeout (0.4.1)
238
+ turbo-rails (1.5.0)
239
+ actionpack (>= 6.0.0)
240
+ activejob (>= 6.0.0)
241
+ railties (>= 6.0.0)
242
+ tzinfo (2.0.6)
243
+ concurrent-ruby (~> 1.0)
244
+ web-console (4.2.1)
245
+ actionview (>= 6.0.0)
246
+ activemodel (>= 6.0.0)
247
+ bindex (>= 0.4.0)
248
+ railties (>= 6.0.0)
249
+ webrick (1.8.1)
250
+ websocket-driver (0.7.6)
251
+ websocket-extensions (>= 0.1.0)
252
+ websocket-extensions (0.1.5)
253
+ zache (0.13.1)
254
+ zeitwerk (2.6.12)
255
+
256
+ PLATFORMS
257
+ aarch64-linux
258
+ arm-linux
259
+ arm64-darwin
260
+ x86-linux
261
+ x86_64-darwin
262
+ x86_64-linux
263
+
264
+ DEPENDENCIES
265
+ bootsnap
266
+ cssbundling-rails
267
+ debug
268
+ descope!
269
+ jbuilder
270
+ jsbundling-rails
271
+ puma (>= 5.0)
272
+ rails (~> 7.1.3)
273
+ sprockets-rails
274
+ sqlite3 (~> 1.4)
275
+ stimulus-rails
276
+ turbo-rails
277
+ tzinfo-data
278
+ web-console
279
+
280
+ RUBY VERSION
281
+ ruby 3.3.0p0
282
+
283
+ BUNDLED WITH
284
+ 2.5.5
@@ -0,0 +1,3 @@
1
+ web: env RUBY_DEBUG_OPEN=true bin/rails server
2
+ js: yarn build --watch
3
+ css: yarn watch:css
@@ -0,0 +1,54 @@
1
+ # Descope Ruby On Rails API Example
2
+
3
+ Rails-React Sample app with Descope Auth
4
+ Add Descope's Ruby SDK to add authentication to a Rails 7 + React.js app. The project will feature multiple pages, protected routes, and logout functionality
5
+
6
+ ## ⚙️ Setup
7
+
8
+ 1. Install dependencies:
9
+
10
+ ```
11
+ bundle install
12
+ ```
13
+
14
+ 3. Client Setup
15
+
16
+ Create a ```.env``` file in the root directory of the `client` folder and add your Descope [Project ID](https://app.descope.com/settings/project) in the file:
17
+
18
+ ```
19
+ REACT_APP_PROJECT_ID="YOUR_DESCOPE_PROJECT_ID"
20
+ ```
21
+
22
+ > **NOTE**: If you're running your flask server on a different port than 3000, change the ```"proxy":"http://127.0.0.1:3000/"``` value to wherever your server is hosted. You can edit the proxy value in your client package.json file.
23
+
24
+ 4. Server Setup
25
+
26
+ Since this app also showcases roles, it will require you to set them up in the Descope Console.
27
+
28
+ - Create two different [roles]((https://app.descope.com/authorization)) called "teacher" and "student" <br>
29
+ - Create a ```.env``` file in the server folder and add your project id in the file:
30
+ ```
31
+ PROJECT_ID="YOUR_DESCOPE_PROJECT_ID"
32
+ ```
33
+
34
+ ## 🔮 Running the Application
35
+
36
+ To run the server:
37
+
38
+ ```
39
+ ./bin/dev
40
+ ```
41
+
42
+ ## 📁 Folder Structure
43
+
44
+ - Server: the server folder contains the rails app and server that will handle session validation
45
+ - React App in the `app/javascript/components` folder
46
+
47
+ ## ⚠️ Issue Reporting
48
+
49
+ For any issues or suggestions, feel free to open an issue in the GitHub repository.
50
+
51
+ ## 📜 License
52
+
53
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
54
+
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative "config/application"
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_tree ../builds
3
+ //= link_style ../stylesheets/application.bootstrap.css