Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
Signed-off-by: greg pereira <[email protected]>
  • Loading branch information
Gregory-Pereira committed Nov 24, 2024
1 parent 3737017 commit 908896e
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 31 deletions.
21 changes: 19 additions & 2 deletions deploy/k8s/base/keycloak/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,19 @@ oc get pods -n keycloak-system
# keycloak-postgresql-5965b4dd55-22hsc 1/1 Running 0 11d
# rhsso-operator-758844f657-s97k9 1/1 Running 0 32h

oc --kustomize apply resources/
# This will create the Keycloak instance, KeycloakClient, KeycloakRealm, and a dummy user
cd resources/

oc create -f keycloak.yaml
# wait for keycloak instance to be initialized and in the `reconciling` stage with status `ready`,
# this may take up to a few minutes

oc create -f realm.yaml
# wait for the keycloakRealm to be `reconciling`

oc create -f instructlab-ui-client.yaml && oc create -f user.yaml
# These two are very fast, wait for them to also be in the `reconciling` stage

# In total, this will create the Keycloak instance, KeycloakClient, KeycloakRealm, and a dummy user
```

## Application setup
Expand All @@ -32,6 +43,12 @@ To get these values you can do the following (this assumes no modification to th
export KEYCLOAK_CLIENT_ID=$(kubectl get secret keycloak-client-secret-instructlab-ui -n keycloak-system -o yaml | yq .data.CLIENT_ID | base64 -d)
export KEYCLOAK_CLIENT_SECRET=$(kubectl get secret keycloak-client-secret-instructlab-ui -n keycloak-system -o yaml | yq .data.CLIENT_SECRET | base64 -d)
export KEYCLOAK_ISSUER=$(kubectl get keycloak keycloak -n keycloak-system -o jsonpath='{.status.externalURL}')/auth/realms/instructlab-ui

echo "KEYCLOAK_CLIENT_ID=${KEYCLOAK_CLIENT_ID}" >> .env
echo "KEYCLOAK_CLIENT_SECRET=${KEYCLOAK_CLIENT_SECRET}" >> .env
echo "KEYCLOAK_ISSUER=${KEYCLOAK_ISSUER}" >> .env

cat .env | tail -n 3
```

Additionally, make sure the `IL_UI_DEPLOYMENT=dev` value is set in the `.env` file, because keycloak auth is not currently available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
labels:
app: sso
name: instructlab-ui
namespace: keycloak-system
spec:
client:
clientAuthenticatorType: client-secret
Expand Down
1 change: 1 addition & 0 deletions deploy/k8s/base/keycloak/resources/keycloak.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
labels:
app: sso
name: keycloak
namespace: keycloak-system
spec:
externalAccess:
enabled: true
Expand Down
3 changes: 0 additions & 3 deletions deploy/k8s/base/keycloak/resources/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: keycloak-system

resources:
- keycloak.yaml
- realm.yaml
Expand Down
1 change: 1 addition & 0 deletions deploy/k8s/base/keycloak/resources/realm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
labels:
app: sso
name: instructlab-ui
namespace: keycloak-system
spec:
instanceSelector:
matchLabels:
Expand Down
1 change: 1 addition & 0 deletions deploy/k8s/base/keycloak/resources/user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
labels:
app: sso
name: dummy
namespace: keycloak-system
spec:
realmSelector:
matchLabels:
Expand Down
14 changes: 7 additions & 7 deletions src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import NextAuth, { NextAuthOptions } from 'next-auth';
import GitHubProvider from 'next-auth/providers/github';
import CredentialsProvider from 'next-auth/providers/credentials';
import KeycloakProvider from "next-auth/providers/keycloak";
import KeycloakProvider from 'next-auth/providers/keycloak';
import axios from 'axios';
import winston from 'winston';
import path from 'path';

