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

Bug 435. Login redirects and running under different hostnames #454

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/(rucio)/did/list/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function Page() {
}
const didQuery = async (query: string, type: DIDType) => {
const request: any = {
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-dids`),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change refers to making deployments more flexible and accessible through any hostname. All the places where the hostname was specified through an environmental variable are reviewed.

url: new URL(`${window.location.protocol}//${window.location.host}/api/feature/list-dids`),
method: 'GET',
headers: new Headers({
'Content-Type': 'application/json',
Expand Down
12 changes: 6 additions & 6 deletions src/app/(rucio)/did/page/[scope]/[name]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function Page({ params }: { params: { scope: string, name: string
)
const didFileReplicasDOnChange = (scope: string, name: string) => {
didFileReplicasComDOM.setRequest({
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-file-replicas`),
url: new URL(`${window.location.protocol}//${window.location.host}/api/feature/list-file-replicas`),
method: 'GET',
params: {
scope: scope,
Expand All @@ -52,7 +52,7 @@ export default function Page({ params }: { params: { scope: string, name: string
useEffect(() => {
const setRequests = async () => {
await didContentsComDOM.setRequest({
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-did-contents`),
url: new URL(`${window.location.protocol}//${window.location.host}/api/feature/list-did-contents`),
method: 'GET',
params: {
scope: params.scope,
Expand All @@ -64,7 +64,7 @@ export default function Page({ params }: { params: { scope: string, name: string
body: null,
} as HTTPRequest)
await didParentsComDOM.setRequest({
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-did-parents`),
url: new URL(`${window.location.protocol}//${window.location.host}/api/feature/list-did-parents`),
method: 'GET',
params: {
scope: params.scope,
Expand All @@ -76,7 +76,7 @@ export default function Page({ params }: { params: { scope: string, name: string
body: null,
} as HTTPRequest)
await didFileReplicasComDOM.setRequest({
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-file-replicas`),
url: new URL(`${window.location.protocol}//${window.location.host}/api/feature/list-file-replicas`),
method: 'GET',
params: {
scope: params.scope,
Expand All @@ -88,7 +88,7 @@ export default function Page({ params }: { params: { scope: string, name: string
body: null,
} as HTTPRequest)
await didRulesComDOM.setRequest({
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-did-rules`),
url: new URL(`${window.location.protocol}//${window.location.host}/api/feature/list-did-rules`),
method: 'GET',
params: {
scope: params.scope,
Expand All @@ -100,7 +100,7 @@ export default function Page({ params }: { params: { scope: string, name: string
body: null,
} as HTTPRequest)
await didDatasetReplicasComDOM.setRequest({
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-dataset-replicas`),
url: new URL(`${window.location.protocol}//${window.location.host}/api/feature/list-dataset-replicas`),
method: 'GET',
params: {
scope: params.scope,
Expand Down
4 changes: 2 additions & 2 deletions src/app/(rucio)/did/queries.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { DIDKeyValuePairsDataViewModel, DIDMetaViewModel } from "@/lib/infrastructure/data/view-model/did";

export async function didMetaQueryBase(scope: string, name: string): Promise<DIDMetaViewModel> {
const url = `${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/get-did-meta?` + new URLSearchParams({scope, name})
const url = '/api/feature/get-did-meta?' + new URLSearchParams({scope, name})
const res = await fetch(url)
return await res.json()
}

export async function didKeyValuePairsDataQuery(scope: string, name: string): Promise<DIDKeyValuePairsDataViewModel> {
const url = `${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/get-did-keyvaluepairs?` + new URLSearchParams({scope, name})
const url = '/api/feature/get-did-keyvaluepairs?' + new URLSearchParams({scope, name})
const res = await fetch(url)
return await res.json()
}
19 changes: 1 addition & 18 deletions src/app/(rucio)/queries.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
import { SiteHeaderViewModel } from '@/lib/infrastructure/data/view-model/site-header'

export async function getSiteHeader(): Promise<SiteHeaderViewModel> {
const req: any = {
method: 'GET',
url: new URL(
`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/get-site-header`,
),
headers: {
'Content-Type': 'application/json',
},
params: {},
}

const res = await fetch(req.url, {
method: 'GET',
headers: new Headers({
'Content-Type': 'application/json',
} as HeadersInit),
})

const res = await fetch('/api/feature/get-site-header')
return await res.json()
}
2 changes: 1 addition & 1 deletion src/app/(rucio)/rse/list/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function Page() {

const setRSEQuery = async (rseExpression: string) => {
await RSESearchComDOM.setRequest({
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-rses`),
url: new URL(`${window.location.protocol}//${window.location.host}/api/feature/list-rses`),
method: 'GET',
headers: new Headers({
'Content-Type': 'application/json',
Expand Down
6 changes: 3 additions & 3 deletions src/app/(rucio)/rse/page/[name]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import { RSEAttributeViewModel, RSEProtocolViewModel, RSEViewModel } from "@/lib
import { useEffect, useState } from "react";

async function getRSE(rseName: string): Promise<RSEViewModel> {
const url = `${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/get-rse?` + new URLSearchParams({rseName})
const url = '/api/feature/get-rse?' + new URLSearchParams({rseName})
const res = await fetch(url)
return await res.json()
}

async function getProtocols(rseName: string): Promise<RSEProtocolViewModel> {
const url = `${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/get-rse-protocols?` + new URLSearchParams({rseName})
const url = '/api/feature/get-rse-protocols?' + new URLSearchParams({rseName})
const res = await fetch(url)
return await res.json()
}

async function getAttributes(rseName:string): Promise<RSEAttributeViewModel> {
const url = `${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/get-rse-attributes?` + new URLSearchParams({rseName})
const url = '/api/feature/get-rse-attributes?' + new URLSearchParams({rseName})
const res = await fetch(url)
return await res.json()
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/(rucio)/rucio-app-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const RucioAppLayout = (props: QueryContextLayoutProps) => {
homeUrl: ""
})
const fetchAccounts = async () => {
await fetch(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/get-site-header`)
await fetch('/api/feature/get-site-header')
.then(res => {
if (res.ok) {
return res.json()
Expand Down
4 changes: 2 additions & 2 deletions src/app/(rucio)/rule/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function CreateRule() {
viewModel.status = 'pending'

try {
const response = await fetch(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/create-rule`, {
const response = await fetch(`/api/feature/create-rule`, {
method: "POST",
headers: new Headers({
'Content-Type': 'application/json'
Expand Down Expand Up @@ -100,7 +100,7 @@ export default function CreateRule() {

const [accountInfo, setAccountInfo] = useState<AccountInfo>(generateEmptyAccountInfoViewModel())
useEffect(() => {
fetch(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/account-info`)
fetch(`${window.location.protocol}//${window.location.host}/api/feature/account-info`)
.then((response) => {
if(response.ok) {
return response.json()
Expand Down
4 changes: 2 additions & 2 deletions src/app/(rucio)/rule/page/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function PageRule({ params }: { params: { id: string } }) {

useEffect(() => {
// TODO get from mock endpoint
fetch(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/mock-get-rule-meta`)
fetch('/api/feature/mock-get-rule-meta')
.then(res => {
if (res.ok) {
return res.json()
Expand All @@ -46,7 +46,7 @@ export default function PageRule({ params }: { params: { id: string } }) {
useEffect(() => {
const runQuery = async () => {
const request: HTTPRequest = {
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/mock-list-rule-page-lock`),
url: new URL(`${window.location.protocol}//${window.location.host}/api/feature/mock-list-rule-page-lock`),
method: "GET",
headers: new Headers({
'Content-Type': 'application/json'
Expand Down
2 changes: 1 addition & 1 deletion src/app/(rucio)/subscription/list/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function ListSubscription({ params }: { params: { account: string
useEffect(() => {
const runQuery = async () => {
await ComDOM.start({
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-subscription-rule-states`),
url: new URL(`${window.location.protocol}//${window.location.host}/api/feature/list-subscription-rule-states`),
method: "GET",
headers: new Headers({
'Content-Type': 'application/json'
Expand Down
4 changes: 2 additions & 2 deletions src/app/(rucio)/subscription/page/[account]/[name]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function updateSubscription(
) {
const req: any = {
method: "PUT",
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/mock-update-subscription`),
url: new URL(`/api/feature/mock-update-subscription`),
headers: {
'Content-Type': 'application/json',
},
Expand Down Expand Up @@ -43,7 +43,7 @@ export default function PageSubscription({ params }: { params: { account: string
async function subscriptionQuery(account: string, name: string): Promise<SubscriptionViewModel> {
const req: any = {
method: "GET",
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/get-subscription`),
url: new URL(`/api/feature/get-subscription`),
params: {
"account": account,
"name": name
Expand Down
2 changes: 1 addition & 1 deletion src/app/moncomdom/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function RSETable() {
<ErrorList errors={errors} resolve={resolveError} resolveAllErrors={resolveAllErrors} />
<button className="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 mr-2 mb-2 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800" onClick={async () => {
const request: HTTPRequest = {
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/stream`),
url: new URL(`${window.location.protocol}//${window.location.host}/api/stream`),
method: 'GET',
headers: {
'Content-Type': 'application/json'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const CreateRuleDIDsPage = (props: {
// build request for comdom
const request: HTTPRequest = {
url: new URL(
`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-dids`,
`${window.location.protocol}//${window.location.host}/api/feature/list-dids`,
),
method: 'GET',
headers: new Headers({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const CreateRuleRSEsPage = (props: {
var RSEExpression = explicitRSEExpression ? explicitRSEExpression : PageRSEsState.RSEExpression
// build request for comdom
const request: HTTPRequest = {
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-account-rse-quotas`),
url: new URL(`${window.location.protocol}//${window.location.host}/api/feature/list-account-rse-quotas`),
method: "POST",
headers: new Headers({
'Content-Type': 'application/json'
Expand Down
4 changes: 2 additions & 2 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export const config = {
}

async function reLogin(request: NextRequest) {
const logoutPage = new URL(`/api/auth/logout?callbackUrl=${request.url}`, request.url)
const logoutPage = new URL(`/api/auth/logout?callbackUrl=${request.nextUrl.pathname}`, request.url)
return NextResponse.redirect(logoutPage)
}

async function initiateLogin(request: NextRequest){
const loginPage = new URL(`/api/auth/login?callbackUrl=${request.url}`, request.url)
const loginPage = new URL(`/api/auth/login?callbackUrl=${request.nextUrl.pathname}`, request.url)
return NextResponse.redirect(loginPage)
}

Expand Down
Loading