Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ionic integration improvement #293

Merged
merged 4 commits into from Apr 6, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -144,7 +144,9 @@ From the **Applications** page, choose **Add Application**. On the Create New Ap
* Logout redirect URIs:
* `http://localhost:8100/implicit/logout`
* `com.okta.dev-737523:/logout`
* Grant type allowed: **Authorization Code**
* Grant type allowed:
- [x] **Authorization Code**
- [x] **Refresh Token**
* Click **Done**

You will also need to add `http://localhost:8100` as a Trusted Origin in **API** > **Trusted Origins**.
Expand Down
12 changes: 7 additions & 5 deletions src/add-auth/index.ts
Expand Up @@ -48,12 +48,14 @@ function addPackageJsonDependencies(framework: string, options: any): Rule {
}
} else if (framework === IONIC_ANGULAR) {
dependencies.push({type: NodeDependencyType.Default, version: '0.5.1', name: 'ionic-appauth'});
dependencies.push({type: NodeDependencyType.Default, version: '2.2.0', name: '@ionic/storage'});
dependencies.push({type: NodeDependencyType.Default, version: '5.23.0', name: '@ionic-native/secure-storage'});
if (options.platform === 'capacitor') {
dependencies.push({type: NodeDependencyType.Default, version: '3.0.2', name: 'cordova-plugin-secure-storage'});
dependencies.push({type: NodeDependencyType.Default, version: '5.0.1', name: 'cordova-plugin-secure-storage-echo'});
dependencies.push({type: NodeDependencyType.Default, version: '2.4.1', name: 'cordova-plugin-advanced-http'});
dependencies.push({type: NodeDependencyType.Default, version: '1.6.0', name: 'cordova-plugin-safariviewcontroller'});
dependencies.push({type: NodeDependencyType.Default, version: '5.23.0', name: '@ionic-native/http'});
} else {
dependencies.push({type: NodeDependencyType.Default, version: '2.2.0', name: '@ionic/storage'});
}
}

Expand Down Expand Up @@ -202,15 +204,15 @@ export function addAuth(options: any): Rule {
}
host.overwrite('./package.json', JSON.stringify(pkgJson));
}
addModuleImportToModule(host, 'src/app/app.module.ts',
'IonicStorageModule.forRoot()', '@ionic/storage');
}

// add imports to app.module.ts
addModuleImportToModule(host, 'src/app/app.module.ts',
'HttpClientModule', '@angular/common/http');
addModuleImportToModule(host, 'src/app/app.module.ts',
'AuthModule', './auth/auth.module');
addModuleImportToModule(host, 'src/app/app.module.ts',
'IonicStorageModule.forRoot()', '@ionic/storage');
}

if (framework === REACT_NATIVE) {
Expand Down Expand Up @@ -297,7 +299,7 @@ export function cordovaNode(packageName: string) {
'cordova-plugin-advanced-http': {},
'cordova-plugin-safariviewcontroller': {},
'cordova-plugin-inappbrowser': {},
'cordova-plugin-secure-storage': {},
'cordova-plugin-secure-storage-echo': {},
'cordova-plugin-customurlscheme': {
'URL_SCHEME': packageName
},
Expand Down
4 changes: 2 additions & 2 deletions src/add-auth/ionic/angular/src/app/auth/auth.service.ts
Expand Up @@ -49,8 +49,8 @@ export class AuthService extends IonicAuth {

private async addConfig() {
const scopes = 'openid profile offline_access';
const redirectUri = this.onDevice() ? '<%= packageName %>:/callback' : 'http://localhost:8100/implicit/callback';
const logoutRedirectUri = this.onDevice() ? '<%= packageName %>:/logout' : 'http://localhost:8100/implicit/logout';
const redirectUri = this.onDevice() ? '<%= packageName %>:/callback' : window.location.origin + '/implicit/callback';
const logoutRedirectUri = this.onDevice() ? '<%= packageName %>:/logout' : window.location.origin + '/implicit/callback';
<% if (configUri) { %>const AUTH_CONFIG_URI = '<%= configUri %>';

if (await this.storage.getItem(AUTH_CONFIG_URI)) {
Expand Down