Skip to content

Commit

Permalink
Add client_id file
Browse files Browse the repository at this point in the history
  • Loading branch information
Vidminas committed Feb 1, 2024
1 parent d55b4c2 commit 9b57125
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ pip install --no-build-isolation --no-deps .

Open chat interface by running `genpod-chat`.

Run the LLM service provider using `genpod-llm`.
Run the LLM service provider using `genpod-llm`.


## Acknowledgments

`chat_app/data/turtle.png` is from <https://emojipedia.org/mozilla/firefox-os-2.5/turtle>.
16 changes: 16 additions & 0 deletions chat_app/data/client_id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"@context": ["https://www.w3.org/ns/solid/oidc-context.jsonld"],

"client_id": "https://raw.githubusercontent.com/Vidminas/socialgenpod/main/chat_app/data/client_id.json",
"client_name": "Social Gen Pod",
"redirect_uris": ["https://raw.githubusercontent.com/Vidminas/socialgenpod/main/chat_app/data/client_id.json", "https://socialgenpod.azurewebsites.net", "http://localhost:8501"],
"post_logout_redirect_uris": ["https://socialgenpod.azurewebsites.net", "http://localhost:8501"],
"client_uri": "https://github.com/Vidminas/socialgenpod",
"logo_uri" : "https://raw.githubusercontent.com/Vidminas/socialgenpod/main/chat_app/data/turtle.png",
"tos_uri" : "https://github.com/Vidminas/socialgenpod/blob/main/README.md",
"scope" : "openid profile offline_access webid",
"grant_types" : ["refresh_token","authorization_code"],
"response_types" : ["code"],
"default_max_age" : 3600,
"require_auth_time" : true
}
Binary file added chat_app/data/turtle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 3 additions & 14 deletions chat_app/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import urllib.parse
import requests

import streamlit as st
Expand All @@ -7,6 +6,9 @@
from chat_app.solid_message_history import SolidChatMessageHistory


OAUTH_CALLBACK_URI = "https://raw.githubusercontent.com/Vidminas/socialgenpod/main/chat_app/data/client_id.json"


def setup_login_sidebar():
from chat_app.solid_oidc_button import SolidOidcComponent
from solid_oidc_client import SolidAuthSession
Expand Down Expand Up @@ -37,19 +39,6 @@ def setup_login_sidebar():

if "solid_idps" not in st.session_state:
st.session_state["solid_idps"] = {}
session = st.runtime.get_instance()._session_mgr.list_active_sessions()[0]
st.session_state["OAUTH_CALLBACK_URI"] = urllib.parse.urlunparse(
[
session.client.request.protocol,
session.client.request.host,
"",
"",
"",
"",
]
)

OAUTH_CALLBACK_URI = st.session_state["OAUTH_CALLBACK_URI"]

if solid_server_url not in st.session_state["solid_idps"]:
st.session_state["solid_idps"][solid_server_url] = SolidOidcComponent(
Expand Down
2 changes: 2 additions & 0 deletions chat_app/solid_oidc_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def generate_pkce_pair(client_id):
class SolidOidcComponent(OAuth2Component):
def __init__(self, solid_server_url: str, valid_redirect_uris: list[str]):
client = SolidOidcClient(storage=MemStore())
client.client_id = "https://raw.githubusercontent.com/Vidminas/socialgenpod/main/chat_app/data/client_id.json"
client.client.client_id = "https://raw.githubusercontent.com/Vidminas/socialgenpod/main/chat_app/data/client_id.json"
client.register_client(solid_server_url, valid_redirect_uris)
super().__init__(
client_id=None,
Expand Down

0 comments on commit 9b57125

Please sign in to comment.