Skip to content

Coding style and broken links #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ $ pip install -r requirements.txt # Install additional tools and dependencies

We use [pylint](https://pylint.org/) for verifying source code format, and
enforcing other Python programming best practices.
There is a pylint configuration file ([`.pylintrc`](../.pylintrc)) at the root of this Git
There is a pylint configuration file ([`.pylintrc`](.pylintrc)) at the root of this Git
repository. This enables you to invoke pylint directly from the command line:

```
pylint firebase_admin
```

However, it is recommended that you use the [`lint.sh`](../lint.sh) bash script to invoke
However, it is recommended that you use the [`lint.sh`](lint.sh) bash script to invoke
pylint. This script will run the linter on both `firebase_admin` and the corresponding
`tests` module. It suprresses some of the noisy warnings that get generated
when running pylint on test code. Note that by default `lint.sh` will only
Expand Down Expand Up @@ -226,7 +226,7 @@ pyenv install 3.3.0 # install Python 3.3.0
pyenv install pypy2-5.6.0 # install pypy2
```

Refer to the [`tox.ini`](../tox.ini) file for a list of target environments that we usually test.
Refer to the [`tox.ini`](tox.ini) file for a list of target environments that we usually test.
Use pyenv to install all the required Python versions on your workstation. Verify that they are
installed by running the following command:

Expand Down
14 changes: 14 additions & 0 deletions firebase_admin/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def create_custom_token(uid, developer_claims=None, app=None):
except _token_gen.ApiCallError as error:
raise AuthError(error.code, str(error), error.detail)


def verify_id_token(id_token, app=None, check_revoked=False):
"""Verifies the signature and data for the provided JWT.

Expand Down Expand Up @@ -150,6 +151,7 @@ def verify_id_token(id_token, app=None, check_revoked=False):
_check_jwt_revoked(verified_claims, _ID_TOKEN_REVOKED, 'ID token', app)
return verified_claims


def create_session_cookie(id_token, expires_in, app=None):
"""Creates a new Firebase session cookie from the given ID token and options.

Expand All @@ -174,6 +176,7 @@ def create_session_cookie(id_token, expires_in, app=None):
except _token_gen.ApiCallError as error:
raise AuthError(error.code, str(error), error.detail)


def verify_session_cookie(session_cookie, check_revoked=False, app=None):
"""Verifies a Firebase session cookie.

Expand All @@ -199,6 +202,7 @@ def verify_session_cookie(session_cookie, check_revoked=False, app=None):
_check_jwt_revoked(verified_claims, _SESSION_COOKIE_REVOKED, 'session cookie', app)
return verified_claims


def revoke_refresh_tokens(uid, app=None):
"""Revokes all refresh tokens for an existing user.

Expand All @@ -214,6 +218,7 @@ def revoke_refresh_tokens(uid, app=None):
user_manager = _get_auth_service(app).user_manager
user_manager.update_user(uid, valid_since=int(time.time()))


def get_user(uid, app=None):
"""Gets the user data corresponding to the specified user ID.

Expand All @@ -236,6 +241,7 @@ def get_user(uid, app=None):
except _user_mgt.ApiCallError as error:
raise AuthError(error.code, str(error), error.detail)


def get_user_by_email(email, app=None):
"""Gets the user data corresponding to the specified user email.

Expand Down Expand Up @@ -281,6 +287,7 @@ def get_user_by_phone_number(phone_number, app=None):
except _user_mgt.ApiCallError as error:
raise AuthError(error.code, str(error), error.detail)


def list_users(page_token=None, max_results=_user_mgt.MAX_LIST_USERS_RESULTS, app=None):
"""Retrieves a page of user accounts from a Firebase project.

Expand Down Expand Up @@ -381,6 +388,7 @@ def update_user(uid, **kwargs):
except _user_mgt.ApiCallError as error:
raise AuthError(error.code, str(error), error.detail)


def set_custom_user_claims(uid, custom_claims, app=None):
"""Sets additional claims on an existing user account.

Expand All @@ -407,6 +415,7 @@ def set_custom_user_claims(uid, custom_claims, app=None):
except _user_mgt.ApiCallError as error:
raise AuthError(error.code, str(error), error.detail)


def delete_user(uid, app=None):
"""Deletes the user identified by the specified user ID.

Expand All @@ -424,6 +433,7 @@ def delete_user(uid, app=None):
except _user_mgt.ApiCallError as error:
raise AuthError(error.code, str(error), error.detail)


def import_users(users, hash_alg=None, app=None):
"""Imports the specified list of users into Firebase Auth.

Expand Down Expand Up @@ -453,6 +463,7 @@ def import_users(users, hash_alg=None, app=None):
except _user_mgt.ApiCallError as error:
raise AuthError(error.code, str(error), error.detail)


def generate_password_reset_link(email, action_code_settings=None, app=None):
"""Generates the out-of-band email action link for password reset flows for the specified email
address.
Expand All @@ -477,6 +488,7 @@ def generate_password_reset_link(email, action_code_settings=None, app=None):
except _user_mgt.ApiCallError as error:
raise AuthError(error.code, str(error), error.detail)


def generate_email_verification_link(email, action_code_settings=None, app=None):
"""Generates the out-of-band email action link for email verification flows for the specified
email address.
Expand All @@ -501,6 +513,7 @@ def generate_email_verification_link(email, action_code_settings=None, app=None)
except _user_mgt.ApiCallError as error:
raise AuthError(error.code, str(error), error.detail)


def generate_sign_in_with_email_link(email, action_code_settings, app=None):
"""Generates the out-of-band email action link for email link sign-in flows, using the action
code settings provided.
Expand All @@ -525,6 +538,7 @@ def generate_sign_in_with_email_link(email, action_code_settings, app=None):
except _user_mgt.ApiCallError as error:
raise AuthError(error.code, str(error), error.detail)


def _check_jwt_revoked(verified_claims, error_code, label, app):
user = get_user(verified_claims.get('uid'), app=app)
if verified_claims.get('iat') * 1000 < user.tokens_valid_after_timestamp:
Expand Down