├── .gitignore ├── MANIFEST.in ├── README.md ├── frappeauth_app ├── __init__.py ├── authentication.py ├── config │ ├── __init__.py │ ├── desktop.py │ └── docs.py ├── frappeauth_app │ └── __init__.py ├── hooks.py ├── modules.txt ├── patches.txt └── templates │ ├── __init__.py │ └── pages │ └── __init__.py ├── license.txt ├── requirements.txt └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.pyc 3 | *.egg-info 4 | *.swp 5 | tags 6 | frappeauth_app/docs/current -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include MANIFEST.in 2 | include requirements.txt 3 | include *.json 4 | include *.md 5 | include *.py 6 | include *.txt 7 | recursive-include frappeauth_app *.css 8 | recursive-include frappeauth_app *.csv 9 | recursive-include frappeauth_app *.html 10 | recursive-include frappeauth_app *.ico 11 | recursive-include frappeauth_app *.js 12 | recursive-include frappeauth_app *.json 13 | recursive-include frappeauth_app *.md 14 | recursive-include frappeauth_app *.png 15 | recursive-include frappeauth_app *.py 16 | recursive-include frappeauth_app *.svg 17 | recursive-include frappeauth_app *.txt 18 | recursive-exclude frappeauth_app *.pyc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Frappeauth App 2 | 3 | Frappe app for authentication, can be used with FrappeVue-AdminLTE 4 | https://github.com/mymi14s/frappevue_adminlte 5 | 6 | ## INSTALLATION 7 | ``` 8 | bench get-app https://github.com/mymi14s/frappeauth_app 9 | bench --site sitename install-app frappeauth_app 10 | bench restart 11 | ``` 12 | ## Edit site_config.json and add "allow_cors": "*" // * can also be replace with a domain name. 13 | 14 | 15 | #### License 16 | 17 | MIT -------------------------------------------------------------------------------- /frappeauth_app/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | __version__ = '0.0.1' 3 | 4 | -------------------------------------------------------------------------------- /frappeauth_app/authentication.py: -------------------------------------------------------------------------------- 1 | import frappe 2 | from frappe.core.doctype.user.user import generate_keys 3 | 4 | 5 | @frappe.whitelist(allow_guest=True) 6 | def login(**kwargs): 7 | try: 8 | usr, pwd, cmd = frappe.form_dict.values() 9 | print(usr, pwd, cmd) 10 | auth = frappe.auth.LoginManager() 11 | auth.authenticate(user=usr, pwd=pwd) 12 | auth.post_login() 13 | msg={ 14 | 'status_code':200, 15 | 'text':frappe.local.response.message, 16 | 'user': frappe.session.user 17 | } 18 | user = frappe.get_doc('User', frappe.session.user) 19 | if(user.api_key and user.api_secret): 20 | msg['token'] = f"{user.api_key}:{user.get_password('api_secret')}" 21 | else: 22 | generate_keys(user.name) 23 | user.reload() 24 | msg['token'] = f"{user.api_key}:{user.get_password('api_secret')}" 25 | return msg 26 | except frappe.exceptions.AuthenticationError: 27 | return {'status_code':401, 'text':frappe.local.response.message} 28 | except Exception as e: 29 | return {'status_code':500, 'text':str(e)} 30 | -------------------------------------------------------------------------------- /frappeauth_app/config/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mymi14s/frappeauth_app/d8cc65c55e5e02cba8c0655364309ab76127b1f1/frappeauth_app/config/__init__.py -------------------------------------------------------------------------------- /frappeauth_app/config/desktop.py: -------------------------------------------------------------------------------- 1 | from frappe import _ 2 | 3 | def get_data(): 4 | return [ 5 | { 6 | "module_name": "Frappeauth App", 7 | "color": "grey", 8 | "icon": "octicon octicon-file-directory", 9 | "type": "module", 10 | "label": _("Frappeauth App") 11 | } 12 | ] 13 | -------------------------------------------------------------------------------- /frappeauth_app/config/docs.py: -------------------------------------------------------------------------------- 1 | """ 2 | Configuration for docs 3 | """ 4 | 5 | # source_link = "https://github.com/[org_name]/frappeauth_app" 6 | # docs_base_url = "https://[org_name].github.io/frappeauth_app" 7 | # headline = "App that does everything" 8 | # sub_heading = "Yes, you got that right the first time, everything" 9 | 10 | def get_context(context): 11 | context.brand_html = "Frappeauth App" 12 | -------------------------------------------------------------------------------- /frappeauth_app/frappeauth_app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mymi14s/frappeauth_app/d8cc65c55e5e02cba8c0655364309ab76127b1f1/frappeauth_app/frappeauth_app/__init__.py -------------------------------------------------------------------------------- /frappeauth_app/hooks.py: -------------------------------------------------------------------------------- 1 | from . import __version__ as app_version 2 | 3 | app_name = "frappeauth_app" 4 | app_title = "Frappeauth App" 5 | app_publisher = "Anthony Emmanuel C." 6 | app_description = "Frappe app for authentication, utilities" 7 | app_icon = "octicon octicon-file-directory" 8 | app_color = "grey" 9 | app_email = "mymi14s@hotmail.com" 10 | app_license = "MIT" 11 | 12 | # Includes in 13 | # ------------------ 14 | 15 | # include js, css files in header of desk.html 16 | # app_include_css = "/assets/frappeauth_app/css/frappeauth_app.css" 17 | # app_include_js = "/assets/frappeauth_app/js/frappeauth_app.js" 18 | 19 | # include js, css files in header of web template 20 | # web_include_css = "/assets/frappeauth_app/css/frappeauth_app.css" 21 | # web_include_js = "/assets/frappeauth_app/js/frappeauth_app.js" 22 | 23 | # include custom scss in every website theme (without file extension ".scss") 24 | # website_theme_scss = "frappeauth_app/public/scss/website" 25 | 26 | # include js, css files in header of web form 27 | # webform_include_js = {"doctype": "public/js/doctype.js"} 28 | # webform_include_css = {"doctype": "public/css/doctype.css"} 29 | 30 | # include js in page 31 | # page_js = {"page" : "public/js/file.js"} 32 | 33 | # include js in doctype views 34 | # doctype_js = {"doctype" : "public/js/doctype.js"} 35 | # doctype_list_js = {"doctype" : "public/js/doctype_list.js"} 36 | # doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"} 37 | # doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"} 38 | 39 | # Home Pages 40 | # ---------- 41 | 42 | # application home page (will override Website Settings) 43 | # home_page = "login" 44 | 45 | # website user home page (by Role) 46 | # role_home_page = { 47 | # "Role": "home_page" 48 | # } 49 | 50 | # Generators 51 | # ---------- 52 | 53 | # automatically create page for each record of this doctype 54 | # website_generators = ["Web Page"] 55 | 56 | # Installation 57 | # ------------ 58 | 59 | # before_install = "frappeauth_app.install.before_install" 60 | # after_install = "frappeauth_app.install.after_install" 61 | 62 | # Desk Notifications 63 | # ------------------ 64 | # See frappe.core.notifications.get_notification_config 65 | 66 | # notification_config = "frappeauth_app.notifications.get_notification_config" 67 | 68 | # Permissions 69 | # ----------- 70 | # Permissions evaluated in scripted ways 71 | 72 | # permission_query_conditions = { 73 | # "Event": "frappe.desk.doctype.event.event.get_permission_query_conditions", 74 | # } 75 | # 76 | # has_permission = { 77 | # "Event": "frappe.desk.doctype.event.event.has_permission", 78 | # } 79 | 80 | # DocType Class 81 | # --------------- 82 | # Override standard doctype classes 83 | 84 | # override_doctype_class = { 85 | # "ToDo": "custom_app.overrides.CustomToDo" 86 | # } 87 | 88 | # Document Events 89 | # --------------- 90 | # Hook on document methods and events 91 | 92 | # doc_events = { 93 | # "*": { 94 | # "on_update": "method", 95 | # "on_cancel": "method", 96 | # "on_trash": "method" 97 | # } 98 | # } 99 | 100 | # Scheduled Tasks 101 | # --------------- 102 | 103 | # scheduler_events = { 104 | # "all": [ 105 | # "frappeauth_app.tasks.all" 106 | # ], 107 | # "daily": [ 108 | # "frappeauth_app.tasks.daily" 109 | # ], 110 | # "hourly": [ 111 | # "frappeauth_app.tasks.hourly" 112 | # ], 113 | # "weekly": [ 114 | # "frappeauth_app.tasks.weekly" 115 | # ] 116 | # "monthly": [ 117 | # "frappeauth_app.tasks.monthly" 118 | # ] 119 | # } 120 | 121 | # Testing 122 | # ------- 123 | 124 | # before_tests = "frappeauth_app.install.before_tests" 125 | 126 | # Overriding Methods 127 | # ------------------------------ 128 | # 129 | # override_whitelisted_methods = { 130 | # "frappe.desk.doctype.event.event.get_events": "frappeauth_app.event.get_events" 131 | # } 132 | # 133 | # each overriding function accepts a `data` argument; 134 | # generated from the base implementation of the doctype dashboard, 135 | # along with any modifications made in other Frappe apps 136 | # override_doctype_dashboards = { 137 | # "Task": "frappeauth_app.task.get_dashboard_data" 138 | # } 139 | 140 | # exempt linked doctypes from being automatically cancelled 141 | # 142 | # auto_cancel_exempted_doctypes = ["Auto Repeat"] 143 | 144 | 145 | # User Data Protection 146 | # -------------------- 147 | 148 | user_data_fields = [ 149 | { 150 | "doctype": "{doctype_1}", 151 | "filter_by": "{filter_by}", 152 | "redact_fields": ["{field_1}", "{field_2}"], 153 | "partial": 1, 154 | }, 155 | { 156 | "doctype": "{doctype_2}", 157 | "filter_by": "{filter_by}", 158 | "partial": 1, 159 | }, 160 | { 161 | "doctype": "{doctype_3}", 162 | "strict": False, 163 | }, 164 | { 165 | "doctype": "{doctype_4}" 166 | } 167 | ] 168 | 169 | # Authentication and authorization 170 | # -------------------------------- 171 | 172 | # auth_hooks = [ 173 | # "frappeauth_app.auth.validate" 174 | # ] 175 | 176 | -------------------------------------------------------------------------------- /frappeauth_app/modules.txt: -------------------------------------------------------------------------------- 1 | Frappeauth App -------------------------------------------------------------------------------- /frappeauth_app/patches.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mymi14s/frappeauth_app/d8cc65c55e5e02cba8c0655364309ab76127b1f1/frappeauth_app/patches.txt -------------------------------------------------------------------------------- /frappeauth_app/templates/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mymi14s/frappeauth_app/d8cc65c55e5e02cba8c0655364309ab76127b1f1/frappeauth_app/templates/__init__.py -------------------------------------------------------------------------------- /frappeauth_app/templates/pages/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mymi14s/frappeauth_app/d8cc65c55e5e02cba8c0655364309ab76127b1f1/frappeauth_app/templates/pages/__init__.py -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | License: MIT -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # frappe -- https://github.com/frappe/frappe is installed via 'bench init' -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | with open("requirements.txt") as f: 4 | install_requires = f.read().strip().split("\n") 5 | 6 | # get version from __version__ variable in frappeauth_app/__init__.py 7 | from frappeauth_app import __version__ as version 8 | 9 | setup( 10 | name="frappeauth_app", 11 | version=version, 12 | description="Frappe app for authentication, utilities", 13 | author="Anthony Emmanuel C.", 14 | author_email="mymi14s@hotmail.com", 15 | packages=find_packages(), 16 | zip_safe=False, 17 | include_package_data=True, 18 | install_requires=install_requires 19 | ) 20 | --------------------------------------------------------------------------------