-
Notifications
You must be signed in to change notification settings - Fork 32
Certificate cleanup #404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Certificate cleanup #404
Changes from all commits
5bf52b9
ba46298
3aa965a
5c6741f
7a71392
119a9fe
a7b31cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,12 @@ | ||
| <% cert = app.certificate %> | ||
| <% if cert.not_after < Time.zone.now %> | ||
| <td style='color: white; background: red'> | ||
| <% elsif cert.not_after < ServiceProviderCertificate.warning_period %> | ||
| <td style='color: black; background: yellow'> | ||
| <% else %> | ||
| <td> | ||
| <% | ||
| # locals: app | ||
| cert = app.certificate | ||
| %> | ||
|
|
||
| <%= content_tag(:td, class: cert.expiration_css_class) do %> | ||
zachmargolis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <% if cert.issuer.to_s == 'Null Certificate' %> | ||
| Invalid | ||
| <% else %> | ||
| <%= cert.not_after.localtime.strftime("%F") %> | ||
| <% end %> | ||
| <% end %> | ||
| <% if cert.issuer.to_s == 'Null Certificate' %> | ||
| Invalid | ||
| <% else %> | ||
| <%= cert.not_after.localtime.strftime("%F") %> | ||
| <% end %> | ||
| </td> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,27 +58,51 @@ | |
| <% end %> | ||
| <% end %> | ||
|
|
||
| <% if service_provider.identity_protocol == 'saml' %> | ||
| <h2><label for="acs_url">Assertion Consumer Service URL:</label></h2> | ||
| <p class="font-mono-xs margin-top-0" name="acs_url"><%= service_provider.acs_url %></p> | ||
|
|
||
| <h2><label for="assertion_consumer_logout_service_url">Assertion Consumer Logout Service URL:</label></h2> | ||
| <p class="font-mono-xs margin-top-0" name="assertion_consumer_logout_service_url"><%= service_provider.assertion_consumer_logout_service_url %></p> | ||
| <% if service_provider.identity_protocol == 'saml' %> | ||
| <h2><label for="acs_url">Assertion Consumer Service URL:</label></h2> | ||
| <p class="font-mono-xs margin-top-0" name="acs_url"><%= service_provider.acs_url %></p> | ||
|
|
||
| <h2><label for="assertion_consumer_logout_service_url">SP Initiated Login URL:</label></h2> | ||
| <p class="font-mono-xs margin-top-0" name="assertion_consumer_logout_service_url"><%= service_provider.sp_initiated_login_url %></p> | ||
| <h2><label for="assertion_consumer_logout_service_url">Assertion Consumer Logout Service URL:</label></h2> | ||
| <p class="font-mono-xs margin-top-0" name="assertion_consumer_logout_service_url"><%= service_provider.assertion_consumer_logout_service_url %></p> | ||
|
|
||
| <h2><label for="block_encryption">SAML Assertion Encryption:</label></h2> | ||
| <p class="font-mono-xs margin-top-0" name="block_encryption"><%= service_provider.block_encryption %></p> | ||
| <% end %> | ||
| <h2><label for="assertion_consumer_logout_service_url">SP Initiated Login URL:</label></h2> | ||
| <p class="font-mono-xs margin-top-0" name="assertion_consumer_logout_service_url"><%= service_provider.sp_initiated_login_url %></p> | ||
|
|
||
| <h2><label for="block_encryption">SAML Assertion Encryption:</label></h2> | ||
| <p class="font-mono-xs margin-top-0" name="block_encryption"><%= service_provider.block_encryption %></p> | ||
| <% end %> | ||
|
|
||
| <h2><label for="saml_client_cert">Public certificate:</label></h2> | ||
| <pre><code><%= service_provider.saml_client_cert %></code></pre> | ||
| <% unless service_provider.saml_client_cert.blank? %> | ||
| <p class="font-mono-xs margin-top-0" name="saml_client_cert">Expires: | ||
| <%= render partial: 'certificate_expiration', locals: { app: service_provider } %></p> | ||
| <% end %> | ||
| <h2> | ||
| <label for="saml_client_cert">Public certificate:</label> | ||
|
Contributor
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. It existed previously, though the https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Form_labelable I could maybe see it as a case for
Contributor
Author
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. Looks like they came from #366 from AxE matchers
Contributor
Author
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. Ok no that was not right... looks like those have just been there a long time.... it's probably time for them to go, especially since this page isn't a form?
Contributor
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. I wonder if they were copied over from the edit form? |
||
| </h2> | ||
|
|
||
| <% unless service_provider.saml_client_cert.blank? %> | ||
| <dl> | ||
| <dt>Issuer</dt> | ||
| <dd><%= service_provider.certificate.issuer %></dd> | ||
|
|
||
| <dt>Subject</dt> | ||
| <dd><%= service_provider.certificate.subject %></dd> | ||
|
|
||
| <dt>Serial Number</dt> | ||
| <dd class="font-mono-xs"><%= service_provider.certificate.serial %></dd> | ||
|
|
||
| <dt>Expiration</dt> | ||
| <dd> | ||
| <%= content_tag(:span, class: ['font-mono-xs', service_provider.certificate.expiration_css_class]) do %> | ||
| <%= service_provider.certificate.not_after %> | ||
| <% end %> | ||
| (<%= time_ago_in_words service_provider.certificate.not_after %>) | ||
| </dd> | ||
| </dl> | ||
|
|
||
| <details name="saml_client_cert"> | ||
| <summary class="summary-fix"> | ||
| Raw Certificate | ||
| </summary> | ||
| <pre><code><%= service_provider.saml_client_cert %></code></pre> | ||
| </details> | ||
| <% end %> | ||
|
|
||
| <h2><label for="return_to_sp_url">Return to App URL:</label></h2> | ||
| <p class="font-mono-xs margin-top-0" name="return_to_sp_url"><%= service_provider.return_to_sp_url %></p> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,54 @@ | ||
| require 'rails_helper' | ||
|
|
||
| describe ServiceProviderCertificate do | ||
| RSpec.describe ServiceProviderCertificate do | ||
| before do | ||
| allow(Figaro.env).to receive(:certificate_expiration_warning_period).and_return('5') | ||
| end | ||
|
|
||
| let(:plain_cert) do | ||
| instance_double('OpenSSL::X509::Certificate', not_after: not_after) | ||
| end | ||
|
|
||
| subject(:cert) do | ||
| ServiceProviderCertificate.new(plain_cert) | ||
| end | ||
|
|
||
| context 'certificate is expired' do | ||
| let(:not_after) { 1.day.ago } | ||
|
|
||
| it 'wraps the expiration in ansi color codes to make it black on red' do | ||
| expired_time = 1.day.ago | ||
| expect(ServiceProviderCertificate.expiration_time_to_colorized_s(expired_time)). | ||
| to match(/\A\e\[0;30;41m#{expired_time.to_s}\e\[0m\z/) | ||
| expect(cert.expiration_time_to_colorized_s). | ||
| to match(/\A\e\[0;30;41m#{not_after.to_s}\e\[0m\z/) | ||
| end | ||
|
|
||
| it 'has an expired CSS style' do | ||
| expect(cert.expiration_css_class).to eq('certificate-expired') | ||
| end | ||
| end | ||
|
|
||
| context 'certificate is near expiration' do | ||
| let(:not_after) { (5.days - 10.seconds).from_now } | ||
|
|
||
| it 'wraps the expiration in ansi color codes to make it black on yellow' do | ||
| expired_time = (5.days - 10.seconds).from_now | ||
| expect(ServiceProviderCertificate.expiration_time_to_colorized_s(expired_time)). | ||
| to match(/\A\e\[0;30;103m#{expired_time.to_s}\e\[0m\z/) | ||
| expect(cert.expiration_time_to_colorized_s). | ||
| to match(/\A\e\[0;30;103m#{not_after.to_s}\e\[0m\z/) | ||
| end | ||
|
|
||
| it 'has a warning CSS style' do | ||
| expect(cert.expiration_css_class).to eq('certificate-warning') | ||
| end | ||
| end | ||
|
|
||
| context 'certificate is not near expiration' do | ||
| it 'does not wraps the expiration in ansi color codes' do | ||
| expired_time = (5.days + 10.seconds).from_now | ||
| expect(ServiceProviderCertificate.expiration_time_to_colorized_s(expired_time)). | ||
| to match(/\A#{expired_time.to_s}\z/) | ||
| let(:not_after) { (5.days + 10.seconds).from_now } | ||
|
|
||
| it 'does not wrap the expiration in ansi color codes' do | ||
| expect(cert.expiration_time_to_colorized_s). | ||
| to match(/\A#{not_after.to_s}\z/) | ||
| end | ||
|
|
||
| it 'does not have a CSS style' do | ||
| expect(cert.expiration_css_class).to be_nil | ||
| end | ||
| end | ||
| end |
Uh oh!
There was an error while loading. Please reload this page.