Merge branch 'add-basic-auth' into 'master'
protect all API routes with basic auth See merge request saburly/gangsta/roraccounting!4
This commit was merged in pull request #4.
This commit is contained in:
2
Procfile
Normal file
2
Procfile
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
web: bundle exec rails s
|
||||||
|
release: bundle exec rails db:migrate
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
class ApplicationController < ActionController::API
|
class ApplicationController < ActionController::API
|
||||||
include Response
|
include Response
|
||||||
|
include BasicAuth
|
||||||
end
|
end
|
||||||
|
|||||||
9
app/controllers/concerns/basic_auth.rb
Normal file
9
app/controllers/concerns/basic_auth.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
module BasicAuth
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
include ActionController::HttpAuthentication::Basic::ControllerMethods
|
||||||
|
http_basic_authenticate_with name: ENV['BASIC_AUTH_USERNAME'],
|
||||||
|
password: ENV['BASIC_AUTH_PASSWORD']
|
||||||
|
end
|
||||||
|
end
|
||||||
17
app/controllers/static_controller.rb
Normal file
17
app/controllers/static_controller.rb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
class StaticController < ActionController::API
|
||||||
|
include ActionView::Layouts
|
||||||
|
include BasicAuth
|
||||||
|
|
||||||
|
def frontend_index_html
|
||||||
|
if params[:path].present?
|
||||||
|
send_file params[:path]
|
||||||
|
else
|
||||||
|
render file: 'protected_public/index.html'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def frontend_static
|
||||||
|
full_path = "protected_public/#{params[:path]}.#{params[:format]}"
|
||||||
|
send_file full_path
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
Learn how to configure a non-root public URL by running `npm run build`.
|
Learn how to configure a non-root public URL by running `npm run build`.
|
||||||
-->
|
-->
|
||||||
<!-- Import Google Icon Font -->
|
<!-- Import Google Icon Font -->
|
||||||
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
|
||||||
<!-- Compiled and minified CSS -->
|
<!-- Compiled and minified CSS -->
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ Rails.application.routes.draw do
|
|||||||
get 'cash'
|
get 'cash'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
|
||||||
|
get '*path', to: 'static#frontend_static'
|
||||||
|
root to: 'static#frontend_index_html'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
{
|
{
|
||||||
|
"engines": {
|
||||||
|
"node": "10.15.3",
|
||||||
|
"yarn": "1.15.2"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "yarn --cwd client install && yarn --cwd client build",
|
||||||
|
"deploy": "cp -a client/build/. protected_public/",
|
||||||
|
"heroku-postbuild": "yarn build && yarn deploy"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react-router-dom": "^5.0.1"
|
"react-router-dom": "^5.0.1"
|
||||||
}
|
}
|
||||||
|
|||||||
0
protected_public/.gitkeep
Normal file
0
protected_public/.gitkeep
Normal file
Reference in New Issue
Block a user