Skip to content

Commit 7166c26

Browse files
author
Michael Oberwasserlechner
committed
feat(code): #13: authorizationCodeOnly from master
1 parent 27f8e84 commit 7166c26

File tree

7 files changed

+4
-43
lines changed

7 files changed

+4
-43
lines changed

android/@byteowls/capacitor-oauth2/src/main/java/com/byteowls/capacitor/oauth2/OAuth2ClientPlugin.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public class OAuth2ClientPlugin extends Plugin {
4040
private static final String PARAM_RESOURCE_URL = "resourceUrl";
4141
private static final String RESPONSE_TYPE_CODE = "code";
4242
private static final String RESPONSE_TYPE_TOKEN = "token";
43-
// private static final String PARAM_AUTHORIZATION_CODE_ONLY = "authorizationCodeOnly";
4443

4544
private OAuth2Options oauth2Options;
4645
private AuthorizationService authService;
@@ -193,13 +192,6 @@ protected OAuth2Options buildOptions(PluginCall call) {
193192
if (o.getState() == null || o.getState().trim().length() == 0) {
194193
o.setState(ConfigUtils.getRandomString(20));
195194
}
196-
// o.setAuthorizationCodeOnly(ConfigUtils.getCallParam(Boolean.class, call, OAuth2ClientPlugin.PARAM_AUTHORIZATION_CODE_ONLY, false));
197-
// if (o.isAuthorizationCodeOnly()) {
198-
// if (!RESPONSE_TYPE_CODE.equals(o.getResponseType())) {
199-
// Log.w(getLogTag(), "'" + PARAM_AUTHORIZATION_CODE_ONLY + "' is 'true' so '" + PARAM_RESPONSE_TYPE + "' must be 'code'! We fix that for you.");
200-
// }
201-
// o.setResponseType(RESPONSE_TYPE_CODE);
202-
// }
203195

204196
if (o.getResponseType() == null || o.getResponseType().length() == 0) {
205197
// fallback to token

android/@byteowls/capacitor-oauth2/src/main/java/com/byteowls/capacitor/oauth2/OAuth2Options.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public class OAuth2Options {
1212
private String responseType;
1313
private String scope;
1414
private String state;
15-
// private boolean authorizationCodeOnly;
1615
private String redirectUrl;
1716
private String customHandlerClass;
1817

@@ -72,14 +71,6 @@ public void setState(String state) {
7271
this.state = state;
7372
}
7473

75-
// public boolean isAuthorizationCodeOnly() {
76-
// return authorizationCodeOnly;
77-
// }
78-
//
79-
// public void setAuthorizationCodeOnly(boolean authorizationCodeOnly) {
80-
// this.authorizationCodeOnly = authorizationCodeOnly;
81-
// }
82-
8374
public String getRedirectUrl() {
8475
return redirectUrl;
8576
}

ios/ByteowlsCapacitorOauth2/Source/ByteowlsCapacitorOauth2.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public class OAuth2ClientPlugin: CAPPlugin {
1919
let PARAM_RESOURCE_URL = "resourceUrl"
2020
let RESPONSE_TYPE_CODE = "code"
2121
let RESPONSE_TYPE_TOKEN = "token"
22-
// let PARAM_AUTHORIZATION_CODE_ONLY = "authorizationCodeOnly"
2322

2423
var oauthSwift: OAuth2Swift?
2524
var handlerClasses = [String: OAuth2CustomHandler.Type]()

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@byteowls/capacitor-oauth2",
3-
"version": "1.0.0-alpha.28",
3+
"version": "1.0.0-beta.1",
44
"description": "Simple Capacitor OAuth 2 client plugin",
55
"author": "Michael Oberwasserlechner",
66
"homepage": "https://github.com/moberwasserlechner/capacitor-oauth2",

src/definitions.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export interface OAuth2AuthenticateOptions {
3939
*/
4040
resourceUrl?: string;
4141
/**
42-
* Defaults to 'token' aka implicit flow if emtpy and not used with @authorizationCodeOnly.
42+
* Defaults to 'token' aka implicit flow if emtpy.
4343
*
44-
* Be aware that this plugin does not support code flow with client secrets because of security reason.
44+
* Be aware that this plugin does not support authorization code flow with client secrets because of security reason.
4545
*
4646
* However code + PKCE will be supported in future. Please see github issue #4
4747
*/
@@ -55,13 +55,6 @@ export interface OAuth2AuthenticateOptions {
5555
* and sends it as using state is recommended.
5656
*/
5757
state?: string;
58-
59-
// /**
60-
// * Force the lib to only return the authorization code in the result.
61-
// * If true we use the code flow and the requestType is always "code".
62-
// * This becomes handy if you want to use it as part of a server side authorization code flow.
63-
// */
64-
// authorizationCodeOnly?: boolean;
6558
/**
6659
* Custom options for the platform "web"
6760
*/

src/web-utils.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ export class WebUtils {
1919
let appId = this.getAppId(options);
2020
let url = options.authorizationBaseUrl + "?client_id=" + appId;
2121

22-
if (options.authorizationCodeOnly) {
23-
if (options.responseType !== "code") {
24-
console.warn("'authorizationCodeOnly' is 'true' so 'responseType' must be 'code'! We fix that for you.");
25-
}
26-
options.responseType = "code";
27-
}
28-
2922
if (!options.responseType) {
3023
options.responseType = "token";
3124
}

src/web.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,7 @@ export class OAuth2ClientPluginWeb extends WebPlugin implements OAuth2ClientPlug
8181
// code flow
8282
let authorizationCode = urlParamObj.code;
8383
if (authorizationCode) {
84-
// if (options.authorizationCodeOnly) {
85-
// let resp = {
86-
// authorization_code: authorizationCode,
87-
// };
88-
// resolve(resp);
89-
// } else {
90-
// // TODO PKCE
91-
// }
84+
// TODO PKCE
9285
} else {
9386
reject(new Error("No authorization code found!"));
9487
}

0 commit comments

Comments
 (0)