Feature #24808 » 0004-Redmine-style-UI-for-Doorkeeper-OAuth2-provider.patch
| app/views/doorkeeper/applications/_form.html.erb | ||
|---|---|---|
|
<%= error_messages_for 'application' %>
|
||
|
<div class="box tabular">
|
||
|
<p><%= f.text_field :name, :required => true %></p>
|
||
|
<p>
|
||
|
<%= f.text_area :redirect_uri, :required => true, :size => 60, :label => :'activerecord.attributes.doorkeeper/application.redirect_uri' %>
|
||
|
<em class="info">
|
||
|
<%= t('doorkeeper.applications.help.redirect_uri') %>
|
||
|
<% if Doorkeeper.configuration.native_redirect_uri %>
|
||
|
<br/><%= raw t('doorkeeper.applications.help.native_redirect_uri',
|
||
|
native_redirect_uri: "<code>#{ Doorkeeper.configuration.native_redirect_uri }</code>") %>
|
||
|
<% end %>
|
||
|
</em>
|
||
|
</p>
|
||
|
<p>
|
||
|
<%= f.text_field :scopes, :size => 60, :label => :'activerecord.attributes.doorkeeper/application.scopes' %>
|
||
|
<em class="info">
|
||
|
<%= t('doorkeeper.applications.help.scopes') %>
|
||
|
</em>
|
||
|
</p>
|
||
|
</div>
|
||
| app/views/doorkeeper/applications/edit.html.erb | ||
|---|---|---|
|
<%= title [t('doorkeeper.applications.index.title'), oauth_applications_path], @application.name %>
|
||
|
<%= labelled_form_for @application, url: doorkeeper_submit_path(@application) do |f| %>
|
||
|
<%= render :partial => 'form', :locals => {:f => f} %>
|
||
|
<%= submit_tag l(:button_save) %>
|
||
|
<% end %>
|
||
| app/views/doorkeeper/applications/index.html.erb | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<%= link_to t('.new'), new_oauth_application_path, :class => 'icon icon-add' %>
|
||
|
</div>
|
||
|
<%= title t('.title') %>
|
||
|
<% if @applications.any? %>
|
||
|
<div class="autoscroll">
|
||
|
<table class="list">
|
||
|
<thead><tr>
|
||
|
<th><%= t('.name') %></th>
|
||
|
<th><%= t('.callback_url') %></th>
|
||
|
<th><%= t('.scopes') %></th>
|
||
|
<th></th>
|
||
|
</tr></thead>
|
||
|
<tbody>
|
||
|
<% @applications.each do |application| %>
|
||
|
<tr id="application_<%= application.id %>" class="<%= cycle("odd", "even") %>">
|
||
|
<td class="name"><span><%= link_to application.name, oauth_application_path(application) %></span></td>
|
||
|
<td class="description"><%= truncate application.redirect_uri.split.join(', '), length: 50 %></td>
|
||
|
<td class="description"><%= h application.scopes %></td>
|
||
|
<td class="buttons">
|
||
|
<%= link_to t('doorkeeper.applications.buttons.edit'), edit_oauth_application_path(application), class: 'icon icon-edit' %>
|
||
|
<%= link_to t('doorkeeper.applications.buttons.destroy'), oauth_application_path(application), :data => {:confirm => t('doorkeeper.applications.confirmations.destroy')}, :method => :delete, :class => 'icon icon-del' %>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<% end %>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
<% else %>
|
||
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
||
|
<% end %>
|
||
| app/views/doorkeeper/applications/new.html.erb | ||
|---|---|---|
|
<%= title [t('doorkeeper.applications.index.title'), oauth_applications_path], t('.title') %>
|
||
|
<%= labelled_form_for @application, url: doorkeeper_submit_path(@application) do |f| %>
|
||
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
||
|
<%= submit_tag l(:button_create) %>
|
||
|
<% end %>
|
||
| app/views/doorkeeper/applications/show.html.erb | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<%= link_to t('doorkeeper.applications.buttons.edit'), edit_oauth_application_path(@application), :accesskey => accesskey(:edit), class: 'icon icon-edit' %>
|
||
|
<%= link_to t('doorkeeper.applications.buttons.destroy'), oauth_application_path(@application), :data => {:confirm => t('doorkeeper.applications.confirmations.destroy')}, :method => :delete, :class => 'icon icon-del' %>
|
||
|
</div>
|
||
|
<%= title [t('doorkeeper.applications.index.title'), oauth_applications_path], @application.name %>
|
||
|
<fieldset class="tabular"><legend><%= l(:label_information_plural) %></legend>
|
||
|
<p>
|
||
|
<label><%= t('.application_id') %>:</label>
|
||
|
<code><%= h @application.uid %></code>
|
||
|
</p>
|
||
|
<p>
|
||
|
<label><%= t('.secret') %>:</label>
|
||
|
<code><%= h @application.secret %></code>
|
||
|
</p>
|
||
|
<p>
|
||
|
<label><%= t('.scopes') %>:</label>
|
||
|
<code><%= h @application.scopes %></code>
|
||
|
</p>
|
||
|
</fieldset>
|
||
|
<br/>
|
||
|
<h3><%= t('.callback_urls') %></h3>
|
||
|
<div class="autoscroll">
|
||
|
<table class="list">
|
||
|
<thead><tr>
|
||
|
<th><%= t('.callback_url') %></th>
|
||
|
<th></th>
|
||
|
</tr></thead>
|
||
|
<tbody>
|
||
|
<% @application.redirect_uri.split.each do |uri| %>
|
||
|
<tr class="<%= cycle("odd", "even") %>">
|
||
|
<td class="name"><span><%= uri %></span></td>
|
||
|
<td class="buttons">
|
||
|
<%= link_to t('doorkeeper.applications.buttons.authorize'), oauth_authorization_path(client_id: @application.uid, redirect_uri: uri, response_type: 'code', scope: @application.scopes), class: 'icon icon-authorize', target: '_blank' %>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<% end %>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
| app/views/doorkeeper/authorizations/error.html.erb | ||
|---|---|---|
|
<h2><%= t('doorkeeper.authorizations.error.title') %></h2>
|
||
|
<p id="errorExplanation"><%= @pre_auth.error_response.body[:error_description] %></p>
|
||
|
<p><a href="javascript:history.back()"><%= l(:button_back) %></a></p>
|
||
|
<% html_title t('doorkeeper.authorizations.error.title') %>
|
||
| app/views/doorkeeper/authorizations/new.html.erb | ||
|---|---|---|
|
<%= title t('.title') %>
|
||
|
<div class="warning">
|
||
|
<p><strong><%=h @pre_auth.client.name %></strong></p>
|
||
|
<p><%= raw t('.prompt', client_name: "<strong class=\"text-info\">#{ @pre_auth.client.name }</strong>") %></p>
|
||
|
<% if @pre_auth.scopes.count > 0 %>
|
||
|
<div class="oauth-permissions">
|
||
|
<p><%= t('.able_to') %>:
|
||
|
<ul>
|
||
|
<% @pre_auth.scopes.each do |scope| %>
|
||
|
<li><%= t scope, scope: [:doorkeeper, :scopes] %></li>
|
||
|
<% end %>
|
||
|
</ul>
|
||
|
</p>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<p>
|
||
|
<%= form_tag oauth_authorization_path, method: :post do %>
|
||
|
<%= hidden_field_tag :client_id, @pre_auth.client.uid %>
|
||
|
<%= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri %>
|
||
|
<%= hidden_field_tag :state, @pre_auth.state %>
|
||
|
<%= hidden_field_tag :response_type, @pre_auth.response_type %>
|
||
|
<%= hidden_field_tag :scope, @pre_auth.scope %>
|
||
|
<%= submit_tag t('doorkeeper.authorizations.buttons.authorize'), class: "btn btn-success btn-lg btn-block" %>
|
||
|
<% end %>
|
||
|
<%= form_tag oauth_authorization_path, method: :delete do %>
|
||
|
<%= hidden_field_tag :client_id, @pre_auth.client.uid %>
|
||
|
<%= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri %>
|
||
|
<%= hidden_field_tag :state, @pre_auth.state %>
|
||
|
<%= hidden_field_tag :response_type, @pre_auth.response_type %>
|
||
|
<%= hidden_field_tag :scope, @pre_auth.scope %>
|
||
|
<%= submit_tag t('doorkeeper.authorizations.buttons.deny'), class: "btn btn-danger btn-lg btn-block" %>
|
||
|
<% end %>
|
||
|
</p>
|
||
| app/views/doorkeeper/authorizations/show.html.erb | ||
|---|---|---|
|
<%= title [t('doorkeeper.authorized_applications.index.title'), oauth_authorized_applications_path] %>
|
||
|
<fieldset class="tabular"><legend><%= l(:label_information_plural) %></legend>
|
||
|
<p>
|
||
|
<label><%= t('.title') %>:</label>
|
||
|
<code><%= params[:code] %></code>
|
||
|
</p>
|
||
|
</fieldset>
|
||
| app/views/doorkeeper/authorized_applications/index.html.erb | ||
|---|---|---|
|
<%= title [t(:label_my_account), my_account_path], t('doorkeeper.authorized_applications.index.title') %>
|
||
|
<% if @applications.any? %>
|
||
|
<div class="autoscroll">
|
||
|
<table class="list">
|
||
|
<thead><tr>
|
||
|
<th><%= t('doorkeeper.authorized_applications.index.application') %></th>
|
||
|
<th><%= t('doorkeeper.authorized_applications.index.created_at') %></th>
|
||
|
<th></th>
|
||
|
</tr></thead>
|
||
|
<tbody>
|
||
|
<% @applications.each do |application| %>
|
||
|
<tr id="application_<%= application.id %>" class="<%= cycle("odd", "even") %>">
|
||
|
<td class="name"><span><%= application.name %></span></td>
|
||
|
<td ><%= format_date application.created_at %></td>
|
||
|
<td class="buttons">
|
||
|
<%= link_to t('doorkeeper.authorized_applications.buttons.revoke'), oauth_authorized_application_path(application), :data => {:confirm => t('doorkeeper.authorized_applications.confirmations.revoke')}, :method => :delete, :class => 'icon icon-del' %>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<% end %>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
<% else %>
|
||
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
||
|
<% end %>
|
||
|
<% content_for :sidebar do %>
|
||
|
<% @user = User.current %>
|
||
|
<%= render :partial => 'my/sidebar' %>
|
||
|
<% end %>
|
||
| config/application.rb | ||
|---|---|---|
|
:key => '_redmine_session',
|
||
|
:path => config.relative_url_root || '/'
|
||
|
# Use Redmine standard layouts and helpers for Doorkeeper OAuth2 screens
|
||
|
config.to_prepare do
|
||
|
Doorkeeper::ApplicationsController.layout "admin"
|
||
|
Doorkeeper::ApplicationsController.main_menu = false
|
||
|
Doorkeeper::AuthorizationsController.layout "base"
|
||
|
Doorkeeper::AuthorizedApplicationsController.layout "base"
|
||
|
Doorkeeper::AuthorizedApplicationsController.main_menu = false
|
||
|
end
|
||
|
if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
|
||
|
instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
|
||
|
end
|
||
| config/initializers/doorkeeper.rb | ||
|---|---|---|
|
use_refresh_token
|
||
|
reuse_access_token
|
||
|
realm Redmine::Info.app_name
|
||
|
base_controller 'ApplicationController'
|
||
|
default_scopes :public
|
||
|
resource_owner_authenticator do
|
||
|
if Setting.rest_api_enabled?
|
||
|
User.active.find_by_id(session[:user_id]) || redirect_to(signin_path(:back_url => request.original_url))
|
||
|
else
|
||
|
render(:text => 'Forbidden', :status => 403)
|
||
|
if require_login
|
||
|
if Setting.rest_api_enabled?
|
||
|
User.current
|
||
|
else
|
||
|
deny_access
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
admin_authenticator do
|
||
|
if !Setting.rest_api_enabled? || !User.active.where(admin: true).find_by_id(session[:user_id])
|
||
|
render(:text => 'Forbidden', :status => 403)
|
||
|
if !Setting.rest_api_enabled? || !User.current.admin?
|
||
|
deny_access
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| public/stylesheets/application.css | ||
|---|---|---|
|
color: #A6750C;
|
||
|
}
|
||
|
.warning .oauth-permissions { display:inline-block;text-align:left; }
|
||
|
.warning .oauth-permissions p { margin-top:0;-webkit-margin-before:0;}
|
||
|
#errorExplanation ul { font-size: 0.9em;}
|
||
|
#errorExplanation h2, #errorExplanation p { display: none; }
|
||
| ... | ... | |
|
.icon-custom-fields { background-image: url(../images/textfield.png); }
|
||
|
.icon-plugins { background-image: url(../images/plugin.png); }
|
||
|
.icon-applications { background-image: url(../images/application_view_tile.png); }
|
||
|
.icon-authorize { background-image: url(../images/application_key.png); }
|
||
|
.icon-news { background-image: url(../images/news.png); }
|
||
|
.icon-issue-closed { background-image: url(../images/ticket_checked.png); }
|
||
|
.icon-issue-note { background-image: url(../images/ticket_note.png); }
|
||