S
Solara4mo ago
Cyrus

Hi, I am looking for a Solara Auth

Hi, I am looking for a Solara Auth example (okta provider) that I can reproduce. I tried https://solara.dev/documentation/examples/general/login_oauth but it points to a 502 error when I click on Login. Do you know of a working example?
9 Replies
iisakkirotko
iisakkirotko4mo ago
Just to confirm, you get the login screen, but the redirect after signing in fails? Looks to me like it points to localhost:8765, which might be a problem from our end. I'll take a look later today if I can get that fixed
Cyrus
CyrusOP4mo ago
Thanks! I have another question. Looking at the Solara docs I see no "template" redirect_uri for the login endpoint? I am new to this so I could be wrong but in okta's examples with Flask I usually see that it should be provided. Would it be something like https://yourdomain.com/_solara/auth/login?
No description
Cyrus
CyrusOP4mo ago
@iisakkirotko
Cyrus
CyrusOP4mo ago
As for your question "you get the login screen, but the redirect after signing in fails?", I see the Login button and when I click on it it goes to
https://solara.dev/_solara/auth/login?redirect_uri=https%3A//solara.dev/documentation/examples/general/login_oauth
https://solara.dev/_solara/auth/login?redirect_uri=https%3A//solara.dev/documentation/examples/general/login_oauth
and shows
No description
iisakkirotko
iisakkirotko4mo ago
Have you tried again since? I think the servers our website is hosted on were down in some regions. The login endpoint for solara is .../_solara/auth/login, but you can also add another one by just creating a route that calls the login function of solara enterprise. In case you mean the uri that users land on after logging in by redirect_uri: by default, solara redirects the user back to the page they were on when clicking login, but you can configure the page by providing a uri (absolute or relative) as an argument to get_login_url. This is not documented, but you can take a look at the implementation on github: https://github.com/widgetti/solara/blob/b0e5c223016e6acfc114ea730c38443b77490269/packages/solara-enterprise/solara_enterprise/auth/utils.py#L27-L35 (Note that the login function also takes an argument similarly)
Monty Python
Monty Python4mo ago
packages/solara-enterprise/solara_enterprise/auth/utils.py lines 27 to 35
def get_login_url(return_to_path: Optional[str] = None):
if return_to_path is None:
router = router_context.get()
return_to_path = router.path
if return_to_path.startswith("/"):
return_to_path = return_to_path[1:]
assert settings.main.base_url is not None
redirect_uri = urllib.parse.quote(settings.main.base_url + return_to_path)
return f"/_solara/auth/login?redirect_uri={redirect_uri}"
def get_login_url(return_to_path: Optional[str] = None):
if return_to_path is None:
router = router_context.get()
return_to_path = router.path
if return_to_path.startswith("/"):
return_to_path = return_to_path[1:]
assert settings.main.base_url is not None
redirect_uri = urllib.parse.quote(settings.main.base_url + return_to_path)
return f"/_solara/auth/login?redirect_uri={redirect_uri}"
iisakkirotko
iisakkirotko4mo ago
For adding a custom endpoint for signing in, you can take a look at how we implement it, for example for flask
Monty Python
Monty Python4mo ago
solara/server/flask.py lines 267 to 270
if has_solara_enterprise:
blueprint.route("/_solara/auth/authorize")(authorize)
blueprint.route("/_solara/auth/logout")(logout)
blueprint.route("/_solara/auth/login")(login)
if has_solara_enterprise:
blueprint.route("/_solara/auth/authorize")(authorize)
blueprint.route("/_solara/auth/logout")(logout)
blueprint.route("/_solara/auth/login")(login)
Cyrus
CyrusOP4mo ago
thanks @iisakkirotko! @iisakkirotko for some reason I can't get an example to work. I have described my issue here
Want results from more Discord servers?
Add your server