Skip to content

Commit

Permalink
Merge pull request #488 from radiantearth/oidc-pathprefix
Browse files Browse the repository at this point in the history
Bugfix for OIDC: pathPrefix not acknowledged and requests sent without Auth details #479
  • Loading branch information
m-mohr authored Oct 14, 2024
2 parents d10fc7d + 52a566d commit cce41cf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
3 changes: 2 additions & 1 deletion docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ For OpenID Connect some additional options must be provided, which currently fol
[oidc-client-ts Configuration options](https://github.com/okta/okta-auth-js?tab=readme-ov-file#configuration-options).
These options (except for `issuer`) must be provided in the property `oidcConfig`.
The `client_id` option defaults to `stac-browser`.
The redirect URL for the OIDC client must be set as follows:

The redirect URL for the OIDC client must be the STAC Browser URL, e.g. `https://mycompany.com/browser`, plus an appended `/auth`, so for example `https://mycompany.com/browser/auth`.

#### Example

Expand Down
8 changes: 2 additions & 6 deletions src/auth/oidc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ export default class OIDC extends Auth {
}

getRedirectUri(appPath) {
let base = this.router.options.base;
let path = this.router.resolve(appPath).href;
if (base.endsWith('/') && path.startsWith('/')) {
base = base.substring(0, base.length - 1);
}
return window.location.origin + base + path;
const path = this.router.resolve(appPath).href;
return window.location.origin + path;
}

async close() {
Expand Down
6 changes: 0 additions & 6 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,6 @@ function getStore(config, router) {
for (let key in config) {
let value = cx.state[key];
switch (key) {
case 'catalogUrl':
if (value) {
// Load the root catalog data if not available (e.g. after page refresh or external access)
await cx.dispatch("load", { url: value, loadApi: true });
}
break;
case 'authConfig':
await cx.dispatch('auth/updateMethod', value);
break;
Expand Down
8 changes: 7 additions & 1 deletion src/views/BrowseMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {
}
},
computed: {
...mapState(["allowExternalAccess", "url", "redirectLegacyUrls"]),
...mapState(["allowExternalAccess", "catalogUrl", "url", "redirectLegacyUrls"]),
...mapGetters(["fromBrowserPath", "error", "loading"]),
errorId() {
if (this.error instanceof Error && this.error.isAxiosError && Utils.isObject(this.error.response)) {
Expand All @@ -30,6 +30,12 @@ export default {
}
return null;
},
created() {
// Load the root catalog data if not available (e.g. after page refresh or external access)
if (this.catalogUrl) {
this.$store.dispatch("load", { url: this.catalogUrl, loadApi: true });
}
},
errorDescription() {
if (this.error instanceof Error && this.error.isAxiosError && Utils.isObject(this.error.response)) {
let res = this.error.response;
Expand Down

0 comments on commit cce41cf

Please sign in to comment.