Fix remaining remarks
This commit is contained in:
parent
ef7ea1a855
commit
58aef5658b
8 changed files with 65 additions and 58 deletions
|
|
@ -97,7 +97,7 @@ module Api
|
|||
if seconds.nil?
|
||||
false
|
||||
else
|
||||
(Time.zone.now.utc.to_i - current_user.current_sign_in_at.to_i) > seconds.to_i
|
||||
(Time.now - current_user.current_sign_in_at) > seconds.to_i
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ module Api
|
|||
logger.info e.backtrace[0, 10].join("\n")
|
||||
render json: {error: :invalid_grant, error_description: e.message, status: 400}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -76,13 +76,14 @@ module Api
|
|||
supported_metadata.each_with_object({}) do |key, attr|
|
||||
value = registrar.public_send(key)
|
||||
next unless value
|
||||
if key == :subject_type
|
||||
case key
|
||||
when :subject_type
|
||||
attr[:ppid] = (value == "pairwise")
|
||||
elsif key == :jwks_uri
|
||||
when :jwks_uri
|
||||
response = Faraday.get(value)
|
||||
attr[:jwks] = response.body
|
||||
attr[:jwks_uri] = value
|
||||
elsif key == :jwks
|
||||
when :jwks
|
||||
attr[:jwks] = value.to_json
|
||||
else
|
||||
attr[key] = value
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
Rails.application.config.middleware.insert 0, Rack::Cors do
|
||||
allow do
|
||||
origins "*"
|
||||
resource "/.well-known/host-meta"
|
||||
resource "/webfinger"
|
||||
resource "/.well-known/webfinger"
|
||||
resource "/.well-known/openid-configuration"
|
||||
resource "/api/openid_connect/user_info", methods: %i(get post)
|
||||
resource "/api/v0/*", methods: %i(delete get post)
|
||||
resource "/.well-known/host-meta"
|
||||
resource "/.well-known/webfinger"
|
||||
resource "/.well-known/openid-configuration"
|
||||
resource "/webfinger"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -919,8 +919,8 @@ en:
|
|||
description: "This allows the application to send new posts, write conversations, and send reactions"
|
||||
error_page:
|
||||
title: "Oh! Something went wrong :("
|
||||
contact_developer: "You should contact the developer of the application and include the following detailed message error:"
|
||||
login_required: "You must first login before authorize this application"
|
||||
contact_developer: "You should contact the developer of the application and include the following detailed error message:"
|
||||
login_required: "You must first login before you can authorize this application"
|
||||
could_not_authorize: "The application could not be authorized"
|
||||
|
||||
people:
|
||||
|
|
|
|||
|
|
@ -35,5 +35,5 @@ Then /^I should receive an "([^\"]*)" error$/ do |error_message|
|
|||
end
|
||||
|
||||
Then(/^I should see a message containing "(.*?)"$/) do |message|
|
||||
expect(find("#openid_connect_error_description").text).to eq(message)
|
||||
expect(find("#openid_connect_error_description").text).to include(message)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ describe Api::OpenidConnect::AuthorizationsController, type: :controller do
|
|||
it "raises an error" do
|
||||
delete :destroy, id: 123_456_789
|
||||
expect(response).to redirect_to(api_openid_connect_user_applications_url)
|
||||
expect(flash[:error]).to eq("The attempt to revoke the authorization with ID 123456789 has failed")
|
||||
expect(flash[:error]).to eq("The attempt to revoke the authorization with ID 123456789 failed")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@ describe Api::OpenidConnect::ClientsController, type: :controller do
|
|||
context "when valid parameters are passed" do
|
||||
it "should return a client id" do
|
||||
stub_request(:get, "http://example.com/uris")
|
||||
.with(headers: {"Accept" => "*/*", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
||||
"User-Agent" => "Faraday v0.9.2"})
|
||||
.with(headers: {
|
||||
"Accept" => "*/*",
|
||||
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
||||
"User-Agent" => "Faraday v0.9.2"
|
||||
})
|
||||
.to_return(status: 200, body: "[\"http://localhost\"]", headers: {})
|
||||
post :create, redirect_uris: ["http://localhost"], client_name: "diaspora client",
|
||||
response_types: [], grant_types: [], application_type: "web", contacts: [],
|
||||
|
|
@ -22,7 +25,9 @@ describe Api::OpenidConnect::ClientsController, type: :controller do
|
|||
context "when valid parameters with jwks is passed" do
|
||||
it "should return a client id" do
|
||||
stub_request(:get, "http://example.com/uris")
|
||||
.with(headers: {"Accept" => "*/*", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
||||
.with(headers: {
|
||||
"Accept" => "*/*",
|
||||
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
||||
"User-Agent" => "Faraday v0.9.2"})
|
||||
.to_return(status: 200, body: "[\"http://localhost\"]", headers: {})
|
||||
post :create, redirect_uris: ["http://localhost"], client_name: "diaspora client",
|
||||
|
|
@ -80,11 +85,13 @@ describe Api::OpenidConnect::ClientsController, type: :controller do
|
|||
context "when valid parameters with jwks_uri is passed" do
|
||||
it "should return a client id" do
|
||||
stub_request(:get, "http://example.com/uris")
|
||||
.with(headers: {"Accept" => "*/*", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
||||
.with(headers: {"Accept" => "*/*",
|
||||
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
||||
"User-Agent" => "Faraday v0.9.2"})
|
||||
.to_return(status: 200, body: "[\"http://localhost\"]", headers: {})
|
||||
stub_request(:get, "https://kentshikama.com/api/openid_connect/jwks.json")
|
||||
.with(headers: {"Accept" => "*/*", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
||||
.with(headers: {"Accept" => "*/*",
|
||||
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
||||
"User-Agent" => "Faraday v0.9.2"})
|
||||
.to_return(status: 200,
|
||||
body: "{\"keys\":[{\"kty\":\"RSA\",\"e\":\"AQAB\",\"n\":\"qpW\",\"use\":\"sig\"}]}", headers: {})
|
||||
|
|
|
|||
Loading…
Reference in a new issue