Oidc-client-js: authentication approach on Ionic/Cordova

Created on 16 Feb 2019  路  3Comments  路  Source: IdentityModel/oidc-client-js

hello, i want to know if my approach is the right approach on Ionic with Authorization Code Flow.
I use startAuthentication to retrieve authentication url to open in Ionic InAppBrowser, when i got back redirect_uri i call completeAuthentication.
For logout i use startlogout

```javascript
startAuthentication(): Promise < string > {
return new Promise((resolve, reject) => {
this.manager.createSigninRequest().then((request: SigninRequest) => {
resolve(request.url);
}, (reason) => {
reject(reason);
})
})
}
completeAuthentication(url: string): Promise < void > {
return this.manager.processSigninResponse(url).then((response: SigninResponse) => {
this.user = new User(response);
this.manager.storeUser(this.user);
});
}
startlogout(): Promise < string > {
return new Promise((resolve, reject) => {
this.manager.revokeAccessToken().then(() => {
this.manager.removeUser().then(() => {
this.manager.createSignoutRequest().then((request) => {
this.user = null;
resolve(request.url);
}, (reason) => {
reject(reason);
});
}, (reason) => {
reject(reason);
});
}, (reason) => {
reject(reason);
});
});
}
completeLogout(url: string): Promise < SignoutResponse > {
return this.manager.processSignoutResponse(url);
}
getClientSettings(): UserManagerSettings {
return {
authority: 'http://myaddress:50001/',
client_id: 'ionic',
redirect_uri: 'http://myaddress/oidc-callback/',
post_logout_redirect_uri: 'http://myaddress/oidc-callback/',
response_type: "code",
scope: "openid profile api",
filterProtocolClaims: true,
loadUserInfo: true,
userStore: new WebStorageStateStore({
store: window.localStorage
})
};
}

question

Most helpful comment

Hi,

I also had this issue with oidc-client-js, the issue is that the creators only intended this library to be used for implicit flow with a front end framework. This is perfect for websites but not ideal for mobile apps in modern development.

The creators of this repo generally direct users towards AppAuth-JS but you will find it a bit more complicated to set up than this repo.

I created my own repo that you can use https://github.com/MatrixMatt249/ionic-appauth this is an npm wrapper of AppAuth-JS specifically for Ionic V3/V4.
There is also a demo at https://github.com/MatrixMatt249/ionic-appauth-ng-demo

Hope this helps,

All 3 comments

Hi
Did you confirm this approach?
It's seems like this example is only thing that I was able to find that's related with cordova app login with IdentityServer4.
How did you call startAuthentication() and what is expected url for completeAuthentication(url: string)?
Can you maybe share your example? I really would like to understand cordova pp login approach.
Thanks

Hi,

I also had this issue with oidc-client-js, the issue is that the creators only intended this library to be used for implicit flow with a front end framework. This is perfect for websites but not ideal for mobile apps in modern development.

The creators of this repo generally direct users towards AppAuth-JS but you will find it a bit more complicated to set up than this repo.

I created my own repo that you can use https://github.com/MatrixMatt249/ionic-appauth this is an npm wrapper of AppAuth-JS specifically for Ionic V3/V4.
There is also a demo at https://github.com/MatrixMatt249/ionic-appauth-ng-demo

Hope this helps,

All set on this issue -- can we close?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iXmonvi33 picture iXmonvi33  路  4Comments

slug56 picture slug56  路  4Comments

tomeinar picture tomeinar  路  3Comments

rmja picture rmja  路  3Comments

primozs picture primozs  路  3Comments