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

[#153072577] First steps to admin app: Base rails app with OAuth #1

Merged
merged 40 commits into from
Dec 14, 2017
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
559d794
rails new
Dec 4, 2017
ee66fb9
Create LICENSE
Dec 4, 2017
b611a66
Remove coffee-rails
camelpunch Dec 4, 2017
6e3d343
Set Ruby version to 2.4.2
camelpunch Dec 4, 2017
13d56e9
CF manifest
camelpunch Dec 4, 2017
0bf1c4a
add ./bin to PATH for direnv users
camelpunch Dec 4, 2017
dfda3e6
Set up / to always redirect to OAUTH_REDIRECT_URL
camelpunch Dec 5, 2017
776877a
clean Gemfile of comments
camelpunch Dec 5, 2017
800b7f6
Remove some gems we don't yet need
camelpunch Dec 5, 2017
714612e
Use omniauth to redirect to UAA
camelpunch Dec 5, 2017
4724cc7
Handle response from UAA, display token.
camelpunch Dec 5, 2017
15c443b
Move before_action to application controller
camelpunch Dec 5, 2017
6f2936a
Tidy up omniauth stuff after spec examples
camelpunch Dec 5, 2017
b7757fc
Switch to capybara
camelpunch Dec 5, 2017
5f15b63
use latest omniauth-uaa-oauth2
camelpunch Dec 5, 2017
709c020
Tidy feature spec
camelpunch Dec 5, 2017
d0c6896
Begin sketching a CF client interface
camelpunch Dec 6, 2017
cfa8756
Fix bundler binstub
camelpunch Dec 6, 2017
7b59785
Skip OmniAuth UAA TLS validation from ENV in dev
camelpunch Dec 6, 2017
222a005
Add Faraday, an HTTP client
camelpunch Dec 6, 2017
231b99e
Use gds-way .editorconfig
Dec 6, 2017
8880207
Construction duck
Dec 7, 2017
4134ee1
Implement basic CF Client for testing token
camelpunch Dec 6, 2017
2e0679b
Ensure token has not expired
henrytk Dec 7, 2017
ef885ec
Rename environment variables for consistancy with other paas-things
Dec 7, 2017
1b2cc9c
skip integration tests unless CONTRACT_TEST_TOKEN
Dec 7, 2017
2858637
README and helper scripts
Dec 7, 2017
0cb2c11
Add instructions for running locally
henrytk Dec 8, 2017
2ec41d5
add travis.yml
Dec 8, 2017
eff6e3f
Add/configure rubocop
Dec 11, 2017
b52b35f
Rename Rails.configuration.api_endpoint
Dec 11, 2017
db43048
Enable recormended RSpec defaults
Dec 11, 2017
a6976df
Rubocop corrections
Dec 11, 2017
216d3a1
Enable Rubocop in Travis
Dec 12, 2017
2c0437d
"design mode" RAILS_ENV=design
Dec 12, 2017
02bda56
Ignore vendor dir
Dec 12, 2017
3e5e30b
Favour documentation over scripts/envrc magic
Dec 12, 2017
247d5d5
Optional CF_* env variables for unit tests
Dec 12, 2017
0fa2101
Inherit rubocop config from govuk-lint
Dec 14, 2017
6d68e91
Rubocop fixes after enabling rspec cops.
Dec 14, 2017
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
Binary file added .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PATH_add ./bin
export OAUTH_CLIENT_ID="paas-admin"
export OAUTH_CLIENT_SECRET="oohilovesecrets"
export AUTH_SERVER_URL="https://login.bosh-lite.com"
export TOKEN_SERVER_URL="https://uaa.bosh-lite.com"
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

/node_modules
/yarn-error.log

.byebug_history
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.4.2
27 changes: 27 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
source 'https://rubygems.org'

ruby "2.4.2"

git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end

gem 'rails', '~> 5.1.4'
gem 'puma', '~> 3.7'
gem 'uglifier', '>= 1.3.0'
gem 'omniauth-uaa-oauth2'

group :development, :test do
gem 'pry-byebug'
gem 'rspec-rails'
end

group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
184 changes: 184 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.1.4)
actionpack (= 5.1.4)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.1.4)
actionview (= 5.1.4)
activesupport (= 5.1.4)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.4)
activesupport (= 5.1.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.4)
activesupport (= 5.1.4)
globalid (>= 0.3.6)
activemodel (5.1.4)
activesupport (= 5.1.4)
activerecord (5.1.4)
activemodel (= 5.1.4)
activesupport (= 5.1.4)
arel (~> 8.0)
activesupport (5.1.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (8.0.0)
bindex (0.5.0)
builder (3.2.3)
byebug (9.1.0)
cf-uaa-lib (1.3.10)
multi_json
coderay (1.1.2)
concurrent-ruby (1.0.5)
crass (1.0.3)
diff-lcs (1.3)
erubi (1.7.0)
execjs (2.7.0)
ffi (1.9.18)
globalid (0.4.1)
activesupport (>= 4.2.0)
hashie (3.5.6)
i18n (0.9.1)
concurrent-ruby (~> 1.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.1.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mini_mime (>= 0.1.1)
method_source (0.9.0)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.10.3)
multi_json (1.12.2)
nio4r (2.1.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
omniauth (1.7.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-uaa-oauth2 (0.0.3)
cf-uaa-lib (>= 1.3.1, < 2.0)
omniauth (~> 1.0)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry-byebug (3.5.1)
byebug (~> 9.1)
pry (~> 0.10)
puma (3.11.0)
rack (2.0.3)
rack-test (0.8.2)
rack (>= 1.0, < 3)
rails (5.1.4)
actioncable (= 5.1.4)
actionmailer (= 5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
activemodel (= 5.1.4)
activerecord (= 5.1.4)
activesupport (= 5.1.4)
bundler (>= 1.3.0)
railties (= 5.1.4)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.1.4)
actionpack (= 5.1.4)
activesupport (= 5.1.4)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.0)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rspec-core (3.7.0)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-rails (3.7.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.0)
ruby_dep (1.5.0)
spring (2.0.2)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.20.0)
thread_safe (0.3.6)
tzinfo (1.2.4)
thread_safe (~> 0.1)
uglifier (4.0.1)
execjs (>= 0.3.0, < 3)
web-console (3.5.1)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)

