-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1228 from tryzealot/refactor/register-udid-device
重构注册 UDID 设备及相关展示的逻辑
- Loading branch information
Showing
23 changed files
with
199 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
module DeviceAttributes | ||
extend ActiveSupport::Concern | ||
|
||
def certificate | ||
@certificate ||= lambda do | ||
cert = OpenSSL::X509::Certificate.new | ||
cert.version = 2 | ||
cert.serial = Random.rand(2**16 - 2) + 1 | ||
cert.subject = subject | ||
cert.issuer = issuer | ||
cert.not_before = create_date | ||
cert.not_after = expire_date | ||
cert.public_key = root_key.public_key | ||
|
||
cert_ext = OpenSSL::X509::ExtensionFactory.new | ||
cert_ext.subject_certificate = cert | ||
cert_ext.issuer_certificate = cert | ||
cert.add_extension(cert_ext.create_extension("basicConstraints","CA:TRUE",true)) | ||
cert.add_extension(cert_ext.create_extension("keyUsage","keyCertSign, cRLSign", true)) | ||
cert.add_extension(cert_ext.create_extension("subjectKeyIdentifier","hash",false)) | ||
cert.add_extension(cert_ext.create_extension("authorityKeyIdentifier","keyid:always",false)) | ||
cert.sign(root_key, digest) | ||
cert | ||
end.call | ||
end | ||
|
||
def subject | ||
@subject ||= OpenSSL::X509::Name.parse("/C=CN/O=tryzealot/OU=zealot/CN=#{Setting.site_title} Self-signed Authority") | ||
end | ||
|
||
def issuer | ||
@issuer ||= OpenSSL::X509::Name.parse("/C=CN/O=tryzealot/OU=zealot/CN=#{Setting.site_title}") | ||
end | ||
|
||
def root_key | ||
@key ||= OpenSSL::PKey::RSA.generate(2048) | ||
end | ||
|
||
def digest | ||
@digest ||= OpenSSL::Digest.new('SHA256') | ||
end | ||
|
||
def payload_uuid | ||
@payload_uuid ||= Rails.cache.fetch('ios-udid', expires_in: 1.week) { SecureRandom.uuid.upcase } | ||
end | ||
|
||
def create_date | ||
Time.now.utc | ||
end | ||
|
||
def expire_date | ||
expire_time = 1 * 365 * 24 * 60 * 60 # 1 year | ||
create_date + expire_time | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.row | ||
.col-md-12 | ||
.alert.alert-warning | ||
strong Ta-Da! | ||
= t('udid.show.unregistered') | ||
|
||
== render 'dashboards/widget', title: t('udid.show.channels'), count: @channel_total, url: '', color_style: 'bg-navy', icon: 'fab fa-adn' | ||
== render 'dashboards/widget', title: t('udid.show.releases'), count: @release_total, url: '', color_style: 'bg-pink', icon: 'fab fa-gg' | ||
== render 'dashboards/widget', title: t('udid.show.apple_keys'), count: @apple_key_total, url: '', color_style: 'bg-yellow', icon: 'fas fa-key' | ||
|
||
== render 'udid/udid_metadata', device: @device | ||
== render 'udid/apps', device: @device, channels: @channels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.row | ||
.col-md-12 | ||
.alert.alert-primary | ||
strong Yah-ah! | ||
= t('udid.show.register') | ||
|
||
- if @device.blank? | ||
== render 'udid/register_form', udid: params[:udid], product: params[:product] | ||
|
||
== render 'udid/udid_metadata', device: @device | ||
== render 'udid/apps', device: @device, channels: @channels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.col-md-12 | ||
.card | ||
= simple_form_for(Device.new, url: register_udid_path(udid: udid, product: product)) do |f| | ||
.card-header | ||
h3.card-title | ||
= t("udid.show.register_device") | ||
.card-tools | ||
.card-body | ||
= f.error_notification | ||
= f.input :name | ||
= f.input :apple_keys, collection: AppleTeam.all_names, label_method: :first, value_method: :last, include_blank: false | ||
|
||
.card-footer | ||
= f.button :submit, t('udid.show.register_device') |
Oops, something went wrong.