Change how we are handling secrets
This commit is contained in:
parent
05619da3fb
commit
59b0206e23
@ -35,9 +35,9 @@ class ArticleExtractor {
|
||||
public init?(_ articleLink: String) {
|
||||
self.articleLink = articleLink
|
||||
|
||||
let clientURL = ArticleExtractorConfig.Mercury.clientURL
|
||||
let username = ArticleExtractorConfig.Mercury.clientId
|
||||
let signiture = articleLink.hmacUsingSHA1(key: ArticleExtractorConfig.Mercury.clientSecret)
|
||||
let clientURL = ArticleExtractorConfig.clientURL
|
||||
let username = ArticleExtractorConfig.clientId
|
||||
let signiture = articleLink.hmacUsingSHA1(key: ArticleExtractorConfig.clientSecret)
|
||||
|
||||
if let base64URL = articleLink.data(using: .utf8)?.base64EncodedString() {
|
||||
let fullURL = "\(clientURL)/\(username)/\(signiture)?base64_url=\(base64URL)"
|
||||
|
@ -9,27 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
enum ArticleExtractorConfig {
|
||||
|
||||
enum Mercury {
|
||||
// For testing add the environment variables in the scheme you are using
|
||||
static let clientId = ArticleExtractorConfig.environmentVariable(named: "MERCURY_CLIENT_ID") ?? Release.mercuryId
|
||||
static let clientSecret = ArticleExtractorConfig.environmentVariable(named: "MERCURY_CLIENT_SECRET") ?? Release.mercurySecret
|
||||
static let clientURL = Release.mercuryURL
|
||||
}
|
||||
|
||||
private enum Release {
|
||||
static let mercuryId = "{MERCURYID}"
|
||||
static let mercurySecret = "{MERCURYSECRET}"
|
||||
static let mercuryURL = "https://extract.feedbin.com/parser"
|
||||
}
|
||||
|
||||
private static func environmentVariable(named: String) -> String? {
|
||||
let processInfo = ProcessInfo.processInfo
|
||||
guard let value = processInfo.environment[named] else {
|
||||
print("‼️ Missing Environment Variable: '\(named)'")
|
||||
return nil
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
static let clientId = "{MERCURYID}"
|
||||
static let clientSecret = "{MERCURYSECRET}"
|
||||
static let clientURL = "https://extract.feedbin.com/parser"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user