Commit Graph

67 Commits

Author SHA1 Message Date
Loïc Guitaut 5cd7a79baf DEV: Fix new Rubocop offenses 2024-03-06 14:01:26 +01:00
Natalie Tay 895db120e3
FEATURE: Allow specifiying required paths when retrieving userinfo (#96)
When retrieving userinfo with oauth2_fetch_user_details=true, we sometimes want to disallow account creation if an attribute is not fulfilled.

This commit adds a new register oauth2_basic_required_json_path which will kick in when retrieving userinfo.
2024-01-31 20:19:18 +08:00
Leonardo Mosquera d1161b99a7
FIX: do not attempt to fetch user JSON if URL is not set (#94)
It is a configuration error to set oauth2_fetch_user_details to true but leave oauth2_user_json_url empty.

Before, this resulted in an unhandled exception in core. Now it is checked here.
2024-01-24 18:50:52 -03:00
Jarek Radosz 05cefd5ecd
DEV: Update linting (#93) 2024-01-16 18:00:23 +01:00
Alan Guo Xiang Tan 576ccb6304
DEV: Improve logging and fix some formatting errors (#92) 2024-01-09 11:22:17 +08:00
Leonardo Mosquera 92e3b2e4b2
DEV: Better verbose logging (#85) 2024-01-09 10:55:09 +08:00
Martin Brennan f7608a6d5b
Update plugin.rb metadata (#89)
Co-authored-by: AlexDev <104522507+alexdevlaeminck@users.noreply.github.com>
2023-11-08 11:19:20 -08:00
David Taylor ccf9d5d32c
DEV: Introduce syntax_tree for ruby formatting (#75) 2022-12-29 13:33:21 +01:00
David Taylor 16ddafad9a
SECURITY: Improve SSRF protections (#72)
See https://github.com/discourse/discourse/security/advisories/GHSA-rcc5-28r3-23rr
2022-11-01 17:38:00 +00:00
Jarek Radosz 38f527fafa
DEV: General cleanup (#65) 2022-04-06 12:19:44 +02:00
Loïc Guitaut 3bbee8933a DEV: Remove unnecessary require
As we’re upgrading Discourse to Rails 7+, we’re also renaming and moving
some files to better follow Rails conventions on that matter.

The current `require_dependency` call prevents us to do that and is not
necessary as the file referenced here is part of the autoload path.
2022-03-02 14:25:14 +01:00
Roman Rizzi d1a912ebc8
FEATURE: Fetch custom attributes from the user details. (#47)
Other plugins can tell the authenticator to traverse the user details JSON using custom paths and store the values in the user associated account extra field.
2021-07-01 18:23:27 -03:00
David Taylor f45cd3edf9
FEATURE: Handle invalid email_verified data from identity provider (#40)
Some identity providers send email_verfied as a 'true'/'false' string, not a boolean. (e.g. this bug in Auth0: https://community.auth0.com/t/27553)

This commit adds automatic handling for this case, so that the string is automatically converted into a real boolean.
2021-04-21 11:16:25 +01:00
babayotakun cef99620a1
Allow to disable CSRF check during the oauth login. (#38)
* Ignore CSRF check.

* Ignore CSRF check as a plugin setting.

Co-authored-by: Kalach, Dmitry <d.kalach@itransition.com>
2021-04-19 12:39:45 -04:00
David Taylor 59c3d9aa5e
DEV: Clean up plugin.rb (#36)
- Remove Faraday version check - all versions of Discourse now have Faraday 1.0
- Remove custom button CSS. Core now takes care of styling login buttons
- Remove deprecated `message` parameter from auth_provider registration
2021-03-30 11:29:22 +01:00
David Taylor a9ad67c4c6
FEATURE: Allow using a different authorize_url for signup (#34)
If specified, the oauth2_authorize_signup_url will be used when the user starts the auth flow via the 'sign up' buttons in the UI. If not specified, the regular authorize_url continues to be used.
2021-03-10 12:29:58 +00:00
David Taylor 96a0bde0aa
FEATURE: Allow JSON paths with literal dots in the keys (#33)
This is achieved by surrounding a key with double quotes, or by escaping
the dot character with a backslash.

For example, given the JSON

```
{ "www.example.com/uid": "myuid" }
```

Previously, there was no way to access this value. The dots would make
the parser try to access `json["www"]["example"]["com/uid"]`.

Now, this value can be accessed by using a `oauth2_json_user_id_path` like:

```
www\.example\.com/uid
```
or alternatively:
```
"www.example.com/uid"
```
2021-03-10 11:48:58 +00:00
David Taylor 5984e52dc6
DEV: Fix rubocop offences 2020-04-30 18:49:15 +01:00
David Taylor be136eacb4
FEATURE: Allow disabling request_body authentication for token endpoint
By default we include both authentication data in both the Authorization header, and in the request body. This provides maximum compatibility, although is technically a breach of the OAuth2 specification. This commit introduces a new site setting `oauth2_send_auth_body`, which allows the behavior to be controlled.
2020-04-30 17:28:22 +01:00
David Taylor d8a8724f2b
FEATURE: Add detailed OAuth2 request and response logs
This makes use of Faraday middleware to log precise details about all requests made by the OAuth2 gem. This should make it easier to debug configuration issues
2020-04-30 17:15:35 +01:00
Josh Kerxhalli-Kleinfield ca5f555750
FEATURE: Allow using array indexes in json paths (#22) 2020-04-21 14:46:42 +01:00
David Taylor 1b9937b27d
DEV: Remove deprecated use of full_screen_login_setting 2020-04-20 14:20:02 +01:00
David Taylor 47a8211d9a
DEV: Correct OAuth2BasicAuthenticator namespace, remove spec workarounds 2020-04-14 21:32:35 +01:00
Penar Musaraj b00dce0684 Rubocop redundant return fix 2019-11-14 15:08:57 -05:00
Angus McLeod 5ae9f35e81 FEATURE: Migrate to ManagedAuthenticator (#21)
This brings the plugin in-line with recent core improvements. Advantages include

- Account-linking logic and storage is shared between all authentication providers
- Optionally, users can be allowed to disconnect/reconnect their accounts
- The 'last used' date of an association is recorded
- Association metadata is recorded in the database for use in data explorer and other plugins

Data migration will be performed automatically, and all existing functionality is maintained.
2019-07-27 16:34:17 +01:00
Angus McLeod eb31cdf44f Handle fetch user details failure (#20)
* handle failure in get_user_details request

* add spec

* improve spec

* return nil on failure
2019-07-11 10:31:51 -04:00
Angus McLeod a634ff896d Use token callback user details (#18)
* Add way to use user details returned in token response

* Add spec

* Apply suggestions from code review

Co-Authored-By: Robin Ward <robin.ward@gmail.com>
2019-07-05 10:27:07 -04:00
Angus McLeod ef5b3ee1ff FEATURE: Allow provider to set email verification state (#17) 2019-06-26 11:03:52 +01:00
David Taylor 725717339e DEV: Remove use of deprecated parameter 2019-06-26 10:52:23 +01:00
Guo Xiang Tan c13a7b6f61
FIX: Keep compatibility with older version of Discourse. 2019-05-14 16:39:59 +08:00
Guo Xiang Tan 5a459fbb6e Add frozen string literal comment to files. 2019-05-13 10:49:26 +08:00
David Taylor 722fe23b4e FEATURE: Add site setting to override user email address during login 2019-03-26 20:38:46 +00:00
David Taylor 4ccc4d1d5a FIX: Send the `Accept: application/json` header when fetching user JSON 2019-03-12 11:58:40 +00:00
David Taylor 090f63c429 FIX: Download avatar for new users
Previously avatars were only loaded on subsequent logins
2019-02-05 14:53:34 +00:00
David Taylor 9ad5050143 DEV: Apply rubocop 2018-10-22 20:13:46 +01:00
Neil Lalonde 718ebbfbfe FIX: callback url on subfolder installs 2018-08-20 14:16:05 -04:00
David Taylor 3ce35cb7dd Add `enabled?` function to authenticator 2018-08-03 10:12:03 +01:00
Nick Shearer 0381f91bbe Add site setting to allow full screen login 2018-07-26 10:42:51 -05:00
Blake Erickson 04ef6494de Add support for scope and add some missing translations
See this post on meta about the need for the ability to request a custom
scope:

https://meta.discourse.org/t/oauth2-basic-support/33879/116?u=blake
2018-05-25 15:35:52 -06:00
misaka4e21 f603604caa
FEATURE: Support avatar retrieval. 2018-05-25 14:34:50 +08:00
Blake Erickson bce6e9e878 ADD: can now walk json that contains arrays
I feel like this is kind of a hack to handle a change with Auth0 where
the actual user id is inside of an array of identities. While I do think
it would be good to build an actual plugin for Auth0 to better handle
their use case I do feel that it is important that we can handle Auth0
with this plugin for now.
2018-05-16 14:53:10 -06:00
David Mejorado 6b5d7b4ef2 Remove unnecessary requires 2018-04-23 09:45:41 -07:00
David Mejorado 4d0be8081a Bump minor version 2018-04-20 19:33:53 -07:00
David Mejorado 287dcc15cc Add request methods for token and user_json urls
Defaults to `GET`.

Context:

https://meta.discourse.org/t/oauth2-basic-support/33879/66?u=davidmh
2018-04-20 15:58:24 -07:00
Leo McArdle 8fc2429496 FIX: make work with user_emails migration 2017-09-05 20:12:45 +01:00
Guo Xiang Tan be6b6ee9bb Fix rubocop offenses. 2017-08-02 15:05:31 +09:00
Robin Ward 4996165a84 SECURITY: Always validate `state` parameter 2017-05-17 15:24:43 -04:00
Robin Ward e2e999014f Add temporary parameter to ignore state with oauth2 basic 2017-05-08 10:53:46 -04:00
jomaxro 1a60017cc0 Add URL to plugin.rb 2017-04-26 00:42:12 -04:00
Robin Ward 5959f5f1bb FIX: Don't add `code` and `state` since most servers dont' want it 2017-03-28 17:35:41 -04:00