Compare commits
3 commits
ec6ac443fb
...
127ea49d74
| Author | SHA1 | Date | |
|---|---|---|---|
| 127ea49d74 | |||
| 30e1fd23d6 | |||
| df517cfbfa |
6 changed files with 55 additions and 4 deletions
|
|
@ -94,3 +94,9 @@ class FarmOSHandler(GenericHandler):
|
|||
return f"{base}/{path}"
|
||||
|
||||
return base
|
||||
|
||||
def get_oauth2_client_id(self):
|
||||
return self.config.get("farmos.oauth2.client_id", default="farm")
|
||||
|
||||
def get_oauth2_scope(self):
|
||||
return self.config.get("farmos.oauth2.scope", default="farm_manager")
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class WuttaFarmMenuHandler(base.MenuHandler):
|
|||
{
|
||||
"title": "Eggs",
|
||||
"route": "quick.eggs",
|
||||
# "perm": "assets.list",
|
||||
"perm": "quick.eggs",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,28 @@
|
|||
</b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field grouped>
|
||||
|
||||
<b-field label="OAuth2 Client ID">
|
||||
<b-input name="farmos.oauth2.client_id"
|
||||
v-model="simpleSettings['farmos.oauth2.client_id']"
|
||||
@input="settingsNeedSaved = true">
|
||||
</b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field label="OAuth2 Scope">
|
||||
<b-input name="farmos.oauth2.scope"
|
||||
v-model="simpleSettings['farmos.oauth2.scope']"
|
||||
@input="settingsNeedSaved = true">
|
||||
</b-input>
|
||||
</b-field>
|
||||
|
||||
</b-field>
|
||||
|
||||
<b-field label="OAuth2 Redirect URI">
|
||||
<wutta-copyable-text text="${url('farmos_oauth_callback')}" />
|
||||
</b-field>
|
||||
|
||||
<b-field label="farmOS Integration Mode">
|
||||
<b-select name="${app.appname}.farmos_integration_mode"
|
||||
v-model="simpleSettings['${app.appname}.farmos_integration_mode']"
|
||||
|
|
|
|||
|
|
@ -55,9 +55,10 @@ class AuthView(base.AuthView):
|
|||
return None
|
||||
|
||||
def get_farmos_oauth2_session(self):
|
||||
farmos = self.app.get_farmos_handler()
|
||||
return OAuth2Session(
|
||||
client_id="farm",
|
||||
scope="farm_manager",
|
||||
client_id=farmos.get_oauth2_client_id(),
|
||||
scope=farmos.get_oauth2_scope(),
|
||||
redirect_uri=self.request.route_url("farmos_oauth_callback"),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -87,10 +87,20 @@ class CommonView(base.CommonView):
|
|||
"farmos_logs_medical.view",
|
||||
"farmos_logs_observation.list",
|
||||
"farmos_logs_observation.view",
|
||||
"farmos_plant_assets.list",
|
||||
"farmos_plant_assets.view",
|
||||
"farmos_plant_types.list",
|
||||
"farmos_plant_types.view",
|
||||
"farmos_quantities_standard.list",
|
||||
"farmos_quantities_standard.view",
|
||||
"farmos_quantity_types.list",
|
||||
"farmos_quantity_types.view",
|
||||
"farmos_structure_assets.list",
|
||||
"farmos_structure_assets.view",
|
||||
"farmos_structure_types.list",
|
||||
"farmos_structure_types.view",
|
||||
"farmos_units.list",
|
||||
"farmos_units.view",
|
||||
"farmos_users.list",
|
||||
"farmos_users.view",
|
||||
"group_assets.create",
|
||||
|
|
@ -121,6 +131,7 @@ class CommonView(base.CommonView):
|
|||
"logs_observation.list",
|
||||
"logs_observation.view",
|
||||
"logs_observation.versions",
|
||||
"quick.eggs",
|
||||
"structure_types.list",
|
||||
"structure_types.view",
|
||||
"structure_types.versions",
|
||||
|
|
|
|||
|
|
@ -57,10 +57,21 @@ class AppInfoView(base.AppInfoView):
|
|||
return info
|
||||
|
||||
def configure_get_simple_settings(self): # pylint: disable=empty-docstring
|
||||
farmos = self.app.get_farmos_handler()
|
||||
simple_settings = super().configure_get_simple_settings()
|
||||
simple_settings.extend(
|
||||
[
|
||||
{"name": "farmos.url.base"},
|
||||
{
|
||||
"name": "farmos.url.base",
|
||||
},
|
||||
{
|
||||
"name": "farmos.oauth2.client_id",
|
||||
"default": farmos.get_oauth2_client_id(),
|
||||
},
|
||||
{
|
||||
"name": "farmos.oauth2.scope",
|
||||
"default": farmos.get_oauth2_scope(),
|
||||
},
|
||||
{
|
||||
"name": f"{self.app.appname}.farmos_integration_mode",
|
||||
"default": self.app.get_farmos_integration_mode(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue