Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up after #106 #112

Merged
merged 5 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Scimitar.engine_configuration = Scimitar::EngineConfiguration.new({

When it comes to token access, Scimitar neither enforces nor presumes any kind of encoding for bearer tokens. You can use anything you like, including encoding/encrypting JWTs if you so wish - https://rubygems.org/gems/jwt may be useful. The way in which a client might integrate with your SCIM service varies by client and you will have to check documentation to see how a token gets conveyed to that client in the first place (e.g. a full OAuth flow with your application, or just a static token generated in some UI which an administrator copies and pastes into their client's SCIM configuration UI).

**Important:** Under Rails 7 or later, you may need to wrap any Scimitar configuration with `Rails.application.config.to_prepare do...` to avoid `NameError: uninitialized constant...` exceptions arising due to autoloader problems:
**Strongly recommended:** You should wrap any Scimitar configuration with `Rails.application.config.to_prepare do...` so that any changes you make to configuration during local development are reflected via auto-reload, rather than requiring a server restart.

```ruby
Rails.application.config.to_prepare do
Expand All @@ -89,6 +89,8 @@ Rails.application.config.to_prepare do
end
```

In general, Scimitar's own development and tests assume this approach. If you choose to put the configuration directly into an initializer file without the `to_prepare` wrapper, you will be at a _slightly_ higher risk of tripping over unrecognised Scimitar bugs; please make sure that your own application test coverage is reasonably comprehensive.

### Routes

For each resource you support, add these lines to your `routes.rb`:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require_dependency "scimitar/application_controller"

module Scimitar

# An ActiveRecord-centric subclass of Scimitar::ResourcesController. See that
Expand All @@ -19,7 +17,7 @@ module Scimitar
#
class ActiveRecordBackedResourcesController < ResourcesController

rescue_from ActiveRecord::RecordNotFound, with: :handle_resource_not_found # See Scimitar::ApplicationController
rescue_from 'ActiveRecord::RecordNotFound', with: :handle_resource_not_found # See Scimitar::ApplicationController

before_action :obtain_id_column_name_from_attribute_map

Expand Down
2 changes: 0 additions & 2 deletions app/controllers/scimitar/resource_types_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require_dependency "scimitar/application_controller"

module Scimitar
class ResourceTypesController < ApplicationController
def index
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/scimitar/resources_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require_dependency "scimitar/application_controller"

module Scimitar

# A Rails controller which is mostly idiomatic, with #index, #show, #create
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/scimitar/schemas_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require_dependency "scimitar/application_controller"

module Scimitar
class SchemasController < ApplicationController
def index
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require_dependency "scimitar/application_controller"
module Scimitar
class ServiceProviderConfigurationsController < ApplicationController
def show
Expand Down
7 changes: 7 additions & 0 deletions lib/scimitar/engine.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
require 'rails/engine'

module Scimitar
class Engine < ::Rails::Engine
isolate_namespace Scimitar

config.autoload_once_paths = %W(
#{root}/app/controllers
#{root}/app/models
)

Mime::Type.register 'application/scim+json', :scim

ActionDispatch::Request.parameter_parsers[Mime::Type.lookup('application/scim+json').symbol] = lambda do |body|
Expand Down
Loading