// Extend the Session and JWT types
declare module 'next-auth' {
interface Session {
provider?: string
provider?: string;
accessToken?: string;
id?: string;
}
Expand Down Expand Up @@ -45,16 +45,16 @@ const ORG = process.env.NEXT_PUBLIC_AUTHENTICATION_ORG!;
const authOptions: NextAuthOptions = {
providers: [
GitHubProvider({
name: "Github",
name: 'Github',
clientId: process.env.OAUTH_GITHUB_ID!,
clientSecret: process.env.OAUTH_GITHUB_SECRET!,
authorization: { params: { scope: 'public_repo' } }
}),
KeycloakProvider({
name: "Keycloak",
name: 'Keycloak',
clientId: process.env.KEYCLOAK_CLIENT_ID!,
clientSecret: process.env.KEYCLOAK_CLIENT_SECRET!,
issuer: process.env.KEYCLOAK_ISSUER,
issuer: process.env.KEYCLOAK_ISSUER
}),
CredentialsProvider({
name: 'Credentials',
Expand Down Expand Up @@ -83,7 +83,7 @@ const authOptions: NextAuthOptions = {
async jwt({ token, user, account }) {
if (account) {
token.accessToken = account.access_token!;
token.provider = account.provider
token.provider = account.provider!;
}
if (user) {
token.id = user.id;
Expand All @@ -96,7 +96,7 @@ const authOptions: NextAuthOptions = {
if (token) {
session.accessToken = token.accessToken;
session.id = token.id;
session.provider = token.provider
session.provider = token.provider;
}
// // Uncomment for session callback debugging
// console.log('Session Callback:', session);
Expand Down
33 changes: 15 additions & 18 deletions src/app/login/keycloakicon.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
// Pulled from: https://github.com/keycloak/keycloak-misc/blob/main/logo/icon-white.svg
const KeycloakIcon = () => (
<svg
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
viewBox="0 0 45 35"
>
<path d="m117.344 128.588-23.017.003-5.716 9.865-5.796 10.065 5.737 9.962 5.782 9.965 23.011-.008 5.69-9.956h3.976v-.004h.02l-.007-19.93h-3.995zm-19.188 6.65h3.835l-.001.002 1.917 3.315-5.75 9.973 5.743 9.954-1.909 3.332.002.003h-3.837l-5.754-9.966-1.925-3.307 1.952-3.386zm11.499.002 3.842.003 5.754 9.962v.003l1.921 3.341-7.677 13.266h-3.83v-.001c-.706-1.036-1.914-3.33-1.914-3.33l5.753-9.958-5.754-9.973z"
style={{
display: "inline",
fill: "#fff",
fillOpacity: 1,
strokeWidth: ".264583",
}}
transform="translate(-82.815 -128.588)"/>
</svg>
);

export default KeycloakIcon;
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 45 35">
<path
d="m117.344 128.588-23.017.003-5.716 9.865-5.796 10.065 5.737 9.962 5.782 9.965 23.011-.008 5.69-9.956h3.976v-.004h.02l-.007-19.93h-3.995zm-19.188 6.65h3.835l-.001.002 1.917 3.315-5.75 9.973 5.743 9.954-1.909 3.332.002.003h-3.837l-5.754-9.966-1.925-3.307 1.952-3.386zm11.499.002 3.842.003 5.754 9.962v.003l1.921 3.341-7.677 13.266h-3.83v-.001c-.706-1.036-1.914-3.33-1.914-3.33l5.753-9.958-5.754-9.973z"
style={{
display: 'inline',
fill: '#fff',
fillOpacity: 1,
strokeWidth: '.264583'
}}
transform="translate(-82.815 -128.588)"
/>
</svg>
);

export default KeycloakIcon;
2 changes: 1 addition & 1 deletion src/components/Dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Index: React.FunctionComponent = () => {
const router = useRouter();

const fetchAndSetPullRequests = React.useCallback(async () => {
if (session?.accessToken && session?.provider == "Github") {
if (session?.accessToken && session?.provider == 'Github') {
try {
const header = {
Authorization: `Bearer ${session.accessToken}`,
Expand Down

0 comments on commit 908896e

Please sign in to comment.