Commit graph

52 commits

Author SHA1 Message Date
Ankush Menat
546260162d perf: Skip link checking on internal deletes
These are deletes that aren't user triggered and these documents are
typically never "linked" somewhere else. So skip all expensive link /
dynamic link checks.
2025-01-06 11:48:19 +05:30
Gavin D'souza
c6580b5880
refactor: Replace pytz to std lib zoneinfo & datetime
Signed-off-by: Gavin D'souza <gavin.dsouza@switchup.de>
2024-12-06 15:43:33 +05:30
Ankush Menat
ae4eb87458 feat: Limit OAuth Client by roles 2024-04-29 14:18:49 +05:30
Ankush Menat
cab3b963cd
fix: strip redirect URIs for trailing whitespaces (#26006) 2024-04-17 13:10:39 +00:00
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Bernd Oliver Sünderhauf
3fbae38a8d
chore: Fix Linter issue with validate_silent_authorization(). (#23577) 2023-12-04 12:38:08 +05:30
Ankush Menat
884e980526 fix: Simpler oauth token validity checks
The code is currently

1. Getting token expiry time (in system tz)
2. Adding system tz to make it tz aware
3. Converting it to UTC
4. Getting current UTC time and comparing.

We can just get current system tz time and compare directly.
2023-11-27 12:04:29 +05:30
Akhil Narang
cc58fd20ca
refactor(oauth): simplify scopes check with the usage of all()
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-23 16:04:56 +05:30
Akhil Narang
fbc88a4d24
refactor(treewide): code cleanup
Drop redundant bool conversion

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-23 13:57:51 +05:30
Ankush Menat
f526054ae2
refactor: Remove usage of utcnow (#23369) 2023-11-23 13:21:27 +05:30
Ankush Menat
4fb0f9f98d refactor: delete oauth internal data with db query
This won't trigger DB hooks but
- it's faster.
- doesn't do any validation/hooks
- doesn't store deleted document
2023-09-25 19:38:48 +05:30
barredterra
88c8baa9ee refactor: for append to extend, merge list extend
Replace a for append loop with list extend.
Create the list with values instead of creating
an empty list and extending it with another list.
2023-08-09 13:25:39 +02:00
barredterra
b553ed98d8 refactor: inline immediately returned variable
Inline a variable to a return in the case when the
variable being declared is immediately returned
2023-08-08 18:09:49 +02:00
William Luke
e0ed7d3b97
fix(oauth): add exp to idToken (#20694) 2023-05-05 01:19:03 +05:30
Ankush Menat
0cab0b830d
refactor: replace imghdr with filetype (#20680)
* refactor: replace `imaghdr` with `filetype`

```
11:52:06 worker.1      | /home/ankush/benches/develop/apps/frappe/frappe/core/doctype/file/utils.py:2: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13
```

* feat: improved extension guessing using filecontent
2023-04-13 12:19:08 +05:30
Mohammad Hussain Nagaria
f46d1aefa9
refactor: use urljoin to build picture url (#20664) 2023-04-12 13:38:23 +05:30
barredterra
b2e36634d6 refactor: rename get_time_zone to get_system_timezone 2023-03-04 19:30:03 +01:00
Aditya Hase
93320ce6e7
fix(oauth): Send id_token of the authorized user instead of Guest
This only affects OAuth clients that use `id_token` obtained from `frappe.integrations.oauth2.get_token`.

Doesn't affect OAuth clients that ignore id_token and explicitly use `frappe.integrations.oauth2.openid_profile` endpoint for getting user details. e.g. Frappe OAuth client.

A simple way to replicate this is to setup Frappe-Frappe OAuth client-server pair and use `login_via_oauth2_id_token` instead of `login_via_oauth2` in `login_via_frappe`.
2022-06-21 21:52:22 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Gavin D'souza
165ff8e1bf chore: Update PyJWT dependency
* Update pinned dep fromm 1.7.1 to 2.0.1
* Updated usages as per changelog

ref: https://python.libhunt.com/pyjwt-changelog
2021-05-29 17:22:30 +05:30
Nabin Hait
6d7a852351 Merge branch 'version-13' into develop 2021-05-17 11:21:46 +05:30
Hussain Nagaria
024e759a70 refactor: Add optional URL scheme validation 2021-05-01 00:34:19 +05:30
Revant Nandgaonkar
c75eb8933f feat: OAuth 2 openid-configuration and introspect_token endpoint
(cherry picked from commit 4e8b00ba1f)
2021-04-29 14:14:30 +00:00
Revant Nandgaonkar
1f2b3e502e fix: sider issues
(cherry picked from commit 1f54b8b973)
2021-04-29 14:14:30 +00:00
Revant Nandgaonkar
dfd5651dbe refactor: improve oauthlib implementation
implement openid provider
implement PKCE
improve errors

(cherry picked from commit 96d6971ee4)
2021-04-29 14:14:30 +00:00
Rohan Bansal
dade7ed216 refactor: fix py3 datatypes and remove references to six in oauth 2021-04-28 14:02:23 +05:30
Revant Nandgaonkar
4e8b00ba1f feat: OAuth 2 openid-configuration and introspect_token endpoint 2021-04-26 22:56:14 +05:30
Revant Nandgaonkar
1f54b8b973 fix: sider issues 2021-04-26 22:56:14 +05:30
Revant Nandgaonkar
96d6971ee4 refactor: improve oauthlib implementation
implement openid provider
implement PKCE
improve errors
2021-04-26 22:56:14 +05:30
barredterra
5a52bc73ef fix: cookie value 2020-11-20 17:40:56 +01:00
barredterra
105dd44ce1 refactor: extract get_client_scopes(), use all() instead of complicated loop 2020-09-26 20:28:31 +02:00
barredterra
22b12ff0ac fix: remove unused imports 2020-09-26 20:25:27 +02:00
Raffael Meyer
8d18fb4323
fix(oauth provider): parse cookies correctly (#11066) 2020-07-29 21:18:39 +05:30
Sagar Vora
ef82f39f99 Merge branch 'staging' into develop 2019-01-29 18:24:11 +05:30
Aditya Hase
928ec12d35 fix(import): Import print_function once 2019-01-28 14:54:55 +05:30
Rushabh Mehta
ef23700256
update(frappe): Update dependency Oauthlib (#6832)
Update dependency oauthlib to 3.0.0

updates interdependent lib requests-oauthlib to 1.2.0
2019-01-25 18:31:52 +05:30
Aditya Hase
837bfc0995 fix(unicode): Import unicode_literals in every file (#6805)
* fix(unicode): Import unicode_literals in every file

* fix(unicode): Test if safe_json_loads return unicode instead of bytes
2019-01-25 11:56:27 +05:30
Revant Nandgaonkar
34e9c2c5ac OAuth 2.0
Resource Owner Password Credentials Grant
2018-03-19 22:27:22 +05:30
Revant Nandgaonkar
02aa7b6f41 Social login refactor (#4519)
* Added DocType Social Login Key

WIP for https://github.com/frappe/frappe/issues/4496
added basic fields
after_insert add provider_username and provider_userid fields on User dt
on_trash deletes added fields on User dt

* Added field to store fontawesome icon for provider

* [Patch] Social Login Keys to Social Login Key

* [Patch] Social Login Keys to Social Login Key

* Social Login Key generates boilerplate

* patch fixed for social_login_refactor

* removed patch-not working

* use social login keys to initiate flow

* Login page shows Social Login Key

* show login via if base_url present

* removed boilerplate generator

* Multiple Changes

fix zxcvbn import in password_strength.py
use of child table instead of additional fields on user dt to store username and userid

* Fetched Template on Client JS

* Frappe social login template working

* Added Social Login Key Templates

* Codacy fixes and validate social login key urls

* [Patch] Social Login Keys (untested)

* [Fix] Patch refactor social login keys

* [Fix] Patch refactor_social_login_keys manually tested

* Refactor OAuth 2.0 related changes for Social Login Key

* [Fix] Patch refactor social login keys

* Test - Adding Frappe Social Login Key

* Social Login Key Tests

check added child table entry on user for provider frappe
it also checks if userid is created

* [WIP] Office 365 Social Login Key Template

* [Fix] Social Login - Redirect URL

* [Test] Single sign-on icons for added provider

* [Fix] Codacy Errors

* [Fix] Social Login Key Form JS

* Docs Added for Social Login Key

* [Fix] Patch Refactor Social Login Keys

* Handle different icon types

Handle different icon types (image, icon, emoji) with just icon field

* Move the login methods to a new py file

frappe.integrations.oauth2_logins added
copied whitelisted guest oauth2 redirect endpoints from login.py
removing the functions from login.py will break backward compatibility

* Social Login Key Form Changes

Moved Enable field to top
Fields which are not editable are collapsed

* [Fix] Codacy Errors

* Corrected Docs, sync.py

* [Docs] Adding a social login provider

* [Fix] set frappe userid from User Social Login

* [Fix] frappe userid in oauth.py

* removed icon_type

* Use frappe.utils.is_image
2018-01-03 14:57:16 +05:30
Revant Nandgaonkar
d80a8e8804 Oauth2 implicit grant fixes tests (#4261)
* [Fix] Implicit Grant / Token

* test for oauth2 implicit grant
2017-10-06 11:47:33 +05:30
Aditya Hase
99f17c651c Use 'in' instead of 'has_key' 2017-09-04 16:05:58 +05:30
Aditya Hase
375dfd601d Replaced urlparse imports with six.moves.urllib.parse (#3847) 2017-08-03 11:43:28 +05:30
Aditya Hase
16a9bdfd31 Replaced urllib.unquote imports with six.moves.urllib.parse.unquote (#3836) 2017-08-02 17:09:31 +05:30
Revant Nandgaonkar
9fb5839f5c [Fix] OAuth2 Token validation (#3694)
Convert token expiration time to utc and compare with utcnow
2017-07-17 11:49:03 +05:30
tundebabzy
6fbe20caaa Except and raise statement python 3 compatible style (#3216)
* changes exception and raise statements to python 3 style

* changes except statement to python 3 style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* adds six.reraise to fix python 3 style raise statements with traceback

* fixes indentation
2017-05-11 10:51:59 +05:30
tundebabzy
7b41d7e5eb Python 3 compatible print statements (#3199)
* changes print statements in file to python 3 compatible style using `__future__`

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* changes deprecated md5 module to hashlib

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements

* adds python 3 style for print statements
2017-05-01 12:34:29 +05:30
Revant Nandgaonkar
511a7e2dde [Fix] set user from refresh token if not found
Use frappe.db.get_value instead of frappe.get_doc
to fetch value of user from bearer/refresh_token
2017-02-28 15:51:23 +05:30
Revant Nandgaonkar
94d9f2c48e [Fix] set user from refresh token if not found 2017-02-28 13:58:29 +05:30
Revant Nandgaonkar
496c1d293e [Add] OAuth 2 Implicit Grant flow (#2728) 2017-02-16 17:18:57 +05:30
Revant Nandgaonkar
7757aaef6a [Fix] oauth url delimiter moved to function instead of global (#2305)
* [Fix] oauth url delimiter moved to function instead of global

* [Fix] renamed oauth_url_delimiter to get_url_delimiter
2016-11-14 12:05:47 +05:30