PLATFORMS
ruby

DEPENDENCIES
listen (>= 3.0.5, < 3.2)
omniauth-uaa-oauth2
pry-byebug
puma (~> 3.7)
rails (~> 5.1.4)
rspec-rails
spring
spring-watcher-listen (~> 2.0.0)
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)

RUBY VERSION
ruby 2.4.2p198

BUNDLED WITH
1.16.0
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Government Digital Service

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# README

This README would normally document whatever steps are necessary to get the
application up and running.

Things you may want to cover:

* Ruby version

* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'

Rails.application.load_tasks
3 changes: 3 additions & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
Empty file added app/assets/images/.keep
Empty file.
14 changes: 14 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require rails-ujs
//= require_tree .
13 changes: 13 additions & 0 deletions app/assets/javascripts/cable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
//
//= require action_cable
//= require_self
//= require_tree ./channels

(function() {
this.App || (this.App = {});

App.cable = ActionCable.createConsumer();

}).call(this);
Empty file.
15 changes: 15 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
4 changes: 4 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
4 changes: 4 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
3 changes: 3 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
end
Empty file added app/controllers/concerns/.keep
Empty file.
5 changes: 5 additions & 0 deletions app/controllers/orgs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class OrgsController < ApplicationController
def index
redirect_to '/auth/cloudfoundry'
end
end
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ApplicationHelper
end
2 changes: 2 additions & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ApplicationJob < ActiveJob::Base
end
4 changes: 4 additions & 0 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: '[email protected]'
layout 'mailer'
end
Empty file added app/models/concerns/.keep
Empty file.
14 changes: 14 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>PaasAdmin</title>
<%= csrf_meta_tags %>

<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'application' %>
</head>

<body>
<%= yield %>
</body>
</html>
Loading