SSO is forcibly creating the user as an admin

Hello

I am integrating discourse SSO, however I am facing a problem where the user being created is getting admin privileges even though that the SSO payload explicitly states that he shouldn’t be.

I am on the latest beta: 2.8.0.beta6 [ f3273bd43e ]
Here is a an example:

SSO URL:

https://community.bloom.pm/session/sso_login?sso=ZXh0ZXJuYWxfaWQ9NjEzZjJmMzMzNWZkODc4NWU4Mjk4Y2JhJm5vbmNlPThiNzdjM2JlMDBmMThkMjYwMDhkYjkxOWQxODA4MzAyJmVtYWlsPW9tYXIlMkJtZW1iZXI0JTQwYmxvb20ucG0mdXNlcm5hbWU9bWVtYmVyNCZuYW1lPW1lbWJlcjQmYWRtaW49ZmFsc2UmbW9kZXJhdG9yPWZhbHNlJnN1cHByZXNzX3dlbGNvbWVfbWVzc2FnZT10cnVl&sig=fcb3e5d3d4b8c39078753cb495f4c3781dcca1f022851a2bdff2015e7fa489b1

Decoding the sso payload gives:

external_id=613f2f3335fd8785e8298cba&nonce=8b77c3be00f18d26008db919d1808302&email=omar%2Bmember4%40bloom.pm&username=member4&name=member4&admin=false&moderator=false&suppress_welcome_message=true

However member4 was created with admin privileges

is member4’s email address in the config file under developer ?

DISCOURSE_DEVELOPER_EMAILS

any email address listed there, will automatically become admin

1 Like

I justed with omar+member9@306.dev which is a totally different domain and not on DISCOURSE_DEVELOPER_EMAILS but the issue is still there, the user got admin access

The api key I am using to sign the SSO belongs to admin, does that affect anything ?

That does not sound right? Can you explain what you are doing?

1 Like

I just integrated SSO on an existing discourse site and I am getting this behavior.
The site is running using docker (discourse_docker repo)

I logged in to the container and access the postgres db, the user has admin flag as false in the db so it is not being updated by the “make_developer_admin” method

What else could be there ?

I am also using those plugins

   - git clone https:// github.com/discourse/docker_manager.git
          - git clone https:// github.com/angusmcleod/discourse-events.git
          - git clone https:// github.com/gdpelican/babble.git
          - git clone https:// github.com/davidtaylorhq/discourse-whos-online.git
          - git clone https:// github.com/discourse/discourse-checklist.git
          - git clone https:// github.com/discourse/discourse-data-explorer.git
          - git clone https:// github.com/BeXcellent/discourse-allowiframe.git

you might want to enable debugging to troubleshoot

Debugging your DiscourseConnect provider

To assist in debugging DiscourseConnect you may enable the site setting verbose_discourse_connect_logging . By enabling that site setting rich diagnostics will show up in YOURSITE.com/logs . Be sure to :white_check_mark: the warnings box at the bottom of YOURSITE.com/logs .

reference: DiscourseConnect - Official Single-Sign-On for Discourse (sso)

The user is not admin, however there is a deeper issue, i added some logs

it looks like some kind of filtering bug using ActiveRecord api, i logged the queries and I don’t see userid in the where filter so it looks it is pulling the notifications data globally
Same thing i guess is happening with forums / topics, it is somehow ignoring the userid filter and getting everything

How can i fix this ?

Posting 2nd media item (since i am new )

Posting 3rd media item - logs

It looks like user.notifications is not adding the filter , i have manually added a where condition in the code and it got fixed in the modal notifications display, but in the details page, it uses a different code path so it is still displaying everything. What’s the real solution ? :expressionless:

rails version: 6.1.4.1

bundle exec gem list --local

*** LOCAL GEMS ***

