Skip to content

Commit 906bbd0

Browse files
author
Max S. Feinberg
committed
Github Authentication
In order to get private repos, a github autenticatio was added. Many thiiiiings are hackish. Needs a lot of improvements but it's too late and the boogeyman can get this time.
1 parent 8d2745b commit 906bbd0

File tree

20 files changed

+467
-48
lines changed

20 files changed

+467
-48
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ capybara-*.html
1111
**.orig
1212
rerun.txt
1313
pickle-email-*.html
14-
14+
.tern-port
1515
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
1616
config/initializers/secret_token.rb
1717
config/secrets.yml
1818

1919
# dotenv
2020
# TODO Comment out this rule if environment variables can be committed
2121
.env
22-
22+
dev.env
2323
## Environment normalization:
2424
/.bundle
2525
/vendor/bundle

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ gem 'jbuilder', '~> 2.5'
1616
gem 'bcrypt', '~> 3.1.7'
1717
gem 'pg'
1818
gem 'react_on_rails', '~> 6.5', '>= 6.5.1'
19+
gem 'omniauth'
20+
gem 'omniauth-github'
21+
gem 'httparty'
1922

2023
group :production, :staging do
2124
gem 'rails_12factor'

Gemfile.lock

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@ GEM
5858
diff-lcs (1.3)
5959
erubis (2.7.0)
6060
execjs (2.7.0)
61+
faraday (0.11.0)
62+
multipart-post (>= 1.2, < 3)
6163
ffi (1.9.18)
6264
foreman (0.83.0)
6365
thor (~> 0.19.1)
6466
globalid (0.3.7)
6567
activesupport (>= 4.1.0)
68+
hashie (3.5.5)
69+
httparty (0.14.0)
70+
multi_xml (>= 0.5.2)
6671
i18n (0.8.1)
6772
jbuilder (2.6.3)
6873
activesupport (>= 3.0.0, < 5.2)
@@ -71,7 +76,8 @@ GEM
7176
rails-dom-testing (>= 1, < 3)
7277
railties (>= 4.2.0)
7378
thor (>= 0.14, < 2.0)
74-
libv8 (5.3.332.38.5-x86_64-linux)
79+
jwt (1.5.6)
80+
libv8 (5.3.332.38.5)
7581
listen (3.0.8)
7682
rb-fsevent (~> 0.9, >= 0.9.4)
7783
rb-inotify (~> 0.9, >= 0.9.7)
@@ -88,9 +94,26 @@ GEM
8894
libv8 (~> 5.3)
8995
minitest (5.10.1)
9096
multi_json (1.12.1)
97+
multi_xml (0.6.0)
98+
multipart-post (2.0.0)
9199
nio4r (2.0.0)
92100
nokogiri (1.7.1)
93101
mini_portile2 (~> 2.1.0)
102+
oauth2 (1.3.1)
103+
faraday (>= 0.8, < 0.12)
104+
jwt (~> 1.0)
105+
multi_json (~> 1.3)
106+
multi_xml (~> 0.5)
107+
rack (>= 1.2, < 3)
108+
omniauth (1.6.1)
109+
hashie (>= 3.4.6, < 3.6.0)
110+
rack (>= 1.6.2, < 3)
111+
omniauth-github (1.2.3)
112+
omniauth (~> 1.5)
113+
omniauth-oauth2 (>= 1.4.0, < 2.0)
114+
omniauth-oauth2 (1.4.0)
115+
oauth2 (~> 1.0)
116+
omniauth (~> 1.2)
94117
pg (0.20.0)
95118
pry (0.10.4)
96119
coderay (~> 1.1.0)
@@ -212,10 +235,13 @@ DEPENDENCIES
212235
coffee-rails (~> 4.2)
213236
database_cleaner
214237
foreman
238+
httparty
215239
jbuilder (~> 2.5)
216240
jquery-rails
217241
listen (~> 3.0.5)
218242
mini_racer
243+
omniauth
244+
omniauth-github
219245
pg
220246
pry
221247
puma (~> 3.0)
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
//= require vendor-bundle
2-
//= require app-bundle
31
//= require application_non_webpack
42
//= require highlight

app/assets/stylesheets/landing.scss

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
background-color: rgba(70,208,237,0.15);
44
height: 210px;
55
position: relative;
6+
display: flex;
7+
justify-content: center;
68

79
&__container {
810
display: flex;
@@ -21,8 +23,8 @@
2123
}
2224

2325
&__logo {
24-
margin: 131px auto;
2526
z-index: 12;
27+
margin: 127px auto;
2628

2729
img {
2830
display: flex;
@@ -345,18 +347,31 @@
345347
padding: 20px 0;
346348
}
347349

348-
&__input,
349-
&__input:focus{
350-
background-color: #ECF4FF;
351-
width: 542px;
352-
outline: none;
353-
border-radius: 10px;
354-
border: 2px solid #0066ee;
355-
font-size: 24px;
356-
line-height: 70px;
357-
padding: 5px 10px;
350+
&__container {
358351
margin: 53px 0 104px 0;
359-
text-align: center;
352+
display: flex;
353+
354+
div {
355+
display: flex;
356+
}
357+
358+
&__input,
359+
&__input:focus{
360+
background-color: #ECF4FF;
361+
width: 542px;
362+
outline: none;
363+
border-radius: 10px;
364+
border: 2px solid #0066ee;
365+
font-size: 24px;
366+
line-height: 70px;
367+
padding: 5px 10px;
368+
text-align: center;
369+
}
370+
a {
371+
display: flex;
372+
align-items: center;
373+
margin: auto auto auto 20px;
374+
}
360375
}
361376
}
362377

app/controllers/landing_controller.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'httparty'
2+
13
class LandingController < ApplicationController
24
def index
35
@state = {
@@ -7,4 +9,38 @@ def index
79
dockercompose: ''
810
}
911
end
12+
13+
def callback
14+
@state = {
15+
repository: '',
16+
repositories: repositories,
17+
dockerfile: '',
18+
dockercompose: ''
19+
}
20+
end
21+
22+
private
23+
24+
def repositories
25+
repos = HTTParty.get('https://api.github.com/user/repos', headers: { 'Authorization': "token #{token}", 'User-Agent': 'WhalesIL' })
26+
27+
repos.map do |repo|
28+
key = "#{repo["html_url"]}.git"
29+
array_repo = repo["html_url"].split("https://")
30+
value = "https://#{token}@#{array_repo.last}.git"
31+
32+
{
33+
key: key,
34+
value: value
35+
}
36+
end
37+
end
38+
39+
def omniauth
40+
request.env['omniauth.auth']
41+
end
42+
43+
def token
44+
omniauth['credentials']['token']
45+
end
1046
end

0 commit comments

Comments
 (0)