-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autolab config master cherrypick (#2028)
* Create Autolab configure tabs (#1825) * Create Autolab configure tabs * Delete lti_tool_jwk.json * Delete lti_platform_jwk.json * addressed autolab_config spec nit --------- Co-authored-by: Nicholas Clark <[email protected]> Co-authored-by: Victor Huang <[email protected]> * Google OAuth Config UI (#1870) * Oauth config page UI * OAuth UI config complete * Addressed nit --------- Co-authored-by: Nicholas Clark <[email protected]> * OAuth flow fix (#1892) * Oauth config page UI * OAuth UI config complete * Addressed nit * Overhauled oauth workflow * Fixed new user registration flow * Fixed issue with user confirmation not being overridden by OAuth * Fixed OAuth button on hover color --------- Co-authored-by: Nicholas Clark <[email protected]> * Autolab config UI smtp (#1839) * Create Autolab configure tabs * SMTP config page * SMTP config page implementation complete * Delete lti_platform_jwk.json * Delete lti_tool_jwk.json * Added default_from field to smtp config settings page * Moved default from input to seperate section --------- Co-authored-by: Nicholas Clark <[email protected]> * Add GitHub Configuration Tab to Configure Autolab (#1843) * Adds github integration config form * Add GitHub Configuration Page * Update Github integration documentation * Display current github config * Fixed cherrypick issues * Update Gemfile.lock * Run Rubocop * Undo changes, fix tests * fix admin controller tests * fix lti config controller tests * Remove redundant titles * Remove redundant tags, make file extension of `_lti_integration.html.erb` consistent * Add missing raises * Remove rescue_from * Remove extraneous tmpfile param --------- Co-authored-by: Nicholas Clark <[email protected]> Co-authored-by: Victor Huang <[email protected]> Co-authored-by: Damian Ho <[email protected]> Co-authored-by: Joey Wildman <[email protected]>
- Loading branch information
1 parent
10c2fd9
commit ce0533d
Showing
38 changed files
with
797 additions
and
263 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
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,4 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
$('#config-tabs').tabs(); | ||
$('.collapsible').collapsible(); | ||
}); |
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 @@ | ||
class GithubConfigController < ApplicationController | ||
skip_before_action :set_course | ||
skip_before_action :authorize_user_for_course | ||
skip_before_action :update_persistent_announcements | ||
|
||
action_auth_level :update_config, :administrator | ||
def update_config | ||
required_params = %w[client_id client_secret] | ||
required_params.each do |param| | ||
if params[param].blank? | ||
flash[:error] = "#{param} field was missing" | ||
redirect_to(autolab_config_admin_path(active: :github)) && return | ||
end | ||
end | ||
|
||
Rails.configuration.x.github.client_id = params[:client_id] | ||
Rails.configuration.x.github.client_secret = params[:client_secret] | ||
|
||
yaml_hash = { github: { client_id: params[:client_id], | ||
client_secret: params[:client_secret] } } | ||
File.open("#{Rails.configuration.config_location}/github_config.yml", "w") do |file| | ||
file.write(YAML.dump(yaml_hash.deep_stringify_keys)) | ||
end | ||
|
||
flash[:success] = "Github configuration was successfully updated" | ||
redirect_to autolab_config_admin_path(active: :github) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
require 'action_mailer' | ||
require 'tempfile' | ||
require 'psych' | ||
|
||
class OauthConfigController < ApplicationController | ||
skip_before_action :set_course | ||
skip_before_action :authorize_user_for_course | ||
skip_before_action :update_persistent_announcements | ||
|
||
action_auth_level :update_oauth_config, :administrator | ||
def update_oauth_config | ||
required_params = %w[provider client_id client_secret] | ||
required_params.each do |param| | ||
if params[param].blank? | ||
flash[:error] = "#{param} field was missing" | ||
redirect_to(autolab_config_admin_path(active: :oauth)) && return | ||
end | ||
end | ||
|
||
yaml_hash = {} | ||
if File.exist?("#{Rails.configuration.config_location}/oauth_config.yml") | ||
yaml_hash = YAML.safe_load( | ||
File.read("#{Rails.configuration.config_location}/oauth_config.yml") | ||
) | ||
end | ||
|
||
yaml_hash[params[:provider]] = { | ||
client_id: params[:client_id], | ||
client_secret: params[:client_secret] | ||
} | ||
|
||
Rails.cache.write(:oauth_config, yaml_hash.deep_symbolize_keys!) | ||
|
||
File.open("#{Rails.configuration.config_location}/oauth_config.yml", "w") do |file| | ||
file.write(YAML.dump(yaml_hash.deep_stringify_keys)) | ||
end | ||
|
||
flash[:success] = "OAuth Config successfully updated" | ||
|
||
redirect_to autolab_config_admin_path(active: :oauth) | ||
end | ||
|
||
def self.get_oauth_providers | ||
Rails.cache.fetch(:oauth_providers) do | ||
return [] unless File.exist?("#{Rails.configuration.config_location}/oauth_config.yml") | ||
|
||
config_hash = YAML.safe_load( | ||
File.read("#{Rails.configuration.config_location}/oauth_config.yml") | ||
).deep_symbolize_keys! | ||
|
||
providers = [] | ||
config_hash.each do |provider, _| | ||
providers.append provider | ||
end | ||
|
||
providers | ||
end | ||
end | ||
|
||
def self.get_oauth_credentials(provider) | ||
oauth_config = Rails.cache.fetch(:oauth_config) do | ||
return {} unless File.exist?("#{Rails.configuration.config_location}/oauth_config.yml") | ||
|
||
YAML.safe_load( | ||
File.read("#{Rails.configuration.config_location}/oauth_config.yml") | ||
).deep_symbolize_keys! | ||
end | ||
|
||
return {} unless oauth_config.key? provider | ||
|
||
oauth_config[provider] | ||
end | ||
end |
Oops, something went wrong.