Skip to content

Commit dba7231

Browse files
Merge pull request #156 from oracle/authChanges
Removed use of Basic authentication for the sample app.
2 parents 597e88e + 276f5c9 commit dba7231

21 files changed

+1574
-75
lines changed

templates/ords-remix-jwt-sample/Database/Modules/concert_app.euser.v2.sql

Lines changed: 399 additions & 0 deletions
Large diffs are not rendered by default.
File renamed without changes.

templates/ords-remix-jwt-sample/app/root.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
} from './utils/auth.server';
3131
import NavBar from './components/navbar/NavBar';
3232
import {
33-
BASIC_SCHEMA_AUTH,
3433
CITIES_ENDPOINT,
3534
} from './routes/constants/index.server';
3635
import TooltipButton from './components/tooltips/TooltipButton';
@@ -42,12 +41,12 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
4241
const userProfile = await auth.isAuthenticated(request);
4342
const profile = userProfile?.profile || null;
4443
const USER_CREDENTIALS = userProfile === null
45-
? BASIC_SCHEMA_AUTH
44+
? null
4645
: `${userProfile.tokenType} ${userProfile.accessToken}`;
4746
const session = await getSession(request.headers.get('Cookie'));
4847
const error = session.get(auth.sessionErrorKey) as LoaderError;
4948

