{"id":13415487,"url":"https://github.com/skorokithakis/django-loginas","last_synced_at":"2026-03-11T06:30:47.387Z","repository":{"id":4989862,"uuid":"6147933","full_name":"skorokithakis/django-loginas","owner":"skorokithakis","description":"\"Log in as user\" for the Django admin.","archived":false,"fork":false,"pushed_at":"2025-12-21T11:38:08.000Z","size":165,"stargazers_count":372,"open_issues_count":8,"forks_count":69,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-12-23T03:14:52.095Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"rails/sass-rails","license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skorokithakis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2012-10-09T21:15:15.000Z","updated_at":"2025-12-21T11:37:53.000Z","dependencies_parsed_at":"2024-01-06T09:53:59.597Z","dependency_job_id":"c6f8061a-a4af-448a-8b9d-3d6adf6d3d8e","html_url":"https://github.com/skorokithakis/django-loginas","commit_stats":{"total_commits":164,"total_committers":38,"mean_commits":4.315789473684211,"dds":0.7682926829268293,"last_synced_commit":"935e230cb1b366d05881243e835d4e545f5661ab"},"previous_names":["stochastic-technologies/django-loginas"],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/skorokithakis/django-loginas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorokithakis%2Fdjango-loginas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorokithakis%2Fdjango-loginas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorokithakis%2Fdjango-loginas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorokithakis%2Fdjango-loginas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skorokithakis","download_url":"https://codeload.github.com/skorokithakis/django-loginas/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorokithakis%2Fdjango-loginas/sbom","scorecard":{"id":829969,"data":{"date":"2025-08-11","repo":{"name":"github.com/skorokithakis/django-loginas","commit":"d8431bd961cf5ed6af936af28bc9abc324c5f296"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":4,"reason":"Found 13/30 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":3,"reason":"3 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/skorokithakis/django-loginas/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/skorokithakis/django-loginas/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/skorokithakis/django-loginas/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/skorokithakis/django-loginas/ci.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:17","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:36","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 13 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T17:30:23.805Z","repository_id":4989862,"created_at":"2025-08-23T17:30:23.805Z","updated_at":"2025-08-23T17:30:23.805Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30368583,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"online","status_checked_at":"2026-03-11T02:00:07.027Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T21:00:49.653Z","updated_at":"2026-03-11T06:30:47.296Z","avatar_url":"https://github.com/skorokithakis.png","language":"Python","funding_links":[],"categories":["Third-Party Packages"],"sub_categories":["Admin","Podcasts"],"readme":"django-loginas\n==============\n\nAbout\n-----\n\n\"Login as user\" for the Django admin.\n\n[![PyPI version](https://img.shields.io/pypi/v/django-loginas.svg)](https://pypi.python.org/pypi/django-loginas)\n\n`loginas` supports Python 3 only, as of version 0.4. If you're on 2, use\n[0.3.6](https://pypi.org/project/django-loginas/0.3.6/).\n\n\nInstalling django-loginas\n-------------------------\n\n* Add `loginas` to your Python path, or install using pip: `pip install django-loginas`\n\n* Add the `loginas` app to your `INSTALLED_APPS`:\n\n```python\n# settings.py\nINSTALLED_APPS = [... 'loginas', ...]\n```\n\n* Add the `loginas` URL to your `urls.py`:\n\n```python\n# urls.py\nurlpatterns = [\n    # from Django 3.2 on, make sure to add loginas urls before the admin site urls, i.e.:\n    path('admin/', include('loginas.urls')),\n    path('admin/', admin.site.urls),\n]\n```\n\n* If you're using a custom User model, you'll need to add the template to it so the button shows up:\n\n```python\n# admin.py\nclass YourUserAdmin(ModelAdmin):\n    change_form_template = 'loginas/change_form.html'\n```\n\nAlternatively, you can add a `change_form.html` template containing just `{% extends 'loginas/change_form.html' %}`\nto your project under the path expected by your custom User model, e.g.\n`.../templates/\u003capp_label\u003e/\u003cmodel_name\u003e/change_form.html`.\n\nAt this point, you should be good to go. Just visit the Django admin, navigate to a user and you should see the \"Log\nin as user\" button at the top right of the screen.\n\nConfiguring\n-----------\n\nAt this point, the only users who will be able to log in as other users are those with the `is_superuser` permission.\nIf you use custom User models, and haven't specified that permission, or if you want to change which users are\nauthorized to log in as others, you can define the `CAN_LOGIN_AS` setting, like so:\n\n```python\n# settings.py\n\n# This will only allow admins to log in as other users:\nCAN_LOGIN_AS = lambda request, target_user: request.user.is_superuser\n\n# This will only allow admins to log in as other users, as long as\n# those users are not admins themselves:\nCAN_LOGIN_AS = lambda request, target_user: request.user.is_superuser and not target_user.is_superuser\n\n# You can also define a string path to a module:\nCAN_LOGIN_AS = \"utils.helpers.custom_loginas\"\n```\n\nBy default, clicking \"Login as user\" will send the user to `settings.LOGIN_REDIRECT_URL`.\nYou can override this behavior like so:\n\n```python\n# settings.py\n\nLOGINAS_REDIRECT_URL = '/loginas-redirect-url'\n```\n\nIn order to automatically restore the original user upon log out, replace the default log out\nwith a special log out that restores the original login session from a signed session.\n\n```python\n# settings.py\n\nfrom django.core.urlresolvers import reverse_lazy\nLOGOUT_URL = reverse_lazy('loginas-logout')\n```\n\nAdditionally, you can specify the redirect url for logout (the default is `settings.LOGIN_REDIRECT_URL`).\n\n```python\n# settings.py\n\nfrom django.core.urlresolvers import reverse_lazy\nLOGINAS_LOGOUT_REDIRECT_URL = reverse_lazy('admin:index')\n```\n\nBy default, clicking \"Login as user\" will not update `user.last_login`.\nYou can override this behavior like so:\n\n```python\n# settings.py\n\nLOGINAS_UPDATE_LAST_LOGIN = True\n```\n\nBy default, the login switch message will generate [Django admin `LogEntry`](https://docs.djangoproject.com/en/3.2/ref/contrib/admin/#logentry-objects) messages using the `User` model's\n`USERNAME_FIELD` like `f\"User {impersonator_user.getattr(USERNAME_FIELD)} logged in as {impersonated_user.getattr(USERNAME_FIELD)}.\"` You can override this behavior by passing in a different\nfield name:\n\n```python\n# settings.py\n\nLOGINAS_USERNAME_FIELD = 'email'\n```\n\nOther implementation suggestions\n--------------------------------\n\n### Existing logout view?\n\nIf you already have a logout view, you can modify to login the original user again after having had a \"login as\" session. Here's an example:\n\n```python\nclass LogoutView(LogoutView):\n    template_name = 'myapp/logged_out.html'\n\n    @method_decorator(never_cache)\n    def dispatch(self, request, *args, **kwargs):\n        from loginas.utils import restore_original_login\n        restore_original_login(request)\n        return redirect('myapp:login')\n```\n\n### Template awareness\n\nYou can add the context processor `loginas.context_processors.impersonated_session_status`\nin your settings.py file if you'd like to be able to access a variable `is_impersonated_session`\nin all your template contexts:\n\n```python\n# settings.py\n\nTEMPLATES = [\n    {\n        ...\n        'OPTIONS': {\n            'context_processors': [\n                'django.template.context_processors.debug',\n                'django.template.context_processors.request',\n                'django.contrib.auth.context_processors.auth',\n                ...\n                'loginas.context_processors.impersonated_session_status',\n            ],\n        },\n    },\n]\n```\n\nNote that django-loginas won't let you log in as other superusers, to prevent\nprivilege escalation from staff users to superusers. If you want to log in as\na superuser, first demote them to a non-superuser, and then log in.\n\nLicense\n-------\n\nThis software is distributed under the BSD license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskorokithakis%2Fdjango-loginas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskorokithakis%2Fdjango-loginas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskorokithakis%2Fdjango-loginas/lists"}