{"id":20865910,"url":"https://github.com/mnesarco/sqlpage_auth_example","last_synced_at":"2025-05-12T10:32:35.175Z","repository":{"id":214561840,"uuid":"736818100","full_name":"mnesarco/sqlpage_auth_example","owner":"mnesarco","description":"SQLPage Authentication and Authorization example","archived":true,"fork":false,"pushed_at":"2023-12-29T14:24:54.000Z","size":230,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-12T15:17:00.083Z","etag":null,"topics":["postgresql","sql","sqlpage"],"latest_commit_sha":null,"homepage":"","language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mnesarco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-29T01:05:20.000Z","updated_at":"2024-09-10T21:07:58.000Z","dependencies_parsed_at":"2023-12-29T02:25:23.683Z","dependency_job_id":"455c0475-b223-46db-bc92-0f68e697fa89","html_url":"https://github.com/mnesarco/sqlpage_auth_example","commit_stats":null,"previous_names":["mnesarco/sqlpage_auth_example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnesarco%2Fsqlpage_auth_example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnesarco%2Fsqlpage_auth_example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnesarco%2Fsqlpage_auth_example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnesarco%2Fsqlpage_auth_example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mnesarco","download_url":"https://codeload.github.com/mnesarco/sqlpage_auth_example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253720137,"owners_count":21952979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["postgresql","sql","sqlpage"],"created_at":"2024-11-18T05:55:16.401Z","updated_at":"2025-05-12T10:32:34.873Z","avatar_url":"https://github.com/mnesarco.png","language":"PLpgSQL","readme":"# SQLPage Authentication and Authorization Example\n\nThis is a very basic example of authentication and authorization boilerplate using [SQLPage](https://github.com/lovasoa/SQLpage/). I try to avoid verbose code and duplication as much as possible.\n\n# Features\n\n* Login Form\n* Signup Form\n* Protected pages\n* Role based access (RBAC)\n* Resource ACL\n\n# Install\n\n```bash\ngit clone https://github.com/mnesarco/sqlpage_auth_example.git\ncd sqlpage_auth_example\ndocker compose up\n```\n\nAfter docker services are up and runnig, Go to http://localhost:8087\n\n# Demo users\n\n* **user** has basic access\n* **user2** has manager access\n* **admin** has full access\n\nPassword of all users is the same: `demo`\n\n# Authorization concept\n\nThere are **users** and **resources** in the system. They are related through **roles** and access control lists (**ACL**)\n\nroles can be granted or revoked from users. Each role has a level access to a resource pattern.\n\n![ER](auth.png)\n\nYou can check if the current session (logged in user) has access to a specific resource with a certain authorization level:\n\n```sql\n-- Check if current user has access to products resource with a minimum level of 30\n\nSELECT ...\nWHERE x_resource_access(sqlpage.cookie('session'), 'products', level);\n\n```\n\nYou can also check if a user has some role:\n\n```sql\n-- Check if current user has admin or manager roles\n\nSELECT ...\nWHERE x_role_access(sqlpage.cookie('session'), 'admin', 'manager');\n\n```\n\n# Disclaimer\n\nThis is an example of a possible solution using the existing version of [SQLPage=0.17.1](https://github.com/lovasoa/SQLpage/)  Use at your own risk.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnesarco%2Fsqlpage_auth_example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmnesarco%2Fsqlpage_auth_example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnesarco%2Fsqlpage_auth_example/lists"}