Skip to content

Commit 29f2eb5

Browse files
Fix merging issue
1 parent b386330 commit 29f2eb5

22 files changed

+128776
-9
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Dev Pipeline - Deploy to Azure Web App Service"
2+
on:
3+
push:
4+
branches: [ "User-Login" ]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- uses: azure/docker-login@v1
13+
with:
14+
login-server: ideal.azurecr.io
15+
username: ${{ secrets.AZURE_REGISTRY_USERNAME }}
16+
password: ${{ secrets.AZURE_REGISTRY_PASSWORD }}
17+
18+
- name: Build the Docker image and Push to Azure Container Registry
19+
working-directory: ./app
20+
run: |
21+
docker build . -t ideal.azurecr.io/ideals:${{ github.sha }}
22+
docker push ideal.azurecr.io/ideals:${{ github.sha }}
23+
24+
- uses: azure/webapps-deploy@v2
25+
with:
26+
app-name: 'ideals-dev'
27+
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
28+
images: 'ideal.azurecr.io/ideals:${{ github.sha }}'

.github/workflows/development-pipeline.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ jobs:
3030
run: bin/rails generate rspec:install
3131
- name: Run tests
3232
run: bin/rake
33-
- name: Upload coverage reports to Codecov
34-
uses: codecov/codecov-action@v3
3533
build:
3634
runs-on: ubuntu-latest
3735
steps:

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
1-
# ideals
1+
# IDEALS [:anger:](https://idealmaps.xyz)
22

