mirror of https://github.com/codevalet/codevalet
Add a profile page to make navigating in and out of Jenkins easier
The OAuth Matryoshka process is unfortunately too error prone :-/
This commit is contained in:
parent
2d3d417eed
commit
28c402a639
|
@ -51,37 +51,54 @@ module CodeValet
|
|||
|
||||
get '/' do
|
||||
unless env['warden'].user.nil?
|
||||
redirect_path = 'securityRealm/commenceLogin?from=%2Fblue'
|
||||
login = env['warden'].user.login
|
||||
if production?
|
||||
redirect to("http://#{login}.codevalet.io/#{redirect_path}")
|
||||
else
|
||||
redirect to("http://localhost:8080/#{redirect_path}")
|
||||
end
|
||||
redirect to('/profile')
|
||||
else
|
||||
haml :index, :locals => {:monkeys => masters}
|
||||
haml :index, :layout => :_base, :locals => {:monkeys => masters}
|
||||
end
|
||||
end
|
||||
|
||||
get '/profile' do
|
||||
unless env['warden'].user
|
||||
redirect to('/')
|
||||
else
|
||||
haml :profile, :layout => :_base, :locals => {:user => env['warden'].user}
|
||||
end
|
||||
end
|
||||
|
||||
get '/login' do
|
||||
env['warden'].authenticate!
|
||||
redirect to('/')
|
||||
redirect to('/profile')
|
||||
end
|
||||
|
||||
get '/github/authenticate' do
|
||||
# If we get to this point and have ?code then we're probably authing
|
||||
# for Jenkins and have bounced through the matryoshka doll already
|
||||
if params['code']
|
||||
redirect_path = "securityRealm/finishLogin?code=#{params[:code]}"
|
||||
puts request.inspect
|
||||
env['warden'].authenticate!
|
||||
|
||||
if session[:jenkins] && env['warden'].user
|
||||
session[:jenkins] = nil
|
||||
redirect_path = "securityRealm/finishLogin?from=%2Fblue&#{env['QUERY_STRING']}"
|
||||
href = "http://localhost:8080/#{redirect_path}"
|
||||
login = env['warden'].user.login
|
||||
if production?
|
||||
redirect to("http://#{login}.codevalet.io/#{redirect_path}")
|
||||
else
|
||||
redirect to("http://localhost:8080/#{redirect_path}")
|
||||
href = "http://#{login}.codevalet.io/#{redirect_path}"
|
||||
end
|
||||
else
|
||||
redirect '/'
|
||||
redirect to(href)
|
||||
end
|
||||
redirect '/profile'
|
||||
end
|
||||
|
||||
get '/_to/jenkins' do
|
||||
unless env['warden'].user
|
||||
redirect to('/')
|
||||
end
|
||||
session[:jenkins] = true
|
||||
login = env['warden'].user.login
|
||||
redirect_path = 'securityRealm/commenceLogin?from=%2Fblue'
|
||||
href = "http://localhost:8080/#{redirect_path}"
|
||||
if production?
|
||||
href = "http://#{login}.codevalet.io/#{redirect_path}"
|
||||
end
|
||||
redirect to(href)
|
||||
end
|
||||
|
||||
get '/github/logout' do
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
!!! XML
|
||||
!!!
|
||||
%html
|
||||
%head
|
||||
%meta{:name => 'referrer', :content => 'no-referrer'}/
|
||||
%link{:rel => 'stylesheet',
|
||||
:href => 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css',
|
||||
:integrity => 'sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ',
|
||||
:crossorigin => 'anonymous'}/
|
||||
%script{:src => 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js',
|
||||
:crossorigin => 'anonymous',
|
||||
:integrity => 'sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn'}
|
||||
%meta{:charset => 'utf-8'}/
|
||||
%meta{:name => 'viewport',
|
||||
:content => 'width=device-width, initial-scale=1, shrink-to-fit=no'}/
|
||||
%title
|
||||
Code Valet
|
||||
%body
|
||||
%nav.navbar.navbar-inverse.bg-danger.navbar-toggleable
|
||||
%a.navbar-brand{:href => '/'}
|
||||
%img{:src => '/images/monkey-128.png',
|
||||
:width => '50', :height => '50', :alt => 'Max the Code Valet'}/
|
||||
Code Valet
|
||||
.navbar-collapse
|
||||
.navbar-nav
|
||||
- if env['warden'].user
|
||||
%a.nav-item.active.nav-link{:href => '/profile'}
|
||||
Profile
|
||||
%a.nav-item.nav-link{:href => '/github/logout'}
|
||||
Logout
|
||||
- else
|
||||
%a.nav-item.active.nav-link{:href => '/login'}
|
||||
Log in
|
||||
|
||||
.container.mt-5
|
||||
= yield
|
|
@ -1,62 +1,28 @@
|
|||
!!! XML
|
||||
!!!
|
||||
%html
|
||||
%head
|
||||
%meta{:name => 'referrer', :content => 'no-referrer'}/
|
||||
%link{:rel => 'stylesheet',
|
||||
:href => 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css',
|
||||
:integrity => 'sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ',
|
||||
:crossorigin => 'anonymous'}/
|
||||
%script{:src => 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js',
|
||||
:crossorigin => 'anonymous',
|
||||
:integrity => 'sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn'}
|
||||
%meta{:charset => 'utf-8'}/
|
||||
%meta{:name => 'viewport',
|
||||
:content => 'width=device-width, initial-scale=1, shrink-to-fit=no'}/
|
||||
%title
|
||||
Code Valet
|
||||
%body
|
||||
%nav.navbar.navbar-inverse.bg-danger.navbar-toggleable
|
||||
%a.navbar-brand{:href => '/'}
|
||||
%img{:src => '/images/monkey-128.png',
|
||||
:width => '50', :height => '50', :alt => 'Max the Code Valet'}/
|
||||
Code Valet
|
||||
.navbar-collapse
|
||||
.navbar-nav
|
||||
- if env['warden'].user
|
||||
= env['warden'].user.login
|
||||
%a.nav-item.active.nav-link{:href => '/github/logout'}
|
||||
Logout
|
||||
- else
|
||||
%a.nav-item.active.nav-link{:href => '/login'}
|
||||
Log in
|
||||
|
||||
.container.mt-5
|
||||
%div
|
||||
%h2
|
||||
Meet Code Valet
|
||||
%p
|
||||
Code Valet is a free service which provides basic CI/CD tools for
|
||||
open source developers, via
|
||||
%a{:href => 'https://jenkins.io'}
|
||||
Jenkins 2
|
||||
with
|
||||
%a{:href => 'https://jenkins.io/doc/book/pipeline'}
|
||||
Jenkins Pipeline
|
||||
and
|
||||
%a{:href => 'https://jenkins.io/project/blueocean'}
|
||||
Blue Ocean.
|
||||
%p
|
||||
Utilizing a regularly updated "Jenkins distribution," consisting of
|
||||
many commonly used plugins built from their "master" branches, Code
|
||||
Valet also aims to provide the Jenkins project with rapid feedback
|
||||
based on real-world usage of Jenkins.
|
||||
.container
|
||||
%h2
|
||||
Users
|
||||
%ul
|
||||
- monkeys.each do |monkey|
|
||||
%li
|
||||
%a{:href => "http://#{monkey}.codevalet.io/blue"}
|
||||
= monkey
|
||||
.container
|
||||
%h2
|
||||
Meet Code Valet
|
||||
%p
|
||||
Code Valet is a free service which provides basic CI/CD tools for
|
||||
open source developers, via
|
||||
%a{:href => 'https://jenkins.io'}
|
||||
Jenkins 2
|
||||
with
|
||||
%a{:href => 'https://jenkins.io/doc/book/pipeline'}
|
||||
Jenkins Pipeline
|
||||
and
|
||||
%a{:href => 'https://jenkins.io/project/blueocean'}
|
||||
Blue Ocean.
|
||||
%p
|
||||
Utilizing a regularly updated "Jenkins distribution," consisting of
|
||||
many commonly used plugins built from their "master" branches, Code
|
||||
Valet also aims to provide the Jenkins project with rapid feedback
|
||||
based on real-world usage of Jenkins.
|
||||
.container
|
||||
%h2
|
||||
Users
|
||||
%ul
|
||||
- monkeys.each do |monkey|
|
||||
%li
|
||||
%a{:href => "http://#{monkey}.codevalet.io/blue"}
|
||||
= monkey
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
.contaienr
|
||||
%p
|
||||
Hello #{user.login}
|
||||
%p
|
||||
%a{:href => '/_to/jenkins'}
|
||||
Log into Jenkins
|
||||
.container
|
||||
.row
|
||||
.col-md-6
|
||||
%h2
|
||||
Recent Updates
|
||||
%ul
|
||||
%li
|
||||
Nothing new to report!
|
||||
.col-md-6
|
||||
%h2
|
||||
Usage
|
||||
%p
|
||||
Infinity!
|
Loading…
Reference in New Issue