-
-
Notifications
You must be signed in to change notification settings - Fork 5
Force all developer application redirect URIs to use HTTPS #145
Changes from 4 commits
293f577
f596cee
52c27db
997ddbc
2426321
749dc9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
class Developers::ApplicationsController < ApplicationController | ||
nested_layouts "layouts/admin" | ||
nested_layouts 'layouts/admin' | ||
|
||
before_action do | ||
@developers = true | ||
end | ||
|
||
before_action except: [:index, :request, :provision, :create] do | ||
before_action except: %i[index request provision create] do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the rationale behind this change, feels less descriptive imo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uhhhh the weird formatter did that |
||
if (current_application.provisional? || current_application.owner_id != current_user.id) && !current_user.admin? | ||
render plain: "403 Forbidden or Provisional Domain", status: 403 | ||
render plain: '403 Forbidden or Provisional Domain', status: 403 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing - will also fail linting |
||
end | ||
end | ||
|
||
before_action only: [:create] do | ||
if !current_user.admin? | ||
render plain: "403 Forbidden", status: 403 | ||
end | ||
render plain: '403 Forbidden', status: 403 unless current_user.admin? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again |
||
end | ||
|
||
def index | ||
|
@@ -44,10 +42,16 @@ def destroy_scope | |
scopes = @application.scopes.to_a | ||
scopes.delete(params[:scope]) | ||
@application.update!(scopes: Doorkeeper::OAuth::Scopes.from_array(scopes)) | ||
redirect_back(fallback_location: developers_applications_path(id: params[:id]), notice: "Destroyed scope #{params[:scope]}") | ||
redirect_back(fallback_location: developers_applications_path(id: params[:id]), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why change |
||
notice: "Destroyed scope #{params[:scope]}") | ||
end | ||
|
||
def add_redirect_uri | ||
uri = URI.parse(params[:redirect_uri]) | ||
if uri.scheme != 'https' | ||
redirect_back(fallback_location: developers_applications_path, notice: 'URIs must use HTTPS') | ||
return | ||
end | ||
@application = current_application | ||
uris = @application.redirect_uri.split("\r\n") | ||
uris.push(params[:redirect_uri]) | ||
|
@@ -56,7 +60,7 @@ def add_redirect_uri | |
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique => e | ||
flash.notice = e.message | ||
else | ||
flash.notice = "Added Redirect URI" | ||
flash.notice = 'Added Redirect URI' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
ensure | ||
redirect_back(fallback_location: developers_applications_path(id: params[:id])) | ||
end | ||
|
@@ -67,14 +71,14 @@ def destroy_redirect_uri | |
uris = @application.redirect_uri.split("\r\n") | ||
uris.delete(params[:redirect_uri]) | ||
@application.update!(redirect_uri: uris.join("\r\n")) | ||
redirect_back(fallback_location: developers_applications_path(id: params[:id]), notice: "Destroyed Redirect URI") | ||
redirect_back(fallback_location: developers_applications_path(id: params[:id]), notice: 'Destroyed Redirect URI') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
end | ||
|
||
def update | ||
@application = current_application | ||
@application.update!(name: params[:name]) if params[:name] | ||
@application.update!(confidential: params[:confidential].to_i.zero?) if params[:confidential] | ||
redirect_back(fallback_location: developers_applications_path(id: params[:id]), notice: "Updated application") | ||
redirect_back(fallback_location: developers_applications_path(id: params[:id]), notice: 'Updated application') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
end | ||
|
||
def destroy | ||
|
@@ -83,14 +87,22 @@ def destroy | |
end | ||
|
||
def create | ||
@application = Doorkeeper::Application.new(name: params[:name], redirect_uri: params[:redirect_uri], confidential: true) | ||
@application = Doorkeeper::Application.new(name: params[:name], redirect_uri: params[:redirect_uri], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why change |
||
confidential: true) | ||
@application.owner = current_user | ||
@application.save! | ||
redirect_to developers_application_path(id: @application.id) | ||
end | ||
|
||
def provision | ||
@application = Doorkeeper::Application.new(name: params[:name], redirect_uri: params[:redirect_uri], plan: params[:plan], confidential: true, provisional: true) | ||
uri = URI.parse(params[:redirect_uri]) | ||
if uri.scheme != 'https' | ||
redirect_back(fallback_location: developers_applications_path, notice: 'URIs must use HTTPS') | ||
return | ||
end | ||
|
||
@application = Doorkeeper::Application.new(name: params[:name], redirect_uri: params[:redirect_uri], | ||
plan: params[:plan], confidential: true, provisional: true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. weird line break |
||
@application.owner = current_user | ||
@application.save! | ||
redirect_to developers_path | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the flashes are in layouts - not in individual views, so update it there |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,40 @@ | ||
<h1 class="font-heading text-3 lg:text-4 xl:text-5">Request an application</h1> | ||
<br><br> | ||
|
||
<% flash.each do |type, msg| %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing - flash in layout |
||
<div class="flash flash-<%= type %>"> | ||
<%= msg %> | ||
</div> | ||
<% end %> | ||
<%= form_with url: provision_developers_applications_path do |form| %> | ||
<%= form.label :name, "What is the name of the app?" %><br> | ||
<br> | ||
<%= form.text_field :name, placeholder: "Dynamic" %> | ||
<br><br><br> | ||
<%= form.label :redirect_uri, "Add a Redirect URI" %><br> | ||
<p>This is where we'll redirect after the user authorizes your app</p> | ||
<br> | ||
<%= form.text_field :redirect_uri, placeholder: "https://oidcdebugger.com/debug" %> | ||
<br><br><br> | ||
<%= form.label :plan, "What are you planning on using it for?" %><br> | ||
<p>Don't worry, it doesn't need to be anything important or serious (it can be if you want though!)</p><br> | ||
<%= form.text_area :plan, placeholder: "I'm going to make a Dynamic DNS app" %> | ||
<br><br><br> | ||
<%= form.label :coc, "Do you agree to our Code of Conduct?" %><br> | ||
<p>We want to make sure our domains aren't used for bad purposes. Please read our Code of Conduct and Acceptable Use Policy: <a href="https://github.com/obl-ong/code-of-conduct">https://github.com/obl-ong/code-of-conduct</a></p> | ||
<br> | ||
<%= form.check_box :coc, required: true %> | ||
<br><br> | ||
|
||
<%= form.submit "Request" %> | ||
<%= form.label :name, "What is the name of the app?" %><br> | ||
<br> | ||
<%= form.text_field :name, placeholder: "Dynamic" %> | ||
<br><br><br> | ||
<%= form.label :redirect_uri, "Add a Redirect URI" %><br> | ||
<p>This is where we'll redirect after the user authorizes your app</p> | ||
<br> | ||
<%= form.text_field :redirect_uri, placeholder: "https://oidcdebugger.com/debug" %> | ||
<br><br><br> | ||
<%= form.label :plan, "What are you planning on using it for?" %><br> | ||
<p>Don't worry, it doesn't need to be anything important or serious (it can be | ||
if you want though!)</p><br> | ||
<%= form.text_area :plan, placeholder: "I'm going to make a Dynamic DNS app" %> | ||
<br><br><br> | ||
<%= form.label :coc, "Do you agree to our Code of Conduct?" %><br> | ||
<p>We want to make sure our domains aren't used for bad purposes. Please read | ||
our Code of Conduct and Acceptable Use Policy: | ||
<a href="https://github.com/obl-ong/code-of-conduct">https://github.com/obl-ong/code-of-conduct</a></p> | ||
<br> | ||
<%= form.check_box :coc, required: true %> | ||
<br><br> | ||
|
||
<%= form.submit "Request" %> | ||
<% end %> | ||
|
||
|
||
<%= style_tag nonce: true do %> | ||
form { | ||
max-width: 50vw; | ||
} | ||
|
||
.domain { | ||
font-size: 2rem; | ||
} | ||
|
||
label { | ||
font-size: 2rem; | ||
font-weight: 600; | ||
} | ||
|
||
textarea { | ||
background-color: #f5f5f51a !important; | ||
border: 1.5px solid var(--cultured) !important; | ||
border-radius: 5px !important; | ||
color: #fff; | ||
min-width: 450px; | ||
min-height: 10rem; | ||
} | ||
|
||
a { | ||
color: var(--winter-sky); | ||
} | ||
<% end %> | ||
form { max-width: 50vw; } .domain { font-size: 2rem; } label { font-size: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's not minify css |
||
2rem; font-weight: 600; } textarea { background-color: #f5f5f51a !important; | ||
border: 1.5px solid var(--cultured) !important; border-radius: 5px | ||
!important; color: #fff; min-width: 450px; min-height: 10rem; } a { color: | ||
var(--winter-sky); } | ||
<% end %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will fail linting