securityAdded
This commit is contained in:
parent
b6c655cf1c
commit
8c57095046
@ -7,7 +7,7 @@
|
||||
<key>Friendvatars.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>2</integer>
|
||||
<integer>3</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
|
Binary file not shown.
@ -1,6 +1,7 @@
|
||||
import Foundation
|
||||
import CryptoSwift
|
||||
|
||||
|
||||
final class AuthController {
|
||||
|
||||
static let serviceName = "FriendvatarsService"
|
||||
@ -18,7 +19,36 @@ final class AuthController {
|
||||
}
|
||||
}
|
||||
|
||||
static func random(length: Int = 20) -> String {
|
||||
let base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
var randomString: String = ""
|
||||
|
||||
for _ in 0..<length {
|
||||
let randomValue = arc4random_uniform(UInt32(base.count))
|
||||
randomString += "\(base[base.index(base.startIndex, offsetBy: Int(randomValue))])"
|
||||
}
|
||||
return randomString
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class func passwordHash(from email: String, password: String) -> String {
|
||||
|
||||
func random(length: Int = 20) -> String {
|
||||
let base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
var randomString: String = ""
|
||||
|
||||
for _ in 0..<length {
|
||||
let randomValue = arc4random_uniform(UInt32(base.count))
|
||||
randomString += "\(base[base.index(base.startIndex, offsetBy: Int(randomValue))])"
|
||||
}
|
||||
return randomString
|
||||
}
|
||||
let randomSalt = random()
|
||||
print(randomSalt)
|
||||
let salt = "x4vV8bGgqqmQwgCoyXFQj+(o.nUNQhVP7ND"
|
||||
return "\(password).\(email).\(salt)".sha256()
|
||||
}
|
||||
|
@ -9,6 +9,17 @@
|
||||
import UIKit
|
||||
import KeychainAccess
|
||||
|
||||
func randomSecret(length: Int = 10) -> String {
|
||||
let base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
var randomString: String = ""
|
||||
|
||||
for _ in 0..<length {
|
||||
let randomValue = arc4random_uniform(UInt32(base.count))
|
||||
randomString += "\(base[base.index(base.startIndex, offsetBy: Int(randomValue))])"
|
||||
}
|
||||
return randomString.sha1()
|
||||
}
|
||||
|
||||
class NoteBiometricViewController: UIViewController {
|
||||
|
||||
@IBAction func isSignOut(_ sender: Any) {
|
||||
@ -32,12 +43,16 @@ class NoteBiometricViewController: UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
let secret = randomSecret()
|
||||
|
||||
@IBAction func storeSecret(_ sender: Any) {
|
||||
DispatchQueue.global().async {
|
||||
do {
|
||||
try self.keychain
|
||||
.accessibility(.whenPasscodeSetThisDeviceOnly, authenticationPolicy: .userPresence)
|
||||
.set(self.txtSecret.text!, key: "secret")
|
||||
.set(self.txtSecret.text!, key: self.secret)
|
||||
} catch let error {
|
||||
print(error)
|
||||
}
|
||||
@ -49,7 +64,7 @@ class NoteBiometricViewController: UIViewController {
|
||||
do {
|
||||
let secret = try self.keychain
|
||||
.authenticationPrompt("Zaloguj się biometrycznie, aby zobaczyć notatkę")
|
||||
.get("secret")
|
||||
.get(self.secret)
|
||||
self.lblSecret.text = "Twoja ukryta notatka to: \(secret!)"
|
||||
} catch let error {
|
||||
print(error)
|
||||
|
@ -54,11 +54,11 @@
|
||||
<action selector="getSecret:" destination="-1" eventType="touchUpInside" id="Ort-po-DdF"/>
|
||||
</connections>
|
||||
</button>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="NRj-yT-SM7">
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="TouchID" translatesAutoresizingMaskIntoConstraints="NO" id="NRj-yT-SM7">
|
||||
<rect key="frame" x="123" y="391" width="128" height="128"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Lbael" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UoU-LQ-ogi">
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UoU-LQ-ogi">
|
||||
<rect key="frame" x="53" y="323" width="280" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
@ -66,9 +66,12 @@
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="viewFlipsideBackgroundColor"/>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
|
||||
<point key="canvasLocation" x="53.600000000000001" y="48.125937031484263"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="TouchID" width="512" height="512"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
@ -8,9 +8,6 @@
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>CryptoSwift.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
@ -18,16 +15,15 @@
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<key>Pods-Friendvatars.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>Pods-Friendvatars.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
|
Loading…
Reference in New Issue
Block a user