50-
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS);
49+
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS!);
5150
if (cities.items.length === 0) {
5251
const errorMessage = 'The cities endpoint has no elements. Review your database configuration and try again.';
5352
throw new Response(errorMessage, {

templates/ords-remix-jwt-sample/app/routes/artists.$id.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
ARTISTS_ENDPOINT,
2323
ARTIST_ENDPOINT,
2424
ARTIST_EVENT_ENDPOINT,
25-
BASIC_SCHEMA_AUTH,
2625
CITIES_ENDPOINT,
2726
LIKED_ARTIST_ENDPOINT,
2827
} from './constants/index.server';
@@ -87,26 +86,26 @@ export const loader = async ({
8786
const userProfile = await auth.isAuthenticated(request);
8887
const profile = userProfile?.profile || null;
8988
const USER_CREDENTIALS = userProfile === null
90-
? BASIC_SCHEMA_AUTH
89+
? null
9190
: `${userProfile.tokenType} ${userProfile.accessToken}`;
9291
const session = await getSession(request.headers.get('Cookie'));
9392
const error = session.get(auth.sessionErrorKey) as LoaderError;
9493
const { id: artistID } = params;
9594
let likedArtist = false;
96-
const artist = await ORDSFetcher(`${ARTIST_ENDPOINT}/${artistID}`, USER_CREDENTIALS) as ORDSResponse<Artist>;
95+
const artist = await ORDSFetcher(`${ARTIST_ENDPOINT}/${artistID}`, USER_CREDENTIALS!) as ORDSResponse<Artist>;
9796
if (artist.items.length === 0) {
9897
const errorMessage = 'The Artist you were looking for does not exist, might have been removed or had its id changed.';
9998
throw new Response(errorMessage, {
10099
status: 404,
101100
statusText: 'Not Found',
102101
} as ErrorResponse);
103102
}
104-
const artistEvents = await ORDSFetcher(`${ARTIST_EVENT_ENDPOINT}/${artistID}`, USER_CREDENTIALS);
105-
const similarArtists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS);
106-
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS);
103+
const artistEvents = await ORDSFetcher(`${ARTIST_EVENT_ENDPOINT}/${artistID}`, USER_CREDENTIALS!);
104+
const similarArtists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS!);
105+
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS!);
107106
if (profile) {
108107
const userID = profile.id;
109-
const userLikedArtist = await ORDSFetcher(`${LIKED_ARTIST_ENDPOINT}/${userID}/${artistID}`, USER_CREDENTIALS);
108+
const userLikedArtist = await ORDSFetcher(`${LIKED_ARTIST_ENDPOINT}/${userID}/${artistID}`, USER_CREDENTIALS!);
110109
likedArtist = userLikedArtist.likedartist === 1;
111110
}
112111
return json({

templates/ords-remix-jwt-sample/app/routes/concerts.$concertID.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import ConcertDetails from '../components/concerts/ConcertDetails';
2929
import {
3030
EVENT_ENDPOINT,
3131
LIKED_EVENT_ENDPOINT,
32-
BASIC_SCHEMA_AUTH,
3332
} from './constants/index.server';
3433
import { UserActions } from '../utils/UserActions';
3534
import ORDSFetcher from '../utils/ORDSFetcher';
@@ -93,12 +92,12 @@ export const loader = async ({
9392
const userProfile = await auth.isAuthenticated(request);
9493
const profile = userProfile?.profile || null;
9594
const USER_CREDENTIALS = userProfile === null
96-
? BASIC_SCHEMA_AUTH
95+
? null
9796
: `${userProfile.tokenType} ${userProfile.accessToken}`;
9897
const session = await getSession(request.headers.get('Cookie'));
9998
const error = session.get(auth.sessionErrorKey) as LoaderError;
10099
const { concertID } = params;
101-
const concert = await ORDSFetcher(`${EVENT_ENDPOINT}/${concertID}`, USER_CREDENTIALS) as ORDSResponse<Concert>;
100+
const concert = await ORDSFetcher(`${EVENT_ENDPOINT}/${concertID}`, USER_CREDENTIALS!) as ORDSResponse<Concert>;
102101
if (concert.items.length === 0) {
103102
const errorMessage = 'The Concert you were looking for does not exist, might have been removed or had its id changed.';
104103
throw new Response(errorMessage, {
@@ -109,7 +108,7 @@ export const loader = async ({
109108
let likedConcert = false;
110109
if (profile !== null) {
111110
const userID = profile.id;
112-
const userLikedConcert = await ORDSFetcher(`${LIKED_EVENT_ENDPOINT}/${userID}/${concertID}`, USER_CREDENTIALS);
111+
const userLikedConcert = await ORDSFetcher(`${LIKED_EVENT_ENDPOINT}/${userID}/${concertID}`, USER_CREDENTIALS!);
113112
likedConcert = userLikedConcert.likedevent === 1;
114113
}
115114

templates/ords-remix-jwt-sample/app/routes/home.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
} from '../utils/auth.server';
2424
import {
2525
STATS_ENDPOINT,
26-
BASIC_SCHEMA_AUTH,
2726
EVENTS_ENDPOINT,
2827
ARTISTS_ENDPOINT,
2928
CONCERTS_BY_CITY_ENDPOINT,
@@ -43,17 +42,17 @@ import featureDescriptions from '../utils/ORDSFeaturesDescription';
4342
export const loader = async ({ request }: LoaderFunctionArgs) => {
4443
const userProfile = await auth.isAuthenticated(request);
4544
const USER_CREDENTIALS = userProfile === null
46-
? BASIC_SCHEMA_AUTH
45+
? null
4746
: `${userProfile.tokenType} ${userProfile.accessToken}`;
4847
const session = await getSession(request.headers.get('Cookie'));
4948
const error = session.get(auth.sessionErrorKey) as LoaderError;
5049
const { searchParams } = new URL(request.url);
5150
const hasCityName = searchParams.has('cityName');
5251
const cityName = searchParams.get('cityName');
5352
const eventsQuery = hasCityName ? `${CONCERTS_BY_CITY_ENDPOINT}/${cityName}` : EVENTS_ENDPOINT;
54-
const stats = await ORDSFetcher(STATS_ENDPOINT, USER_CREDENTIALS);
55-
const events = await ORDSFetcher(eventsQuery, USER_CREDENTIALS);
56-
const artists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS);
53+
const stats = await ORDSFetcher(STATS_ENDPOINT, USER_CREDENTIALS!);
54+
const events = await ORDSFetcher(eventsQuery, USER_CREDENTIALS!);
55+
const artists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS!);
5756
return json({
5857
error,
5958
stats,

templates/ords-remix-jwt-sample/app/routes/resources.artists.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
} from '~/utils/auth.server';
1616
import {
1717
ARTISTS_ENDPOINT,
18-
BASIC_SCHEMA_AUTH,
1918
} from './constants/index.server';
2019
import ORDSFetcher from '../utils/ORDSFetcher';
2120

@@ -29,11 +28,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
2928
artistsURL.searchParams.append('limit', limit.toString());
3029
const userProfile = await auth.isAuthenticated(request);
3130
const USER_CREDENTIALS = userProfile === null
32-
? BASIC_SCHEMA_AUTH
31+
? null
3332
: `${userProfile.tokenType} ${userProfile.accessToken}`;
3433
const session = await getSession(request.headers.get('Cookie'));
3534
const error = session.get(auth.sessionErrorKey) as LoaderError;
36-
const artists = await ORDSFetcher(artistsURL, USER_CREDENTIALS);
35+
const artists = await ORDSFetcher(artistsURL, USER_CREDENTIALS!);
3736
return json({
3837
error,
3938
artists,

templates/ords-remix-jwt-sample/app/routes/resources.cities.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
} from '~/utils/auth.server';
1616
import {
1717
CITIES_ENDPOINT,
18-
BASIC_SCHEMA_AUTH,
1918
} from './constants/index.server';
2019
import ORDSFetcher from '../utils/ORDSFetcher';
2120

@@ -29,11 +28,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
2928
citiesURL.searchParams.append('limit', limit.toString());
3029
const userProfile = await auth.isAuthenticated(request);
3130
const USER_CREDENTIALS = userProfile === null
32-
? BASIC_SCHEMA_AUTH
31+
? null
3332
: `${userProfile.tokenType} ${userProfile.accessToken}`;
3433
const session = await getSession(request.headers.get('Cookie'));
3534
const error = session.get(auth.sessionErrorKey) as LoaderError;
36-
const cities = await ORDSFetcher(citiesURL, USER_CREDENTIALS);
35+
const cities = await ORDSFetcher(citiesURL, USER_CREDENTIALS!);
3736
return json({
3837
error,
3938
cities,

templates/ords-remix-jwt-sample/app/routes/resources.concerts.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
} from '~/utils/auth.server';
1616
import {
1717
EVENTS_ENDPOINT,
18-
BASIC_SCHEMA_AUTH,
1918
CONCERTS_BY_CITY_ENDPOINT,
2019
} from './constants/index.server';
2120
import ORDSFetcher from '../utils/ORDSFetcher';
@@ -33,11 +32,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
3332
eventsURL.searchParams.append('limit', limit.toString());
3433
const userProfile = await auth.isAuthenticated(request);
3534
const USER_CREDENTIALS = userProfile === null
36-
? BASIC_SCHEMA_AUTH
35+
? null
3736
: `${userProfile.tokenType} ${userProfile.accessToken}`;
3837
const session = await getSession(request.headers.get('Cookie'));
3938
const error = session.get(auth.sessionErrorKey) as LoaderError;
40-
const events = await ORDSFetcher(eventsURL, USER_CREDENTIALS);
39+
const events = await ORDSFetcher(eventsURL, USER_CREDENTIALS!);
4140
return json({
4241
error,
4342
events,

templates/ords-remix-jwt-sample/app/routes/resources.musicGenres.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
getSession,
1515
} from '~/utils/auth.server';
1616
import {
17-
BASIC_SCHEMA_AUTH,
1817
MUSIC_GENRES_ENDPOINT,
1918
} from './constants/index.server';
2019
import ORDSFetcher from '../utils/ORDSFetcher';
@@ -31,13 +30,13 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
3130
musicGenresURL.searchParams.append('limit', limit.toString());
3231
const userProfile = await auth.isAuthenticated(request);
3332
const USER_CREDENTIALS = userProfile === null
34-
? BASIC_SCHEMA_AUTH
33+
? null
3534
: `${userProfile.tokenType} ${userProfile.accessToken}`;
3635
const session = await getSession(request.headers.get('Cookie'));
3736
const error = session.get(auth.sessionErrorKey) as LoaderError;
3837
const musicGenres = await ORDSFetcher(
3938
musicGenresURL,
40-
USER_CREDENTIALS,
39+
USER_CREDENTIALS!,
4140
) as ORDSResponse<MusicGenre>;
4241
return json({
4342
error,

0 commit comments

Comments
 (0)