Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions Sources/OAuthKit/OAuth+Provider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ extension OAuth {
public var customUserAgent: String?
/// Enables provider debugging. Off by default.
public var debug: Bool
/// An optional regex that can be used in conjuction with the ``OAuth/URLProtocol`` class to intercept outbound requests
/// and inject an `Authorization: Bearer <<token>>` header into a request.
public var authorizationPattern: String?

/// The coding keys.
enum CodingKeys: String, CodingKey {
Expand All @@ -58,7 +55,6 @@ extension OAuth {
case encodeHttpBody
case customUserAgent
case debug
case authorizationPattern
}

/// Public initializer.
Expand All @@ -75,7 +71,6 @@ extension OAuth {
/// - encodeHttpBody: If the provider should encode the access token parameters into the http body (true by default)
/// - customUserAgent: The custom user agent to send with browser requests.
/// - debug: Boolean to pass debugging into to the standard output (false by default)
/// - authorizationPattern: a regex pattern used to automatically match outbound url requests that should have authorization headers added
public init(id: String,
icon: URL? = nil,
authorizationURL: URL,
Expand All @@ -87,8 +82,7 @@ extension OAuth {
scope: [String]? = nil,
encodeHttpBody: Bool = true,
customUserAgent: String? = nil,
debug: Bool = false,
authorizationPattern: String? = nil) {
debug: Bool = false) {
self.id = id
self.icon = icon
self.authorizationURL = authorizationURL
Expand All @@ -101,7 +95,6 @@ extension OAuth {
self.encodeHttpBody = encodeHttpBody
self.customUserAgent = customUserAgent
self.debug = debug
self.authorizationPattern = authorizationPattern
}

/// Custom decoder initializer.
Expand All @@ -121,7 +114,6 @@ extension OAuth {
encodeHttpBody = try container.decodeIfPresent(Bool.self, forKey: .encodeHttpBody) ?? true
customUserAgent = try container.decodeIfPresent(String.self, forKey: .customUserAgent)
debug = try container.decodeIfPresent(Bool.self, forKey: .debug) ?? false
authorizationPattern = try container.decodeIfPresent(String.self, forKey: .authorizationPattern)
}
}
}
158 changes: 0 additions & 158 deletions Sources/OAuthKit/OAuth+URLProtocol.swift

This file was deleted.

10 changes: 0 additions & 10 deletions Sources/OAuthKit/OAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ public extension OAuth {
func clear() {
debugPrint("⚠️ [Clearing oauth state]")
keychain.clear()
URLProtocol.clear()
state = .empty
}
}
Expand Down Expand Up @@ -278,7 +277,6 @@ private extension OAuth {
func publish(state: State) {
switch state {
case .authorized(let provider, let auth):
addAuthorization(provider: provider, authorization: auth)
schedule(provider: provider, auth: auth)
case .receivedDeviceCode(let provider, let deviceCode):
schedule(provider: provider, deviceCode: deviceCode)
Expand All @@ -288,14 +286,6 @@ private extension OAuth {
self.state = state
}

/// Adds a received authorization to the ``OAuth/URLProtocol`` class.
/// - Parameters:
/// - provider: the provider
/// - authorization: the authorization issued by the provider
func addAuthorization(provider: Provider, authorization: Authorization) {
URLProtocol.addAuthorization(authorization, for: provider)
}

/// Schedules the provider to be polled for authorization with the specified device token.
/// - Parameters:
/// - provider: the oauth provider
Expand Down
3 changes: 0 additions & 3 deletions Sources/OAuthKit/OAuthKit.docc/Extensions/OAuth.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,3 @@ let oauth: OAuth = .init(.module, options: options)

- ``state``
- ``providers``

### OAuth Authorization Headers
- ``OAuthKit/OAuth/URLProtocol``
20 changes: 0 additions & 20 deletions Sources/OAuthKit/OAuthKit.docc/Extensions/URLProtocol.md

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 1 addition & 9 deletions Sources/OAuthKit/OAuthKit.docc/Tutorials/Contents.tutorial
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Tutorials(name: "Tutorials") {
@Intro(title: "OAuthKit Tutorials") {
Learn how to start OAuth flows, observe state changes, and use authorization tokens in API requests using URLProtocols.
Learn how to start OAuth flows and observe state changes.

@Image(source: tutorial-card.jpg, alt: "tutorial")
}
Expand All @@ -19,12 +19,4 @@
Learn the basics of how to create observable ``OAuth`` instances and start authorization flows.
@TutorialReference(tutorial: "doc:FlowsStates")
}

@Chapter(name: "URLProtocols with OAuthKit") {

@Image(source: blueprint-card.jpg, alt: "OAuthKit")

Leverage the ``OAuth/URLProtocol`` class to automatically have `Authorization` header values injected into matching outbound `URLRequest`.
@TutorialReference(tutorial: "doc:URLProtocol")
}
}
2 changes: 0 additions & 2 deletions Sources/OAuthKit/OAuthKit.docc/Tutorials/FlowsStates.tutorial
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

@Step {
Once the ``OAuth/Provider`` has been authorized, the ``OAuth/state`` will reach an ``OAuth/State/authorized(_:_:)`` state can you can dismiss the authorization window.

> Tip: See using the received authorization token in subsequent API requests in the <doc:URLProtocol> tutorial.
@Code(name: "ContentView.swift", file: flows-states-step-4.swift)
}
}
Expand Down
40 changes: 0 additions & 40 deletions Sources/OAuthKit/OAuthKit.docc/Tutorials/URLProtocol.tutorial

This file was deleted.

3 changes: 1 addition & 2 deletions Tests/OAuthKitTests/CodableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ struct CodableTests {
clientSecret: "CLIENT_SECRET",
scope: ["email"],
customUserAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15",
debug: true,
authorizationPattern: "github.com")
debug: true)

let data = try encoder.encode(provider)
let decoded: OAuth.Provider = try decoder.decode(OAuth.Provider.self, from: data)
Expand Down
Loading