Skip to content

Commit

Permalink
wip. response から email が落ちる
Browse files Browse the repository at this point in the history
  • Loading branch information
hhorikawa committed Nov 2, 2024
1 parent 16d2c98 commit eadcdb2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

bugs:
- response から email が drop する。ユーザの承諾の保存辺りが不味そう

●●未了
- `registration_endpoint` 動的な登録の再実装
- `end_session_endpoint` シングルログアウト (SLO) の実装
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/discovery_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ def show
end
end

def jwk_set
render json: {keys: IdToken.config[:jwk_set]}.to_json
end


private

def webfinger_discovery
Expand Down
1 change: 1 addition & 0 deletions app/models/fake_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FakeUser < ApplicationRecord

def to_response_object access_token
userinfo = userinfo()
#raise userinfo.inspect # この段階では email 入っている
unless access_token.accessible?(Scope::PROFILE)
userinfo.all_attributes.each do |attribute|
userinfo.send("#{attribute}=", nil) unless access_token.accessible?(attribute)
Expand Down
23 changes: 14 additions & 9 deletions app/views/clients/_client.html.erb
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@

<fieldset class="client">
<h3>
<%= client.name %>
<code class="redirect_uris"><%= client.redirect_uris.try(:join, ' ') %></code>
</h3>
<h3 class="title is-3"><%= client.name %></h3>
<p><%= t('client.identifier') %>
<code><%= client.identifier %></code>

<details>
<summary><%= t('client.credentials') %></summary>
<summary>Details:</summary>
<dl>
<dt><%= t('client.identifier') %>
<dd><code><%= client.identifier %></code>
<dt>Redirect URIs:
<dd><% client.redirect_uris.each do |uri| %>
<code class="redirect_uris"><%= uri %></code>
<% end %>

<dt><%= t('client.secret') %></dt>
<dd><code><%= client.secret %></code>
</dl>
<nav class="authorize">
<h4><%= t('authorizations.new.title', client:client.name) %></h4>
<h4 class="title is-4"><%= t('authorizations.new.title', client:client.name) %></h4>
<ul>
<% Client.available_response_types.each do |response_type| %>
<li>
<%= form_tag new_authorization_path, method: :get do %>
<%= form_tag new_authorization_path, method: :get, data:{turbo:false} do %>
<%= hidden_field_tag :redirect_uri, client.redirect_uris.first %>
<%= hidden_field_tag :client_id, client.identifier %>
<%= hidden_field_tag :response_type, response_type %>
<%= hidden_field_tag :scope, Scope.all.collect(&:name).join(' ') %>
Expand All @@ -28,6 +32,7 @@
</ul>
</nav>
</details>

<footer>
<%= link_to 'Edit...', edit_client_path(client) %>
<%= button_to t('destroy'), client_path(client),
Expand Down
3 changes: 2 additions & 1 deletion app/views/clients/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<h1><%= 'Edit ' + @client.name %></h1>

<% content_for(:title) {"Edit " + @client.name } %>

<article>
<%= form_for @client, :method => :put, :html => {:class => 'box'} do |f| %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboard/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</p>
</nav>

<section>
<section class="section">
<%= render @clients %>
</section>

Expand Down
6 changes: 2 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@
# UserInfo Endpoint
match 'user_info', to: 'user_info#show', :via => [:get, :post]

get 'jwks.json', to: proc { |env|
[200,
{'Content-Type' => 'application/json'},
[IdToken.config[:jwk_set].to_json]] }
#
get 'jwks.json', to: "discovery#jwk_set"

# For details on the DSL available within this file,
# see https://guides.rubyonrails.org/routing.html
Expand Down

0 comments on commit eadcdb2

Please sign in to comment.