From 7d2655aae78604f8cc09e961868d520b23c102ce Mon Sep 17 00:00:00 2001 From: Ben Rosser Date: Thu, 24 Sep 2015 13:52:20 -0400 Subject: Remove 'kerberos' from auth_helper.rb for gitlab-CE. There is no Kerberos auth in gitlab-ce, so it shouldn't be noted as a form-driven auth mechanism in app/helpers/auth_helper.rb. This breaks using Kerberos as a custom omniauth provider. See issue #2510 --- app/helpers/auth_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/auth_helper.rb b/app/helpers/auth_helper.rb index ce7e9b1db87..cd99a232403 100644 --- a/app/helpers/auth_helper.rb +++ b/app/helpers/auth_helper.rb @@ -1,6 +1,6 @@ module AuthHelper PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2).freeze - FORM_BASED_PROVIDERS = [/\Aldap/, 'kerberos', 'crowd'].freeze + FORM_BASED_PROVIDERS = [/\Aldap/, 'crowd'].freeze def ldap_enabled? Gitlab.config.ldap.enabled -- cgit v1.2.1 From 037defc7def3e2d0f2de4930516149d7567362fc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 28 Sep 2015 17:19:20 +0200 Subject: Move CI variables page to project settings Signed-off-by: Dmitriy Zaporozhets --- CHANGELOG | 1 + app/controllers/ci/variables_controller.rb | 33 ------------------ app/controllers/projects/application_controller.rb | 4 +++ app/controllers/projects/runners_controller.rb | 4 --- app/controllers/projects/variables_controller.rb | 25 ++++++++++++++ app/views/ci/variables/show.html.haml | 39 ---------------------- app/views/layouts/ci/_nav_project.html.haml | 5 --- app/views/layouts/nav/_project_settings.html.haml | 5 +++ app/views/projects/variables/show.html.haml | 39 ++++++++++++++++++++++ config/routes.rb | 2 +- spec/features/ci/variables_spec.rb | 28 ---------------- spec/features/variables_spec.rb | 25 ++++++++++++++ 12 files changed, 100 insertions(+), 110 deletions(-) delete mode 100644 app/controllers/ci/variables_controller.rb create mode 100644 app/controllers/projects/variables_controller.rb delete mode 100644 app/views/ci/variables/show.html.haml create mode 100644 app/views/projects/variables/show.html.haml delete mode 100644 spec/features/ci/variables_spec.rb create mode 100644 spec/features/variables_spec.rb diff --git a/CHANGELOG b/CHANGELOG index a0f1fa12082..7e31c2f57b6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ v 8.1.0 (unreleased) - Add notes and SSL verification entries to hook APIs (Ben Boeckel) - Fix grammar in admin area "labels" .nothing-here-block when no labels exist. - Move CI runners page to project settings area + - Move CI variables page to project settings area v 8.0.3 (unreleased) diff --git a/app/controllers/ci/variables_controller.rb b/app/controllers/ci/variables_controller.rb deleted file mode 100644 index 9c6c775fde8..00000000000 --- a/app/controllers/ci/variables_controller.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Ci - class VariablesController < Ci::ApplicationController - before_action :authenticate_user! - before_action :project - before_action :authorize_access_project! - before_action :authorize_manage_project! - - layout 'ci/project' - - def show - end - - def update - if project.update_attributes(project_params) - Ci::EventService.new.change_project_settings(current_user, project) - - redirect_to ci_project_variables_path(project), notice: 'Variables were successfully updated.' - else - render action: 'show' - end - end - - private - - def project - @project ||= Ci::Project.find(params[:project_id]) - end - - def project_params - params.require(:project).permit({ variables_attributes: [:id, :key, :value, :_destroy] }) - end - end -end diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 48c922f450c..56a63ce9758 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -31,4 +31,8 @@ class Projects::ApplicationController < ApplicationController def ci_enabled return render_404 unless @project.gitlab_ci? end + + def ci_project + @ci_project ||= @project.gitlab_ci_project + end end diff --git a/app/controllers/projects/runners_controller.rb b/app/controllers/projects/runners_controller.rb index d59884a1dd7..6cb6e3ef6d4 100644 --- a/app/controllers/projects/runners_controller.rb +++ b/app/controllers/projects/runners_controller.rb @@ -55,10 +55,6 @@ class Projects::RunnersController < Projects::ApplicationController protected - def ci_project - @ci_project = @project.gitlab_ci_project - end - def set_runner @runner ||= @ci_project.runners.find(params[:id]) end diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb new file mode 100644 index 00000000000..d6561a45a70 --- /dev/null +++ b/app/controllers/projects/variables_controller.rb @@ -0,0 +1,25 @@ +class Projects::VariablesController < Projects::ApplicationController + before_action :ci_project + before_action :authorize_admin_project! + + layout 'project_settings' + + def show + end + + def update + if ci_project.update_attributes(project_params) + Ci::EventService.new.change_project_settings(current_user, ci_project) + + redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Variables were successfully updated.' + else + render action: 'show' + end + end + + private + + def project_params + params.require(:project).permit({ variables_attributes: [:id, :key, :value, :_destroy] }) + end +end diff --git a/app/views/ci/variables/show.html.haml b/app/views/ci/variables/show.html.haml deleted file mode 100644 index ebf68341e08..00000000000 --- a/app/views/ci/variables/show.html.haml +++ /dev/null @@ -1,39 +0,0 @@ -%h3.page-title - Secret Variables - -%p.light - These variables will be set to environment by the runner and will be hidden in the build log. - %br - So you can use them for passwords, secret keys or whatever you want. - -%hr - - -= nested_form_for @project, url: url_for(controller: 'ci/variables', action: 'update'), html: { class: 'form-horizontal' } do |f| - - if @project.errors.any? - #error_explanation - %p.lead= "#{pluralize(@project.errors.count, "error")} prohibited this project from being saved:" - .alert.alert-error - %ul - - @project.errors.full_messages.each do |msg| - %li= msg - - = f.fields_for :variables do |variable_form| - .form-group - = variable_form.label :key, 'Key', class: 'control-label' - .col-sm-10 - = variable_form.text_field :key, class: 'form-control', placeholder: "PROJECT_VARIABLE" - - .form-group - = variable_form.label :value, 'Value', class: 'control-label' - .col-sm-10 - = variable_form.text_area :value, class: 'form-control', rows: 2, placeholder: "" - - = variable_form.link_to_remove "Remove this variable", class: 'btn btn-danger pull-right prepend-top-10' - %hr - %p - .clearfix - = f.link_to_add "Add a variable", :variables, class: 'btn btn-success pull-right' - - .form-actions - = f.submit 'Save changes', class: 'btn btn-save', return_to: request.original_url diff --git a/app/views/layouts/ci/_nav_project.html.haml b/app/views/layouts/ci/_nav_project.html.haml index 9ebe7eabd8e..4b0dc4fc2f5 100644 --- a/app/views/layouts/ci/_nav_project.html.haml +++ b/app/views/layouts/ci/_nav_project.html.haml @@ -11,11 +11,6 @@ %span Commits %span.count= @project.commits.count - = nav_link path: 'variables#show' do - = link_to ci_project_variables_path(@project) do - = icon('code fw') - %span - Variables = nav_link path: 'web_hooks#index' do = link_to ci_project_web_hooks_path(@project) do = icon('link fw') diff --git a/app/views/layouts/nav/_project_settings.html.haml b/app/views/layouts/nav/_project_settings.html.haml index a85dd71126c..c8975fb8492 100644 --- a/app/views/layouts/nav/_project_settings.html.haml +++ b/app/views/layouts/nav/_project_settings.html.haml @@ -40,3 +40,8 @@ = icon('cog fw') %span Runners + = nav_link(controller: :variables) do + = link_to namespace_project_variables_path(@project.namespace, @project) do + = icon('code fw') + %span + Variables diff --git a/app/views/projects/variables/show.html.haml b/app/views/projects/variables/show.html.haml new file mode 100644 index 00000000000..29416a94ff6 --- /dev/null +++ b/app/views/projects/variables/show.html.haml @@ -0,0 +1,39 @@ +%h3.page-title + Secret Variables + +%p.light + These variables will be set to environment by the runner and will be hidden in the build log. + %br + So you can use them for passwords, secret keys or whatever you want. + +%hr + + += nested_form_for @ci_project, url: url_for(controller: 'projects/variables', action: 'update'), html: { class: 'form-horizontal' } do |f| + - if @project.errors.any? + #error_explanation + %p.lead= "#{pluralize(@ci_project.errors.count, "error")} prohibited this project from being saved:" + .alert.alert-error + %ul + - @ci_project.errors.full_messages.each do |msg| + %li= msg + + = f.fields_for :variables do |variable_form| + .form-group + = variable_form.label :key, 'Key', class: 'control-label' + .col-sm-10 + = variable_form.text_field :key, class: 'form-control', placeholder: "PROJECT_VARIABLE" + + .form-group + = variable_form.label :value, 'Value', class: 'control-label' + .col-sm-10 + = variable_form.text_area :value, class: 'form-control', rows: 2, placeholder: "" + + = variable_form.link_to_remove "Remove this variable", class: 'btn btn-danger pull-right prepend-top-10' + %hr + %p + .clearfix + = f.link_to_add "Add a variable", :variables, class: 'btn btn-success pull-right' + + .form-actions + = f.submit 'Save changes', class: 'btn btn-save', return_to: request.original_url diff --git a/config/routes.rb b/config/routes.rb index 201add02335..776b606bf7d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -58,7 +58,6 @@ Gitlab::Application.routes.draw do resources :runner_projects, only: [:create, :destroy] resources :events, only: [:index] - resource :variables, only: [:show, :update] end resource :user_sessions do @@ -591,6 +590,7 @@ Gitlab::Application.routes.draw do resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex } resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex } resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex } + resource :variables, only: [:show, :update] resources :hooks, only: [:index, :create, :destroy], constraints: { id: /\d+/ } do member do diff --git a/spec/features/ci/variables_spec.rb b/spec/features/ci/variables_spec.rb deleted file mode 100644 index e387b3be555..00000000000 --- a/spec/features/ci/variables_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe "Variables" do - let(:user) { create(:user) } - - before do - login_as(user) - end - - describe "specific runners" do - before do - @project = FactoryGirl.create :ci_project - @project.gl_project.team << [user, :master] - end - - it "creates variable", js: true do - visit ci_project_variables_path(@project) - click_on "Add a variable" - fill_in "Key", with: "SECRET_KEY" - fill_in "Value", with: "SECRET_VALUE" - click_on "Save changes" - - expect(page).to have_content("Variables were successfully updated.") - expect(@project.variables.count).to eq(1) - end - - end -end diff --git a/spec/features/variables_spec.rb b/spec/features/variables_spec.rb new file mode 100644 index 00000000000..adb602f3edd --- /dev/null +++ b/spec/features/variables_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe "Variables" do + let(:user) { create(:user) } + before { login_as(user) } + + describe "specific runners" do + before do + @project = FactoryGirl.create :ci_project + @gl_project = @project.gl_project + @gl_project.team << [user, :master] + end + + it "creates variable", js: true do + visit namespace_project_variables_path(@gl_project.namespace, @gl_project) + click_on "Add a variable" + fill_in "Key", with: "SECRET_KEY" + fill_in "Value", with: "SECRET_VALUE" + click_on "Save changes" + + expect(page).to have_content("Variables were successfully updated.") + expect(@project.variables.count).to eq(1) + end + end +end -- cgit v1.2.1