This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rbCAS/service-whitelist
Service whitelist
- Loading branch information
Showing
19 changed files
with
362 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Upgrade CASinoCore | ||
|
||
Here is a list of backward-incompatible changes that were introduced. | ||
|
||
## 1.1.0 | ||
|
||
API changes: | ||
|
||
* `login_credential_acceptor`: The parameters of `#process` changed from `params, cookies, user_agent` to just `params, user_agent` | ||
|
||
New callbacks: | ||
|
||
* `login_credential_requestor` calls `#service_not_allowed` on the listener, when a service is not in the service whitelist. | ||
* `api/service_ticket_provider` calls `#service_not_allowed_via_api` on the listener, when a service is not in the service whitelist. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class CreateServiceRules < ActiveRecord::Migration | ||
def change | ||
create_table :service_rules do |t| | ||
t.boolean :enabled, null: false, default: true | ||
t.integer :order, null: false, default: 10 | ||
t.string :name, null: false | ||
t.string :url, null: false | ||
t.boolean :regex, null: false, default: false | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :service_rules, :url, unique: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'casino_core/model' | ||
|
||
class CASinoCore::Model::ServiceRule < ActiveRecord::Base | ||
attr_accessible :enabled, :order, :name, :url, :regex | ||
validates :name, presence: true | ||
validates :url, uniqueness: true, presence: true | ||
|
||
def self.allowed?(service_url) | ||
rules = self.where(enabled: true) | ||
if rules.empty? | ||
true | ||
else | ||
rules.any? { |rule| rule.allows?(service_url) } | ||
end | ||
end | ||
|
||
def allows?(service_url) | ||
if self.regex? | ||
regex = Regexp.new self.url, true | ||
if regex =~ service_url | ||
return true | ||
end | ||
elsif self.url == service_url | ||
return true | ||
end | ||
false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.