3-
[![CI Pipeline - DEV](https://github.com/Proj-IDEALS/ideals/actions/workflows/dev-pipeline.yml/badge.svg)](https://github.com/Proj-IDEALS/ideals/actions/workflows/dev-pipeline.yml)
3+
## _Highly-interactive concept map of relationships between learning theories_
4+
5+
[![CI Pipeline - DEVELOPMENT](https://github.com/Proj-IDEALS/ideals/actions/workflows/development-pipeline.yml/badge.svg)](https://github.com/Proj-IDEALS/ideals/actions/workflows/development-pipeline.yml) [![CI/CD Pipeline - RELEASE](https://github.com/Proj-IDEALS/ideals/actions/workflows/release-pipeline.yml/badge.svg)](https://github.com/Proj-IDEALS/ideals/actions/workflows/release-pipeline.yml) [![Dev Pipeline - Deploy to Azure Web App Service](https://github.com/Proj-IDEALS/ideals/actions/workflows/Deploy-to-azure-dev.yml/badge.svg)](https://github.com/Proj-IDEALS/ideals/actions/workflows/Deploy-to-azure-dev.yml)
6+
7+
8+
## Usage
9+
10+
#### With Docker-compose
11+
IDEALS uses Rails + Docker for fast development.
12+
Make a change in your file and instantaneously see your updates!
13+
14+
Open your favourite Terminal and run these commands.
15+
16+
```sh
17+
git clone https://github.com/Proj-IDEALS/ideals.git
18+
cd ideals
19+
docker-compose -f docker-compose.dev.yml up --build
20+
```
21+
22+
#### Without Docker-compose
23+
##### Prerequisites
24+
Make sure you have installed all of the following prerequisites on your development machine:
25+
* Git - [Download & Install Git](https://git-scm.com/downloads). OSX and Linux machines typically have this already installed.
26+
* Ruby - [Download & Install Ruby](https://www.ruby-lang.org/en/documentation/installation/). OSX machines typically have this already installed.
27+
* Rails - [Download & Install Rails](https://guides.rubyonrails.org/v5.1/getting_started.html#installing-rails)
28+
* npm - [Download & Install npm](https://nodejs.org/en/download/)
29+
30+
```sh
31+
git clone https://github.com/Proj-IDEALS/ideals.git
32+
cd ideals/app
33+
bundle install
34+
bundle exec rails server -b 0.0.0.0
35+
```
36+
> Note: `export NODE_OPTIONS=--openssl-legacy-provider` is required if the webpack fails with code: 'ERR_OSSL_EVP_UNSUPPORTED'.
437
5-
[![CI/CD Pipeline - RELEASE](https://github.com/Proj-IDEALS/ideals/actions/workflows/release-pipeline.yml/badge.svg)](https://github.com/Proj-IDEALS/ideals/actions/workflows/release-pipeline.yml)

app/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ WORKDIR $INSTALL_PATH
1515
COPY . .
1616
RUN rm -rf node_modules vendor
1717
RUN gem install rails bundler
18+
RUN bundle update rack-protection
1819
RUN bundle install
1920
RUN yarn install
2021

app/Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,10 @@ gem 'rubocop', require: false
7979
gem 'unicorn', '~> 6.1.0'
8080
gem 'sidekiq', '~> 6.4.2'
8181
gem 'redis-rails', '~> 5.0.2'
82+
83+
#login
84+
gem 'omniauth-auth0', '~> 3.0'
85+
gem 'omniauth-rails_csrf_protection', '~> 1.0' # prevents forged authentication requests
86+
8287
gem 'webpacker'
8388
gem 'react-rails'

app/Gemfile.lock

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ GEM
154154
erubi (1.12.0)
155155
eventmachine (1.2.7)
156156
execjs (2.8.1)
157+
faraday (2.7.4)
158+
faraday-net_http (>= 2.0, < 3.1)
159+
ruby2_keywords (>= 0.0.4)
160+
faraday-net_http (3.0.2)
157161
ffi (1.15.5)
158162
formatador (1.1.0)
159163
gem_update_checker (0.2.0)
@@ -175,6 +179,7 @@ GEM
175179
guard-compat (~> 1.0)
176180
multi_json (~> 1.8)
177181
hashdiff (1.0.1)
182+
hashie (5.0.0)
178183
http_parser.rb (0.8.0)
179184
i18n (1.12.0)
180185
concurrent-ruby (~> 1.0)
@@ -188,6 +193,7 @@ GEM
188193
actionview (>= 5.0.0)
189194
activesupport (>= 5.0.0)
190195
json (2.6.3)
196+
jwt (2.7.0)
191197
kgio (2.11.4)
192198
listen (3.8.0)
193199
rb-fsevent (~> 0.10, >= 0.10.3)
@@ -212,6 +218,7 @@ GEM
212218
msgpack (1.6.0)
213219
multi_json (1.15.0)
214220
multi_test (1.1.0)
221+
multi_xml (0.6.0)
215222
nenv (0.3.0)
216223
net-imap (0.3.4)
217224
date
@@ -232,6 +239,26 @@ GEM
232239
notiffany (0.1.3)
233240
nenv (~> 0.1)
234241
shellany (~> 0.0)
242+
oauth2 (2.0.9)
243+
faraday (>= 0.17.3, < 3.0)
244+
jwt (>= 1.0, < 3.0)
245+
multi_xml (~> 0.5)
246+
rack (>= 1.2, < 4)
247+
snaky_hash (~> 2.0)
248+
version_gem (~> 1.1)
249+
omniauth (2.1.1)
250+
hashie (>= 3.4.6)
251+
rack (>= 2.2.3)
252+
rack-protection
253+
omniauth-auth0 (3.1.0)
254+
omniauth (~> 2)
255+
omniauth-oauth2 (~> 1)
256+
omniauth-oauth2 (1.8.0)
257+
oauth2 (>= 1.4, < 3)
258+
omniauth (~> 2.0)
259+
omniauth-rails_csrf_protection (1.0.1)
260+
actionpack (>= 4.2)
261+
omniauth (~> 2.0)
235262
os (1.1.4)
236263
parallel (1.22.1)
237264
parser (3.2.1.0)
@@ -248,6 +275,8 @@ GEM
248275
rack (2.2.6.2)
249276
rack-livereload (0.3.17)
250277
rack
278+
rack-protection (3.0.5)
279+
rack
251280
rack-proxy (0.7.6)
252281
rack
253282
rack-test (2.0.2)
@@ -346,6 +375,7 @@ GEM
346375
rubocop-ast (1.26.0)
347376
parser (>= 3.2.1.0)
348377
ruby-progressbar (1.11.0)
378+
ruby2_keywords (0.0.5)
349379
rubyzip (2.3.2)
350380
selenium-webdriver (4.8.1)
351381
rexml (~> 3.2, >= 3.2.5)
@@ -357,6 +387,9 @@ GEM
357387
connection_pool (>= 2.2.2)
358388
rack (~> 2.0)
359389
redis (>= 4.2.0)
390+
snaky_hash (2.0.1)
391+
hashie
392+
version_gem (~> 1.1, >= 1.1.1)
360393
sprockets (4.2.0)
361394
concurrent-ruby (~> 1.0)
362395
rack (>= 2.2.4, < 4)
@@ -386,6 +419,7 @@ GEM
386419
unicorn (6.1.0)
387420
kgio (~> 2.6)
388421
raindrops (~> 0.7)
422+
version_gem (1.1.1)
389423
web-console (4.2.0)
390424
actionview (>= 6.0.0)
391425
activemodel (>= 6.0.0)
@@ -426,6 +460,8 @@ DEPENDENCIES
426460
guard-livereload (~> 2.5)
427461
importmap-rails
428462
jbuilder
463+
omniauth-auth0 (~> 3.0)
464+
omniauth-rails_csrf_protection (~> 1.0)
429465
puma (~> 5.0)
430466
rack-livereload (~> 0.3.16)
431467
rails (~> 7.0.4, >= 7.0.4.2)

app/app/assets/config/manifest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
//= link boxicons.css
1212
//= link_tree ../../javascript .js
1313
//= link_tree ../../../vendor/javascript .js
14+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
class Auth0Controller < ApplicationController
2+
def callback
3+
# OmniAuth stores the informatin returned from
4+
# Auth0 and the IdP in request.env['omniauth.auth'].
5+
# In this code, you will pull the raw_info supplied
6+
# from the id_token and assign it to the session.
7+
# Refer to https://github.com/auth0/omniauth-auth0/blob/master/EXAMPLES.md#example-of-the-resulting-authentication-hash
8+
# for complete information on 'omniauth.auth' contents.
9+
auth_info = request.env['omniauth.auth']
10+
session[:userinfo] = auth_info['extra']['raw_info']
11+
12+
# Redirect to the URL you want after successful auth
13+
redirect_to '/newobjects'
14+
end
15+
16+
def failure
17+
# Handles failed authentication
18+
@error_msg = request.params['message']
19+
end
20+
21+
def logout
22+
reset_session
23+
redirect_to logout_url, allow_other_host: true
24+
end
25+
26+
private
27+
AUTH0_CONFIG = Rails.application.config_for(:auth0)
28+
29+
def logout_url
30+
request_params = {
31+
returnTo: "https://idealmaps.xyz",
32+
client_id: AUTH0_CONFIG['auth0_client_id']
33+
}
34+
35+
URI::HTTPS.build(host: AUTH0_CONFIG['auth0_domain'], path: '/v2/logout', query: to_query(request_params)).to_s
36+
end
37+
38+
def to_query(hash)
39+
hash.map { |k, v| "#{k}=#{CGI.escape(v)}" unless v.nil? }.reject(&:nil?).join('&')
40+
end
41+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module Secured
2+
extend ActiveSupport::Concern
3+
4+
included do
5+
before_action :logged_in_using_omniauth?
6+
end
7+
8+
def logged_in_using_omniauth?
9+
redirect_to '/' unless session[:userinfo].present?
10+
end
11+
end

app/app/views/newobjects/index.html.erb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
<p style="color: green"><%= notice %></p>
22

3+
<!-- Place a login button anywhere on your application -->
4+
<%= button_to 'Login', '/auth/auth0', method: :post, data: { turbo: false } %>
5+
<!-- Place a logout button anywhere on your application -->
6+
<%= button_to 'Logout', 'auth/logout', method: :get, data: { turbo: false } %>
7+
8+
39
<h1>List of Objects</h1>
410

511
<%= link_to "Create New Object", new_newobject_path %>
612

13+
14+
715
<div id="newobjects">
816
<% @newobjects.each do |newobject| %>
917
<%= render newobject %>

app/config/auth0.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
development:
2+
auth0_domain: ideals.us.auth0.com
3+
auth0_client_id: zVt9TW2CvNPKc6tVavCcpov9pIuOtRxW
4+
auth0_client_secret: 6HFPxe7fKC-oM2FImZcp8FM0YxNfcJwj6-Jr_5KVGI7EHCKfrhpqb78bgyjWSbCW
5+
test:
6+
auth0_domain:
7+
auth0_client_id:
8+
auth0_client_secret:
9+
#Use Duo
10+
#Duo API Endpoint:api-35bcf667.duosecurity.com

app/config/boot.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
22

33
require "bundler/setup" # Set up gems listed in the Gemfile.
4-
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
4+
require "bootsnap/setup" # Speed up boot time by caching expensive operations.

app/config/environments/development.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,7 @@
6868
# Uncomment if you wish to allow Action Cable access from any origin.
6969
# config.action_cable.disable_request_forgery_protection = true
7070
config.hosts << "idealmaps.xyz"
71+
config.hosts << "xytom-cuddly-chainsaw-6p9w7qv79jqc477g-3000.preview.app.github.dev"
72+
config.hosts << "ideals-dev.azurewebsites.net"
73+
7174
end

app/config/initializers/auth0.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ./config/initializers/auth0.rb
2+
AUTH0_CONFIG = Rails.application.config_for(:auth0)
3+
4+
Rails.application.config.middleware.use OmniAuth::Builder do
5+
provider(
6+
:auth0,
7+
AUTH0_CONFIG['auth0_client_id'],
8+
AUTH0_CONFIG['auth0_client_secret'],
9+
AUTH0_CONFIG['auth0_domain'],
10+
callback_path: '/auth/auth0/callback',
11+
authorize_params: {
12+
scope: 'openid profile'
13+
}
14+
)
15+
end

app/config/routes.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
Rails.application.routes.draw do
22
root :to => 'application#index'
33
resources :newobjects
4+
5+
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
6+
7+
# Defines the root path route ("/")
8+
# root "articles#index"
9+
10+
#User Login
11+
get '/auth/auth0/callback' => 'auth0#callback'
12+
get '/auth/failure' => 'auth0#failure'
13+
get '/auth/logout' => 'auth0#logout'
14+
415
resources :map
16+
517
end

0 commit comments

Comments
 (0)