From 95c62e2941f9e189289e340b7b6cbe153550a7e5 Mon Sep 17 00:00:00 2001 From: Peter Bouda Date: Sun, 6 Oct 2024 18:39:16 +0100 Subject: [PATCH] Initial commit --- .gitignore | 3 +++ .../discourse_scim_plugin/scim_controller.rb | 11 ++++++++ config/routes.rb | 24 ++++++++++++++++++ lib/discourse_scim_plugin/engine.rb | 8 ++++++ plugin.rb | 25 +++++++++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 .gitignore create mode 100644 app/controllers/discourse_scim_plugin/scim_controller.rb create mode 100644 config/routes.rb create mode 100644 lib/discourse_scim_plugin/engine.rb create mode 100644 plugin.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..91bbf8e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +/gems +/auto_generated \ No newline at end of file diff --git a/app/controllers/discourse_scim_plugin/scim_controller.rb b/app/controllers/discourse_scim_plugin/scim_controller.rb new file mode 100644 index 0000000..9b40f52 --- /dev/null +++ b/app/controllers/discourse_scim_plugin/scim_controller.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module ::DiscourseScimPlugin + class ScimController < ::ApplicationController + requires_plugin PLUGIN_NAME + + def index + render json: { hello: "world" } + end + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..ea3d31d --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require "scimitar" + +# DiscourseScimPlugin::Engine.routes.draw do +# get "/list" => "scim#index" +# end + +# Discourse::Application.routes.draw { mount ::DiscourseScimPlugin::Engine, at: "/scim" } + +namespace :scim_v2 do + DiscourseScimPlugin::Engine.routes.draw do + get 'Users', to: 'users#index' + get 'Users/:id', to: 'users#show' + post 'Users', to: 'users#create' + put 'Users/:id', to: 'users#replace' + patch 'Users/:id', to: 'users#update' + delete 'Users/:id', to: 'users#destroy' + end + + Discourse::Application.routes.draw { + mount Scimitar::Engine, at: '/scim' + } +end \ No newline at end of file diff --git a/lib/discourse_scim_plugin/engine.rb b/lib/discourse_scim_plugin/engine.rb new file mode 100644 index 0000000..d9b805e --- /dev/null +++ b/lib/discourse_scim_plugin/engine.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module DiscourseScimPlugin + class Engine < ::Rails::Engine + engine_name PLUGIN_NAME + isolate_namespace DiscourseScimPlugin + end +end \ No newline at end of file diff --git a/plugin.rb b/plugin.rb new file mode 100644 index 0000000..9a33b35 --- /dev/null +++ b/plugin.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +# name: discourse-scim-plugin +# about: A plugin to add SCIM endpoints to discourse +# version: 0.0.1 +# authors: Peter Bouda +# url: https://github.com/pbouda/discourse-scim-plugin + +gem 'marcel', '1.0.0', {require: false } +gem 'activestorage', '7.1.4', {require: false } +gem 'actiontext', '7.1.4', {require: false } +gem 'actionmailbox', '7.1.4', {require: false } +gem 'websocket-extensions', '0.1.0', {require: false } +gem 'websocket-driver', '0.6.1', {require: false } +gem 'actioncable', '7.1.4', {require: false } +gem 'rails', '7.1.4', {require: false } +gem 'scimitar', '2.9.0', {require: false } + +require "scimitar" + +module ::DiscourseScimPlugin + PLUGIN_NAME = "scim" + + require_relative "lib/discourse_scim_plugin/engine" +end \ No newline at end of file