0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-25 11:17:50 +01:00
Commit Graph

22 Commits

Author SHA1 Message Date
Julian Bez
9576fab1e4
chore: Add Pyupgrade rules (#21714)
* Add Pyupgrade rules
* Set correct Python version
2024-04-25 08:22:28 +01:00
Julian Bez
487ca39064
chore: Enable more ruff rules (#21043) 2024-04-08 16:21:51 +01:00
Ben White
69b2bece50
fix: Deleting role members (#20928) 2024-03-18 10:09:35 +01:00
Tom Owers
5513be7731
chore: upgraded Ruff linter (#18188)
* Upgraded Ruff linter

* Formatted whole codebase with new ruff rules

* Revert import removal

* Fixed mypi issues or added ignores

* Fixed schema formatting

* Fixed hogvm failing tests

* Remove duplicate key in list
2023-10-26 12:38:15 +02:00
Paul D'Ambra
5b268df29c
feat: allow verified property definitions (#15937)
Today it annoyed me I could verify an event but not a property

Changes
Adds property definition verification, which was mostly copy-pasta from existing code
2023-06-08 11:52:25 +01:00
Li Yi Yu
862697ef83
feat: role based permissions (#12657)
* initial role and role memberships setup

* create role when org is created and role memberships when user joins

* wip for merge

* fix api tests for role

* nest roles under organization route and test fixes

* remove pdb set trace

* fix types

* remove creating default roles and role memberships for orgs and users

* add permission levels to orgs and roles

* bulk create role memberships

* leave role membership as individual api request, handle bulk creation on the frontend instead

* feature flag role access wip and migrations

* fix flag role access tests

* linter

* isort

* temp type ignore

* add access level to plugin tests

* test remove test migration safe

* test license import error fix

* delete old? org license test

* nvm we need these tests

* type ignore

* reset license plans after test

* add organization resource access model and remove access level field from regular organizations

* feat: permission return on feature flag (#12826)

* suggested permission return

* change naming

* add changes

* pass bool

* fix plugin tests

* organization resource access tests and fixes

* update can edit return with new org resource access model from feature flag

* fix tests

* add permissions to feature flag for editing

* more tests

* remove unnecessary spacing

* fix test

* add context for feature flag serializer tests

* add back workflow test step

* add organization to feature flag role access

* fix(spike): why are tests failing (#12858)

* was it because invalid id is provided?

* allow django to touch the db

* a less unexpected way of allowing access to the DB

* Revert "add organization to feature flag role access"

This reverts commit ef18b0ec8b.

* address feedback and include organization safety checks in tests

* test error fix

* test role dupe name per org

* remove third access level option

* fix migration for it

* more tests

* fix test

* feat: role based permissions UI (#12776)

* add api

* starter

* role and member creation + deletion

* working with all deletes

* add block

* working roles

* permissions tab on org settings

* org default setting

* types

* flag role assignment

* working per flag permission

* working with admin block

* types

* use restricted area component

* wrap flag resource access in different url

* restore migrations manifest

* update url endpoints

* pay gate mini org role settings

* remove view and custom edit and remove resource access creation on org creation

* add feature flag

* address feedback

* fix backend tests

* remove broken permissions setting on new feature flags

* export logic props interface

Co-authored-by: Li Yi Yu <li@posthog.com>

* type fixes

Co-authored-by: Eric Duong <eeoneric@gmail.com>
Co-authored-by: Paul D'Ambra <paul@posthog.com>
2022-11-23 20:36:29 -05:00
Michael Matloka
5d2ad6c7bb
chore(deps): Update black to 22.8.0 (#11596)
* chore(deps): Update `black` to `22.8.0`

* Format
2022-09-05 14:38:54 +02:00
Alex Gyujin Kim
446028beb9
chore: remove deprecated tags fields (#10280)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-06-23 16:53:35 +00:00
Alex Gyujin Kim
2b40af5d77
fix(migration): migrate deprecated_tags to new tagging model (#8825) 2022-03-09 10:25:47 -08:00
Guido Iaquinti
0ef7f6a493
ci(flake8): enable unused import check (#8714) 2022-03-08 09:53:54 +01:00
Tim Glaser
ee71311991
noop 0214 (#8704)
* noop 0214

* No opp tests and ee migration
2022-02-18 21:42:38 +00:00
Alex Gyujin Kim
a88766300e
Add tags back migrations (#8701)
* add tags back migrations

* make tags default None
2022-02-18 21:29:16 +00:00
Alex Gyujin Kim
d7a0c10e32
Part 2: Deprecate old tags and upgrade to new tags Backend (#8529) 2022-02-18 08:47:05 -08:00
Alex Gyujin Kim
ba640115e9
Editable taxonomy definitions (#8430) 2022-02-15 18:04:19 -08:00
Michael Matloka
8b5ecc9f6f
Dashboard permissions base (#8394)
* Add models for dashboard permissions

* Update migrations

* Add basic API capabilities

* Add basic dashboard perms UI

* Update test_insight.ambr

* Fix typing

* Split RestrictionLevel into RestrictionLevel&PrivilegeLevel for clarity

* Update migrations post-merge
2022-02-02 17:16:35 +01:00
Alex Gyujin Kim
204ca1bc92
Add verified properties to event definitions (#8081)
Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2022-01-18 08:38:55 -06:00
Michael Matloka
bc3e223265
Project-based permissioning framework (#5976)
* Refactor `AvailableFeature` from strings to an enum everywhere

* Fix circular dependency and type

* Add "Per-project access" feature flag, premium feature, and organization switch

* Rename `OrganizationMembershipLevel` to `OrganizationAccessLevel`

* Create `ExplicitTeamMembership` model

* Show whether projects are restricted in the project switcher

* Update organizations API code

* Fix migrations

* Move organization tests that require EE to `ee`

* Revert `OrganizationMembershipLevel` rename

* Fix organization tests

* Update migration

* Fix schema and add Members to Project Settings

* Build out test memberships API with security tests

* Update `TeamMembers` and `teamMembersLogic`

* Move "Per-project access" description to tooltip

* Add moar tests

* Fix Project Members list logic

* Add additional membership checks

* Update migrations

* Fix typing

* Adjust explicit team memberships API similarly

* Fix typo

* Unify `ExplicitTeamMemberSerializer`

* Remove old changes to `membersLogic` usage

* Use `effective_membership_level` on `TeamBasicSerializer`

* Clean up organization update tests

* Explicitly disallow enabling per-project access for free

* Fix circular import

* Remove `id` from `UserSerializer`

* Fix typing

* Try to fix import

* Fix fatal typing

* Add more tests

* Update permissioning.ts

* Add clarifying comment to migration

* Fix import

* minor clarifications

* Revert `TopNavigation` changes

* Make new access control entirely project-based

* Update migrations

* Add `project_based_permissioning` to `TeamBasicSerializer`

* Update test_team.py

* Fix Access Control restriction tooltip

* adjust copy & UI a bit

* Address feedback on field comment

* "Privacy settings" to "Access Control"

* Ignore mypy

* Rename `Team` field `project_based_permissioning` to `access_control`

* Update migrations

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-09-22 18:29:59 +02:00
Li Yi Yu
7546e3ea0a
Event properties taxonomy (#4486)
* add description and tag fields to event and property definitions

* set up description and tagging on models

* frontend functionality for description editing

* connect backend and kea logic for description editing

* update event and property definitions model and migration

* delete set null instead of cascade

* migration merge fix

* add owner column

* undo posthog event property taxonomy migrations

* set up definitions on enterprise level

* allow enterprise definitions description editing

* fix licensing conditions and add tests

* proper get and update methods for the multi inheritance table and new column fields for enterprise event model

* check for license to separate routes

* migrate existing definitions to ee definitions tables and render ee vs non-ee definition views based on existing feature conditional

* all the working backend updates

* updated tests

* frontend fixes and linting updates

* feature flag it
2021-06-03 09:22:16 -04:00
Tim Glaser
5cfbc49cc3
Add clickhouse and max users to license (#3918)
Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-04-14 08:45:39 -07:00
Marius Andra
1eeed28751
Fix Master EE code (#1701)
* add test runner to ease pycharm dev

* fix broken import

* drop and recreate the clickhouse test db before running tests

* fix person uuid str json serialization issue

* make kafka optional in tests

* fix inits

* remove need for kafka in person.py

* fix a bunch of mypy errors

* fix function and add process_event to pipeline

* fixed missing params and tests

* change uuid and fix types

* types

* optimize for merge prop test

* make ClickhouseProducer to produce to clickhouse one way or another

* annotate types

Co-authored-by: Eric <eeoneric@gmail.com>
Co-authored-by: James Greenhill <fuziontech@gmail.com>
2020-09-24 06:14:17 -04:00
Michael Matloka
c040601f49
Personal API keys and Zapier integration (#1281)
* Add missing migration

* Add generate_random_token() model util

* Move PublicTokenAuthentication to utils

* Make use of generate_random_token

* Add User.personal_access_token field

* Add PersonalAccessTokenAuthentication

* Fix PublicTokenAuthentication

* Fix migration and auth import

* Add personal_access_token to user API

* Update Setup.js

* Support trailing slash in API

* Improve PAT auth quality

* Add django-rest-hooks requirement

* Update settings.py for rest_hooks

* Fix django-rest-hooks requirement

* Bring back API routes with no double trailing slash

* Rename posthog.api.team to team_user

* Add API TODO

* Ad PAT auth with X-PAT HTTP header

* Replace User.personal_access_token with PersonalAPIKey model

* Fix PersonalAPIKey max_lengths

* Describe posthog.models.utils.generate_random_token better

* Add personal_api_key to API

* Add authenticate_header to PersonalAPIKeyAuthentication

* Add hook API endpoint

* Use django.utils.timezone in place of datetime.datetime

* Add Personal API Keys to Setup

* Sort personal_api_keys in ORM

* Add Action.on_perform()

* Remove requirements.txt comment

* Add a

* Add REST hook tasks

* Optimize PersonalAPIKeyAuthentication query

* Add a trailing slash version of /e endpoint

* Add team field to PersonalAPIKey model

* Add personal API key support to capture endpoint, get_cached_from_token

* Reject personal API keys from inactive users

* Add extra_properties_json field to /capture

* Improve PAK auth header regex

* Use custom hook model

* Deliver hooks

* Handle action.on_perform

* Consolidate userLogic in userLogic.tsx

* Update PersonalAPIKeys.js

* Make PersonalAPIKey foreign keys read-only

* Update requirements/dev.txt

* Make PersonalAPIKeys TSX

* Fix conflict

* Fix migration

* Fix minor mishaps

* Update and fix tests

* Use CharField of random 32 bits as hook.id

* Fix conflicting migrations

* Fix ValidationError in HookSerializer.validate_event

* Use query param in /api/event/actions ID filtering

* Rename endpoint `hook` to `hooks`

* Satisfy mypy

* Add tests

* Use DRF serialization in action_defined and annotation_created triggers

* Update migration leafs

* Make mypy ignore rest_hooks

* Update Django signal receiver names

* Update TS dependencies

* Revert "Update TS dependencies"

This reverts commit 7fc26fefcd.

* Add field user to Hook model

* Update migration leafs

* Fix circular import

* Fix some code

* Install git before running pip install in Dockerfiles

* Improve personal API keys UI

* Satisfy mypy

* Reword key label placeholder

* Add personal API key support to /api/user/*

Unfortunately these endpoints are still limited by CSRF protections at the moment, so not accessible outside PostHog itself.

* Improve PersonalAPIKeyAuthentication and add CsrfOrKeyViewMiddleware

* Run collectstatic before test

* Don't install dev dependencies in CI

* Update dependency installation order in CI

* Fix bug and describe PersonalAPIKeyAuthentication

* Fix CI issues

* Fix typing issues

* Fix more typing issues

* Use /api/personal_api_keys to list keys

* Move REST hooks (and therefore Zapier) to ee/

* Refactor personal API logic with kea-loaders

* Add "More about API authentication in PostHog docs."

* Update PersonalAPIKeys.tsx

* Use TestMixin

* Fix "Authentication" that should've been "Authorization"

* Add option to skip self.client.force_login in API tests

* Include team_id and user_id in personal API key serialization

* Update test_hooks.py

* Add personal API key tests

* Remove leftover

* Make ee.settings override posthog.settings

* Don't directly import from models

* Remove unused imports

* Fix mypy issues

* Fix HOOK_DELIVERER

* Use decorator for /api/user PAK auth

* Don't fire REST hook if user doesn't have "zapier" feature

* Import Optional

* Reword to "premium Zapier"

* Make mypy happy

* Fix test_delete_personal_api_key

* Fix misclick

* Fix and test /capture with personal API key

* Make mypy happy

* Remove extra_properties_json

* Resolve migrations

* Remove apt-utils

* Optimize and test PAK user.is_active filtering

* Replace DEBUG true with 1

* Remove unused instance_id

* Improve typing

* Fix deletion toast

* Refactor CopyToClipboard and use it in PAKs

* Use toast.success

* Update migrations

* Fix migration

* Fix migrations

* Complete merge

Co-authored-by: Tim Glaser <tim@glsr.nl>
2020-08-26 10:34:57 +02:00
Tim Glaser
23f5918477
Add enterprise edition and licensing (#1390)
* Add enterprise edition and licensing

* Cypress test

* License wording change

* Fix typos
2020-08-14 11:23:55 +02:00