Skip to content

Commit

Permalink
correct regelrett api scopes for SKIP (#256)
Browse files Browse the repository at this point in the history
* correct regelrett api scopes for SKIP

* correct regelrett api scopes for SKIP

* fix
  • Loading branch information
starheim98 authored Jan 22, 2025
1 parent 845babf commit 1512386
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
5 changes: 3 additions & 2 deletions frisk.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getMyMicrosoftTeams,
getTeam,
} from "@/services/backend";
import { getregelrettFrontendUrl } from "@/config";
import { getRegelrettClientId, getregelrettFrontendUrl } from "@/config";
import { object, string, array, type z } from "zod";
import { Button, FormControl, FormLabel, Select } from "@kvib/react";
import type { useFunction } from "@/hooks/use-function";
Expand Down Expand Up @@ -388,9 +388,10 @@ const RegelrettSchema = object({
type RegelrettSchema = z.infer<typeof RegelrettSchema>;

async function getRegelrettTokens() {
const REGELRETT_CLIENT_ID = getRegelrettClientId();
const regelrettScope =
import.meta.env.MODE === "skip"
? "api://regelrett-backend/regelrett"
? `api://${REGELRETT_CLIENT_ID}/regelrett`
: "api://e9dc946b-6fef-44ab-82f1-c0ec2e402903/.default";

const accounts = msalInstance.getAllAccounts();
Expand Down
21 changes: 11 additions & 10 deletions nginx/main.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
function getConfig(r) {
var config = {
clientId: process.env.VITE_CLIENT_ID,
authority: process.env.VITE_AUTHORITY,
redirect_uri: process.env.VITE_LOGIN_REDIRECT_URI,
backend_url: process.env.VITE_BACKEND_URL,
regelrett_frontend_url: process.env.VITE_REGELRETT_FRONTEND_URL
};
r.headersOut['Content-Type'] = 'application/json';
r.return(200, JSON.stringify(config));
var config = {
clientId: process.env.VITE_CLIENT_ID,
authority: process.env.VITE_AUTHORITY,
redirect_uri: process.env.VITE_LOGIN_REDIRECT_URI,
backend_url: process.env.VITE_BACKEND_URL,
regelrett_frontend_url: process.env.VITE_REGELRETT_FRONTEND_URL,
regelrett_client_id: process.env.REGELRETT_CLIENT_ID,
};
r.headersOut["Content-Type"] = "application/json";
r.return(200, JSON.stringify(config));
}

export default { getConfig };
export default { getConfig };
6 changes: 6 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface IConfig {
redirect_uri: string;
backend_url: string;
regelrett_frontend_url: string;
regelrett_client_id: string;
}

const defaultConfig: IConfig = {
Expand All @@ -21,6 +22,7 @@ const defaultConfig: IConfig = {
regelrett_frontend_url:
import.meta.env.VITE_REGLERRETT_FRONTEND_URL ??
"https://regelrett-frontend-1024826672490.europe-north1.run.app",
regelrett_client_id: import.meta.env.REGELRETT_CLIENT_ID ?? "",
};

export async function getConfig(): Promise<IConfig> {
Expand Down Expand Up @@ -62,3 +64,7 @@ export function getBackendUrl() {
export function getregelrettFrontendUrl() {
return config.regelrett_frontend_url;
}

export function getRegelrettClientId() {
return config.regelrett_client_id;
}

0 comments on commit 1512386

Please sign in to comment.