DAVIDhaker/django-sso

redirect always got fallback=true

Opened this issue · 21 comments

I use 127.0.0.1:8000 as gateway and localhost:9000 as client.
I try to login gateway and redirect http://127.0.0.1:8000/__welcome/ success.
then i go to the address http://localhost:9000/sso/test/
it always redirect http://127.0.0.1:8000/__welcome/?fallback=true

the exception is in Service f'{self.base_url}/sso/event/',
my base_url is 127.0.0.1:8000 but not client http://localhost:9000/
there's no url /sso/event/
is my setting wrong?

Hi. You forget to attach gateway/client urls into your project(s). Please read Readme again. You need to add Django SSO urls to youproject/urls.py like it described in docs.

yes. i'v already add urls to my projects like the described in docs. it's not work.

Do you see anything in CLI? Library should report about errors.

Please provide screenshot from CLI.

gateway:
image
http://127.0.0.1:8000/login/ login admin OK.
image

client:
image

goto http://localhost:9000/sso/test/
it always redirect http://127.0.0.1:8000/__welcome/?fallback=true
image

sso/event error.
image

this is my client setting, and i am not defined the overrides.
image

No. Overrides are optional. On the client side you must provide SSO server link, token and inject urls to service-side project from django_sso.sso_service.urls.

image
SSO lib can't emit event to subordinated service because event aceptor url is not available - 404. Please show me your urls on service side.

this is geteway urls.py:
image
this is client url.py:
image

  • What is version of Django SSO are you use?
  • What is version of Django are you used?
  • Could you provide pure setup of Django's + the library (with same steps, what you do in your problematic project)?

For current i do not understand, how to occurs it.

@yih0620 you could check against https://github.com/kakulukia/test_client to see whats different in you soo client, but the 404 response clearly said the url on the client side is not reachable, maybe the urlpatterns you showed above is being overwritten afterwards?

You could test manually opening http://localhost:9000/sso/event/ in the browser - it should tell you:
Method Not Allowed: /sso/event/
[05/Feb/2023 12:37:03] "GET /sso/event/ HTTP/1.1" 405 0
since its just accepting POST requests

python version:3.7.4
django version: 3.2.17

I create new project today.
https://github.com/yih0620/ssoServerTest
https://github.com/yih0620/ssoClientTest

image

and thank you for your kind assistance!!

@DAVIDhaker shouldn't obtain and even be called on different hosts? It looks like even is called on the sso server instead of the client. Which log are we seeing @yih0620 ?

@kakulukia log from ssoservertest.
i development on a single machine, and i set the hosts file as
image

i change SSO_ROOT = 'http://localhost:9000'
and reverse server and client ip
server at http://localhost:9000/
client at 127.0.0.1:8000
it work!
i think my Subordinated services ip set wrong before.

@yih0620, hi! Excuse for long wait for reply. I think you solved problem on one's own. Little bit later i will try to test you project that you did published before.

@DAVIDhaker shouldn't obtain and even be called on different hosts? It looks like even is called on the sso server instead of the client. Which log are we seeing @yih0620 ?

There is no difference in direct communication between services. Only in browser required different hostnames. If i understand you question right.

@yih0620 v2.0.0 is ready. You should update. And checkout new feature. :)

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\thread
ing.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\thread
ing.py", line 870, in run
self._target(*self._args, **self.kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-p
ackages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-p
ackages\django\core\management\commands\runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-p
ackages\django\utils\autoreload.py", line 87, in raise_last_exception
raise exception[1]
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-p
ackages\django\core\management_init
.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-p
ackages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-p
ackages\django_init
.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-p
ackages\django\apps\registry.py", line 122, in populate
app_config.ready()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-p
ackages\django_sso\sso_gateway\apps.py", line 26, in ready
affected_models = self.sso_settings.affected_models_fields.keys()
AttributeError: 'Settings' object has no attribute 'affected_models_fields'

update to 2.0 i have this error@@
and downgrade back to 1.1.4, it work well..

#8 << have a look at this to solve it

sorry for put my problem here but i have this error

SSO token validation error
No connection adapters were found for '127.0.0.1:8000/sso/obtain/'
This error caused because SSO server don't know token of this service.

To solve this problem create subordinated service in SSO-server and put obtained token to SSO_TOKEN into settings.py file

in my settings file (sso_service_test)a put the token from my gateway_server like this
settings (sso_service_test1)
LOGIN_URL = '/login/'

SSO_ROOT = '127.0.0.1:8000'

SSO_TOKEN = 'kPeKnDUJg2uK4KGbCVzH4Cc342WHipLGWDp6wxooB1zFce37gpEdJWWtxxtUEshlTAruDfVHnNMnVf7rKjRBwBIgZRwOaV5S5v3D6cKObmlVrpCYBEqufu7cgYVH7e2AR'

in my server gateway add subordinate
Screen Shot 2023-02-19 at 5 41 35 PM

but no working this is versions on my gateway and service exactly (both)
asgiref==3.6.0
certifi==2022.12.7
charset-normalizer==3.0.1
Django==4.1.7
django-sso==2.0.0
idna==3.4
requests==2.28.2
sqlparse==0.4.3
urllib3==1.26.14

any idea?

Hello @CARocha. For first. Try to install v3 (released minutes ago). If problem not solved - contact me via email for speed up problem solving.