Comments (5)
Hi @danielheth , in its default configuration the AuthJS library does need to use the # fragment. You can configure the callback to be query-parameter based, which would allow you to use the # fragment for your own routing instead. However I'm not sure if this library has property abstracted those configuration options. I'm referring to the responseMode
option that is mentioned here:
https://github.com/okta/okta-auth-js#openid-connect-options
from okta-oidc-js.
The OAuth spec requires that only one hash fragment exist.
The redirection endpoint URI MUST be an absolute URI as defined by
[RFC3986] Section 4.3. The endpoint URI MAY include an
"application/x-www-form-urlencoded" formatted (per Appendix B) query
component ([RFC3986] Section 3.4), which MUST be retained when adding
additional query parameters. The endpoint URI MUST NOT include a
fragment component.
So you have two options:
- Do URL rewrites for your SPA
- Create another page that's not part of the SPA that contains your callback logic. This will be your new
redirect_uri
. Make sure to add this page's url to your list of redirect uris in Okta. Here's what it might look like:
<!-- callback.html -->
<script>
// OIDC variables
var issuer = '## your issuer ##';
var clientId = '## your clientId ##';
var redirectUri = '## your redirect uri (this page) ##';
var redirectAfterSuccess = '## your destination after successful signin ##';
// build an auth client
var client = new OktaAuth({
url: issuer.split('/oauth2/')[0],
clientId: clientId
issuer: issuer,
redirectUri: redirectUri
});
// parse tokens from the url
client.token.parseFromUrl()
.then(function(tokens) {
// add tokens to the tokenManager
for (var t = 0; t < tokens.length; t++) {
var token = tokens[t];
if (token.idToken) {
client.tokenManager.add('idToken', token);
} else if (token.accessToken) {
client.tokenManager.add('accessToken', token);
}
}
// redirect when finished
window.location = redirectAfterSuccess;
})
.catch(function(err) {
// handle the error
});
</script>
from okta-oidc-js.
I was able to track down that you're using the localStorage
browser functionality to store tokens... i tested it by using:
localStorage.setItem('hello', '1234');
console.log('hello:', localStorage.getItem('hello'));
And didn't have any troubles.. so somewhere in your code... localStorage isn't working correctly.
from okta-oidc-js.
Finally got a very simple angular2 app working... but the instant i enabled HashLocationStrategy (https://angular.io/api/common/HashLocationStrategy) things blew up.
I believe it is because this line assumes there will only be one hash (#) within the url... https://github.com/okta/okta-auth-js/blob/f162b052efd664dd0db843032c1970dec4639e66/lib/token.js#L599
from okta-oidc-js.
Closing down this issue due the answers provided. Please reopen is the problem persists.
from okta-oidc-js.
Related Issues (20)
- Security vulnerabilities in jwt-verifier dependencies HOT 2
- @okta/jwt-verifier > njwt > [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() HOT 1
- ID token refresh Feature Request/Question HOT 1
- decode function ? HOT 2
- a way to verify using a pem ? HOT 1
- Typescript Options interface missing jwskUri property HOT 2
- Security vulnerability in [email protected] HOT 2
- okta-oidc-js error in documentation on how to work with Proxies HOT 2
- Showing component only for authenticated user, but for every path, without rerendering each time path changes. HOT 5
- SecureRoute is not passing Router props to my component HOT 2
- security vulnerabilities from lodash HOT 2
- done is not a function in oidcUtils.bootstrapPassportStrategy HOT 12
- react-router Link to a SecureRoute yields "OAuth flow response state doesn't match request state" HOT 4
- /implicit/callback route not working for any version of @okta/okta-angular HOT 5
- Security vulnerability in jwks-rsa's dependency HOT 5
- Server-side request forgery HOT 3
- Creating Multiple OIDC instances in Nodejs('@okta/oidc-middleware') HOT 6
- Error while resolving signing key for kid . Unable to verify first certificate HOT 2
- JWT-verifier -> [JwtParseError: Unexpected signature algorithm] HOT 6
- JWT-verifier -> Unable to find a signing key that matches 'xxxx' HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from okta-oidc-js.