Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
Merge branch 'security'
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed Jul 21, 2012
2 parents 099310b + bd6554b commit 1ff02b9
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ gem install cupertino
$ ios login
```

_Credentials are saved in `.netrc`. You will not be prompted for your username or password by commands while you are logged in._
_Credentials are saved in the keychain. You will not be prompted for your username or password by commands while you are logged in._

### Devices

Expand Down
2 changes: 1 addition & 1 deletion bin/ios
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
require 'commander/import'
require 'terminal-table'
require 'term/ansicolor'
require 'netrc'

require 'cupertino'

HighLine.track_eof = false # Fix for built-in Ruby
Signal.trap("INT") {} # Suppress backtrace when exiting command

program :version, Cupertino::VERSION
program :description, 'A command-line interface for the iOS Provisioning Portal'
Expand Down
2 changes: 1 addition & 1 deletion cupertino.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.add_dependency "terminal-table", "~> 1.4.5"
s.add_dependency "term-ansicolor", "~> 1.0.7"
s.add_dependency "mechanize", "~> 2.5.1"
s.add_dependency "netrc", "~> 0.7.2"
s.add_dependency "security", "~> 0.1.1"

s.files = Dir["./**/*"].reject { |file| file =~ /\.\/(bin|log|pkg|script|spec|test|vendor)/ }
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Expand Down
2 changes: 1 addition & 1 deletion lib/cupertino.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Cupertino
VERSION = '0.4.0'
VERSION = '0.5.0'
HOSTNAME = "developer.apple.com"
end
5 changes: 3 additions & 2 deletions lib/cupertino/provisioning_portal/agent.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'mechanize'
require 'netrc'
require 'security'

module Cupertino
module ProvisioningPortal
Expand All @@ -10,7 +10,8 @@ def initialize
super
self.user_agent_alias = 'Mac Safari'

@username, @password = Netrc.read[Cupertino::HOSTNAME]
pw = Security::InternetPassword.find(:server => Cupertino::HOSTNAME)
@username, @password = pw.attributes['acct'], pw.password if pw
end

def get(uri, parameters = [], referer = nil, headers = {})
Expand Down
6 changes: 2 additions & 4 deletions lib/cupertino/provisioning_portal/commands/login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
c.description = ''

c.action do |args, options|
say_warning "You are already authenticated" if Netrc.read[Cupertino::HOSTNAME]
say_warning "You are already authenticated" if Security::InternetPassword.find(:server => Cupertino::HOSTNAME)

user = ask "Username:"
pass = password "Password:"

netrc = Netrc.read
netrc[Cupertino::HOSTNAME] = user, pass
netrc.save
Security::InternetPassword.add(Cupertino::HOSTNAME, user, pass)

say_ok "Account credentials saved"
end
Expand Down
6 changes: 2 additions & 4 deletions lib/cupertino/provisioning_portal/commands/logout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
c.description = ''

c.action do |args, options|
say_error "You are not authenticated" and abort unless Netrc.read[Cupertino::HOSTNAME]
say_error "You are not authenticated" and abort unless Security::InternetPassword.find(:server => Cupertino::HOSTNAME)

netrc = Netrc.read
netrc.delete(Cupertino::HOSTNAME)
netrc.save
Security::InternetPassword.delete(:server => Cupertino::HOSTNAME)

say_ok "Account credentials removed"
end
Expand Down

0 comments on commit 1ff02b9

Please sign in to comment.