Skip to content

Commit 43b54c5

Browse files
committed
Merge branch 'master' into develop
# Conflicts: # CONTRIBUTORS.md
2 parents fb4d26e + e81b4bc commit 43b54c5

14 files changed

+168
-18
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0
1+
4.2

CHANGELOG.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,71 @@ Changelog
44
Version numbering represents the Swift version, plus a running number representing updates, fixes and new features at the same time.
55
You can also refer to commit logs to get details on what was implemented, fixed and improved.
66

7+
### Master
8+
9+
- Swift 4.2 support.
10+
[djbe](https://github.com/djbe)
11+
[#273](https://github.com/p2/OAuth2/pull/273)
12+
- Fix crash due to memory ownership.
13+
[foldericon](https://github.com/foldericon)
14+
[#271](https://github.com/p2/OAuth2/pull/271)
15+
- Added an Auth2 implicit grant variation for requests that return parameters in the query instead of the fragment.
16+
[tschmitz](https://github.com/tschmitz)
17+
[#262](https://github.com/p2/OAuth2/pull/262)
18+
- Fix some Swift 4 warnings.
19+
[everlof](https://github.com/everlof)
20+
[#251](https://github.com/p2/OAuth2/pull/251)
21+
- Pass back a strongly typed `OAuth2Error` when possible (along with `error_description`). Also added an `invalidGrant` error.
22+
[sebskuse](https://github.com/sebskuse)
23+
[#248](https://github.com/p2/OAuth2/pull/248)
24+
- You can now implement your own custom loggers.
25+
[p2](https://github.com/p2)
26+
[#236](https://github.com/p2/OAuth2/pull/236)
27+
- Fixed parsing errors with empty descriptions.
28+
[p2](https://github.com/p2)
29+
[#247](https://github.com/p2/OAuth2/pull/247)
30+
- Fix the appearance and location of the `Cancel` button on macOS.
31+
[kengruven](https://github.com/kengruven)
32+
[#246](https://github.com/p2/OAuth2/pull/246)
33+
34+
### 4.0.1
35+
36+
- Correct the ACL for `updateFromKeychainItems` to `open`.
37+
[JohnTheBastard](https://github.com/JohnTheBastard)
38+
[#239](https://github.com/p2/OAuth2/pull/239)
39+
- Fixed unauthorized error when refreshing a token.
40+
[amaurydavid](https://github.com/amaurydavid)
41+
[#237](https://github.com/p2/OAuth2/pull/237)
42+
- Fixed an exception due to the web policy completion handler being called twice.
43+
[Kashkovsky](https://github.com/Kashkovsky)
44+
[#235](https://github.com/p2/OAuth2/pull/235)
45+
- Bubble errors up from a token fetch to the client.
46+
[dhardiman](https://github.com/dhardiman)
47+
[#232](https://github.com/p2/OAuth2/pull/232)
48+
[#234](https://github.com/p2/OAuth2/pull/234)
49+
50+
### 4.0.0
51+
52+
- Update to Swift 4.
53+
[paulw11](https://github.com/paulw11)
54+
[#228](https://github.com/p2/OAuth2/pull/228)
55+
- Fix an assertion error in Xcode 9.
56+
[markmarkswell](https://github.com/markmarkswell)
57+
[#227](https://github.com/p2/OAuth2/pull/227)
58+
- Remove the dependency on the system `sharedApplication` property to support use in extensions.
59+
[robertbarclay](https://github.com/robertbarclay)
60+
[#212](https://github.com/p2/OAuth2/pull/212)
61+
- Changed the ACL of `customAuthorizer` from `internal` to `open`.
62+
[amaurydavid](https://github.com/amaurydavid)
63+
[#203](https://github.com/p2/OAuth2/pull/203)
64+
- Corrected some typos in the codebase and documentation.
65+
[Lutzifer](https://github.com/Lutzifer)
66+
[#199](https://github.com/p2/OAuth2/pull/199)
67+
- Fixed some warnings with String interpolation.
68+
[paulw11](https://github.com/paulw11)
69+
[jakepetroules](https://github.com/jakepetroules)
70+
[#195](https://github.com/p2/OAuth2/pull/195)
71+
[#204](https://github.com/p2/OAuth2/pull/204)
772

873
### 3.0.3
974

CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Contributors
33

44
Contributors to the codebase, in reverse chronological order:
55

6+
- David Jennes, @davidjennes
7+
- Tim Schmitz, @tschmitz
68
- Maxime Le Moine, @MaximeLM
79
- Seb Skuse, @sebskuse
810
- David Hardiman, @dhardiman

OAuth2.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@
830830
PRODUCT_NAME = OAuth2;
831831
SDKROOT = appletvos;
832832
SKIP_INSTALL = YES;
833-
SWIFT_VERSION = 3.0;
833+
SWIFT_VERSION = 4.2;
834834
TARGETED_DEVICE_FAMILY = 3;
835835
TVOS_DEPLOYMENT_TARGET = 9.0;
836836
};
@@ -858,7 +858,7 @@
858858
SDKROOT = appletvos;
859859
SKIP_INSTALL = YES;
860860
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
861-
SWIFT_VERSION = 3.0;
861+
SWIFT_VERSION = 4.2;
862862
TARGETED_DEVICE_FAMILY = 3;
863863
TVOS_DEPLOYMENT_TARGET = 9.0;
864864
};
@@ -990,7 +990,7 @@
990990
PRODUCT_NAME = OAuth2;
991991
SKIP_INSTALL = YES;
992992
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
993-
SWIFT_VERSION = 4.0;
993+
SWIFT_VERSION = 4.2;
994994
};
995995
name = Debug;
996996
};
@@ -1012,7 +1012,7 @@
10121012
PRODUCT_NAME = OAuth2;
10131013
SKIP_INSTALL = YES;
10141014
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1015-
SWIFT_VERSION = 4.0;
1015+
SWIFT_VERSION = 4.2;
10161016
};
10171017
name = Release;
10181018
};
@@ -1034,7 +1034,7 @@
10341034
PRODUCT_NAME = OAuth2;
10351035
SDKROOT = macosx;
10361036
SKIP_INSTALL = YES;
1037-
SWIFT_VERSION = 4.0;
1037+
SWIFT_VERSION = 4.2;
10381038
};
10391039
name = Debug;
10401040
};
@@ -1058,7 +1058,7 @@
10581058
SDKROOT = macosx;
10591059
SKIP_INSTALL = YES;
10601060
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1061-
SWIFT_VERSION = 4.0;
1061+
SWIFT_VERSION = 4.2;
10621062
};
10631063
name = Release;
10641064
};
@@ -1077,7 +1077,7 @@
10771077
PRODUCT_BUNDLE_IDENTIFIER = "com.github.p2.${PRODUCT_NAME:rfc1034identifier}";
10781078
PRODUCT_NAME = "$(TARGET_NAME)";
10791079
SDKROOT = macosx;
1080-
SWIFT_VERSION = 3.0;
1080+
SWIFT_VERSION = 4.2;
10811081
};
10821082
name = Debug;
10831083
};
@@ -1098,7 +1098,7 @@
10981098
PRODUCT_NAME = "$(TARGET_NAME)";
10991099
SDKROOT = macosx;
11001100
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1101-
SWIFT_VERSION = 3.0;
1101+
SWIFT_VERSION = 4.2;
11021102
};
11031103
name = Release;
11041104
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ OAuth2
44
[![Build Status](https://travis-ci.org/p2/OAuth2.svg?branch=master)](https://travis-ci.org/p2/OAuth2)
55
[![License](https://img.shields.io/:license-apache-blue.svg)](LICENSE.txt)
66

7-
OAuth2 frameworks for **macOS**, **iOS** and **tvOS** written in Swift 3.0.
7+
OAuth2 frameworks for **macOS**, **iOS** and **tvOS** written in Swift 4.2.
88

99
- [⤵️ Installation](#installation)
1010
- [🛠 Usage](#usage)

Sources/Base/OAuth2AuthRequest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ Class representing an OAuth2 authorization request that can be used to create NS
6969
open class OAuth2AuthRequest {
7070

7171
/// The url of the receiver. Queries may by added by parameters specified on `params`.
72-
open let url: URL
72+
public let url: URL
7373

7474
/// The HTTP method.
75-
open let method: OAuth2HTTPMethod
75+
public let method: OAuth2HTTPMethod
7676

7777
/// The content type that will be specified. Defaults to `wwwForm`.
7878
open var contentType = OAuth2HTTPContentType.wwwForm

Sources/Base/OAuth2AuthorizerUI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Platform-dependent authorizers must adopt this protocol.
2727
public protocol OAuth2AuthorizerUI {
2828

2929
/// The OAuth2 instance this authorizer belongs to.
30-
unowned var oauth2: OAuth2Base { get }
30+
var oauth2: OAuth2Base { get }
3131

3232
/**
3333
Open the authorize URL in the OS browser.

Sources/Base/OAuth2Base.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ open class OAuth2Base: OAuth2Securable {
3737
}
3838

3939
/// Settings related to the client-server relationship.
40-
open let clientConfig: OAuth2ClientConfig
40+
public let clientConfig: OAuth2ClientConfig
4141

4242
/// Client-side authorization options.
4343
open var authConfig = OAuth2AuthConfig()
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// OAuth2ImplicitGrantWithQueryParams.swift
3+
// OAuth2
4+
//
5+
// Created by Tim Schmitz on 5/3/18.
6+
// Copyright 2018 Tim Schmitz
7+
//
8+
// Licensed under the Apache License, Version 2.0 (the "License");
9+
// you may not use this file except in compliance with the License.
10+
// You may obtain a copy of the License at
11+
//
12+
// http://www.apache.org/licenses/LICENSE-2.0
13+
//
14+
// Unless required by applicable law or agreed to in writing, software
15+
// distributed under the License is distributed on an "AS IS" BASIS,
16+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
// See the License for the specific language governing permissions and
18+
// limitations under the License.
19+
//
20+
21+
22+
23+
import Foundation
24+
#if !NO_MODULE_IMPORT
25+
import Base
26+
#endif
27+
28+
29+
/**
30+
Class to handle OAuth2 implicit grant requests that return params in the query
31+
instead of the fragment.
32+
*/
33+
open class OAuth2ImplicitGrantWithQueryParams: OAuth2ImplicitGrant {
34+
35+
override open func handleRedirectURL(_ redirect: URL) {
36+
logger?.debug("OAuth2", msg: "Handling redirect URL \(redirect.description)")
37+
do {
38+
// token should be in the URL query
39+
let comp = URLComponents(url: redirect, resolvingAgainstBaseURL: true)
40+
guard let query = comp?.query, query.count > 0 else {
41+
throw OAuth2Error.invalidRedirectURL(redirect.description)
42+
}
43+
44+
let params = type(of: self).params(fromQuery: query)
45+
let dict = try parseAccessTokenResponse(params: params)
46+
logger?.debug("OAuth2", msg: "Successfully extracted access token")
47+
didAuthorize(withParameters: dict)
48+
}
49+
catch let error {
50+
didFail(with: error.asOAuth2Error)
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)