Compare commits
No commits in common. "2ca56b6df7be4457fd4e9d1f717e09e2d79f598a" and "4498be544b054aa35d742bff347c62ba12789f7a" have entirely different histories.
2ca56b6df7
...
4498be544b
|
@ -22,6 +22,7 @@ HYDRA_PUBLIC_URL = 'http://127.0.0.1:4444'
|
||||||
SUBJECT_PREFIX = 'something random'
|
SUBJECT_PREFIX = 'something random'
|
||||||
|
|
||||||
OAUTH_ID = 'identiy_provider'
|
OAUTH_ID = 'identiy_provider'
|
||||||
|
OAUTH_SECRET = 'ThisIsNotSafe'
|
||||||
|
|
||||||
|
|
||||||
[LENTICULAR_CLOUD_SERVICES.jabber]
|
[LENTICULAR_CLOUD_SERVICES.jabber]
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
from secrets import token_hex
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from ory_hydra_client import Client
|
from ory_hydra_client import Client
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from ory_hydra_client.api.o_auth_2 import list_o_auth_2_clients, create_o_auth_2_client, set_o_auth_2_client
|
from ory_hydra_client.api.o_auth_2 import list_o_auth_2_clients, create_o_auth_2_client
|
||||||
from ory_hydra_client.models.o_auth_20_client import OAuth20Client
|
from ory_hydra_client.models.o_auth_20_client import OAuth20Client
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
class HydraService:
|
class HydraService:
|
||||||
|
|
||||||
|
@ -23,7 +19,7 @@ class HydraService:
|
||||||
self.set_hydra_client(Client(base_url=app.config['HYDRA_ADMIN_URL']))
|
self.set_hydra_client(Client(base_url=app.config['HYDRA_ADMIN_URL']))
|
||||||
|
|
||||||
client_name = app.config['OAUTH_ID']
|
client_name = app.config['OAUTH_ID']
|
||||||
client_secret = token_hex(16)
|
client_secret = app.config['OAUTH_SECRET']
|
||||||
|
|
||||||
clients = list_o_auth_2_clients.sync_detailed(_client=self.hydra_client).parsed
|
clients = list_o_auth_2_clients.sync_detailed(_client=self.hydra_client).parsed
|
||||||
if clients is None:
|
if clients is None:
|
||||||
|
@ -49,11 +45,6 @@ class HydraService:
|
||||||
ret = create_o_auth_2_client.sync(json_body=client, _client=self.hydra_client)
|
ret = create_o_auth_2_client.sync(json_body=client, _client=self.hydra_client)
|
||||||
if ret is None:
|
if ret is None:
|
||||||
raise RuntimeError("could not crate account")
|
raise RuntimeError("could not crate account")
|
||||||
else:
|
|
||||||
client.client_secret = client_secret
|
|
||||||
ret = set_o_auth_2_client.sync(id=client.client_id,json_body=client, _client=self.hydra_client)
|
|
||||||
if ret is None:
|
|
||||||
raise RuntimeError("could not crate account")
|
|
||||||
if type(client.client_id) is not str:
|
if type(client.client_id) is not str:
|
||||||
raise RuntimeError("could not parse client_id from ory-hydra")
|
raise RuntimeError("could not parse client_id from ory-hydra")
|
||||||
self.client_id = client.client_id
|
self.client_id = client.client_id
|
||||||
|
|
|
@ -92,7 +92,7 @@ def init_login_manager(app: Flask) -> None:
|
||||||
oauth2.register(
|
oauth2.register(
|
||||||
name="custom",
|
name="custom",
|
||||||
client_id=hydra_service.client_id,
|
client_id=hydra_service.client_id,
|
||||||
client_secret=hydra_service.client_secret,
|
client_secret=app.config['OAUTH_SECRET'],
|
||||||
server_metadata_url=f'{base_url}/.well-known/openid-configuration',
|
server_metadata_url=f'{base_url}/.well-known/openid-configuration',
|
||||||
access_token_url=f"{base_url}/oauth2/token",
|
access_token_url=f"{base_url}/oauth2/token",
|
||||||
authorize_url=f"{base_url}/oauth2/auth",
|
authorize_url=f"{base_url}/oauth2/auth",
|
||||||
|
|
|
@ -10,10 +10,6 @@ in
|
||||||
services.lenticular-cloud = {
|
services.lenticular-cloud = {
|
||||||
enable = mkEnableOption "lenticluar service enable";
|
enable = mkEnableOption "lenticluar service enable";
|
||||||
domain = mkOption {
|
domain = mkOption {
|
||||||
type = lib.types.str;
|
|
||||||
example = "example.com";
|
|
||||||
};
|
|
||||||
service_domain = mkOption {
|
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
example = "account.example.com";
|
example = "account.example.com";
|
||||||
};
|
};
|
||||||
|
@ -72,10 +68,10 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx.enable = true;
|
services.nginx.enable = true;
|
||||||
services.nginx.virtualHosts."${cfg.service_domain}" = {
|
services.nginx.virtualHosts."${cfg.domain}" = {
|
||||||
addSSL = true;
|
addSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
serverName = cfg.service_domain;
|
serverName = cfg.domain;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
recommendedProxySettings = true;
|
recommendedProxySettings = true;
|
||||||
proxyPass = "http://unix:/run/${username}/web.sock";
|
proxyPass = "http://unix:/run/${username}/web.sock";
|
||||||
|
|
Loading…
Reference in a new issue