actionmailer (6.1.4.1)
actionpack (6.1.4.1)
actionview (6.1.4.1)
actionview_precompiler (0.2.3)
active_model_serializers (0.8.4)
activejob (6.1.4.1)
activemodel (6.1.4.1)
activerecord (6.1.4.1)
activesupport (6.1.4.1)
addressable (2.8.0)
aws-eventstream (1.2.0)
aws-partitions (1.432.0)
aws-sdk-core (3.112.1)
aws-sdk-kms (1.44.0)
aws-sdk-s3 (1.96.1)
aws-sdk-sns (1.38.0)
aws-sigv4 (1.2.3)
barber (0.12.2)
bootsnap (1.8.1)
builder (3.2.4)
bundler (2.2.26)
byebug (11.1.3)
cbor (0.5.9.6)
chunky_png (1.4.0)
coderay (1.1.3)
colored2 (3.1.2)
concurrent-ruby (1.1.9)
connection_pool (2.2.5)
cose (1.2.0)
cppjieba_rb (0.3.3)
crass (1.0.6)
css_parser (1.10.0)
diffy (3.4.0)
discourse-ember-rails (0.18.6)
discourse-ember-source (3.12.2.3)
discourse-fonts (0.0.9)
ecma-re-validator (0.3.0)
email_reply_trimmer (0.1.13)
ember-data-source (3.0.2)
ember-handlebars-template (0.8.0)
ember-source (2.18.2)
erubi (1.10.0)
excon (0.85.0)
execjs (2.8.1)
exifr (1.3.9)
faraday (1.7.2)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
fast_blank (1.0.1)
fast_xs (0.8.0)
fastimage (2.2.5)
ffi (1.15.4)
fspath (3.1.2)
gc_tracer (1.5.1)
globalid (0.5.2)
guess_html_encoding (0.0.11)
hana (1.3.7)
hashie (4.1.0)
highline (2.0.3)
hkdf (0.3.0)
htmlentities (4.3.4)
http_accept_language (2.1.1)
i18n (1.8.10)
image_optim (0.30.0)
image_size (2.1.2)
in_threads (1.5.4)
jmespath (1.4.0)
jquery-rails (4.4.0)
json (2.5.1)
json_schemer (0.2.18)
jwt (2.2.3)
kgio (2.11.4)
libv8-node (15.14.0.1 x86_64-linux)
lograge (0.11.2)
logstash-event (1.2.02)
logstash-logger (0.26.1)
logster (2.9.7)
loofah (2.12.0)
lru_redux (1.1.0)
lz4-ruby (0.3.3)
mail (2.8.0.edge)
maxminddb (0.1.22)
memory_profiler (1.0.0)
message_bus (3.3.6)
method_source (1.0.0)
mini_mime (1.1.1)
mini_racer (0.4.0)
mini_scheduler (0.13.0)
mini_sql (1.1.3)
mini_suffix (0.3.2)
minitest (5.14.4)
msgpack (1.4.2)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
mustache (1.1.1)
nio4r (2.5.8)
nokogiri (1.12.4 x86_64-linux)
oauth (0.5.6)
oauth2 (1.4.7)
oj (3.13.2)
omniauth (1.9.1)
omniauth-facebook (8.0.0)
omniauth-github (1.4.0)
omniauth-google-oauth2 (0.8.2)
omniauth-oauth (1.2.0)
omniauth-oauth2 (1.7.1)
omniauth-twitter (1.4.0)
openssl (2.2.0)
openssl-signature_algorithm (1.1.1)
optimist (3.0.1)
pg (1.2.3)
progress (3.6.0)
pry (0.13.1)
pry-byebug (3.9.0)
pry-rails (0.3.9)
public_suffix (4.0.6)
puma (5.4.0)
r2 (0.2.7)
racc (1.5.2)
rack (2.2.3)
rack-mini-profiler (2.3.3)
rack-protection (2.1.0)
rack-test (1.1.0)
rails-dom-testing (2.0.3)
rails-html-sanitizer (1.4.2)
rails_failover (0.7.3)
rails_multisite (3.1.0)
railties (6.1.4.1)
raindrops (0.19.2)
rake (13.0.6)
rbtrace (0.4.14)
rchardet (1.8.0)
redis (4.4.0)
redis-namespace (1.8.1)
regexp_parser (2.1.1)
request_store (1.5.0)
rinku (2.0.6)
rotp (6.2.0)
rqrcode (2.1.0)
rqrcode_core (1.2.0)
rtlit (0.0.5)
ruby-readability (0.7.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sanitize (6.0.0)
sassc (2.0.1)
sassc-rails (2.1.2)
seed-fu (2.3.9)
sidekiq (6.2.2)
sprockets (3.7.2)
sprockets-rails (3.2.2)
sshkey (2.0.0)
stackprof (0.2.17)
thor (1.1.0)
tilt (2.0.10)
tzinfo (2.0.4)
uglifier (4.2.0)
unf (0.1.4)
unf_ext (0.0.7.7)
unicorn (6.0.0)
uri_template (0.7.0)
webpush (1.1.0)
xorcist (1.1.2)
zeitwerk (2.4.2)

I started a new docker container from scratch and moved the assets/data, that fixed the issue
Rebuilding the existing container did not help

#closed

1 Like