Skip to content

Commit 97da26f

Browse files
author
maxim-lixakov
committed
[DOP-21268] - add docs
1 parent 40b33b8 commit 97da26f

File tree

8 files changed

+145
-4
lines changed

8 files changed

+145
-4
lines changed

docs/backend/auth/custom.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. _backend-auth-custom:
2+
3+
Custom Auth provider
4+
====================
5+
6+
You can implement custom auth provider by inheriting from class below and implementing necessary methods.
7+
8+
.. autoclass:: syncmaster.backend.providers.auth.AuthProvider
9+
:members:
10+
:member-order: bysource

docs/backend/auth/dummy.rst

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
.. _backend-auth-dummy:
2+
3+
Dummy Auth provider
4+
===================
5+
6+
Description
7+
-----------
8+
9+
This auth provider allows to sign-in with any username and password, and and then issues an access token.
10+
11+
After successful auth, username is saved to backend database. It is then used for creating audit records for any object change, see ``changed_by`` field.
12+
13+
Interaction schema
14+
------------------
15+
16+
.. dropdown:: Interaction schema
17+
18+
.. plantuml::
19+
20+
@startuml
21+
title DummyAuthProvider
22+
participant "Client"
23+
participant "Backend"
24+
25+
== POST v1/auth/token ==
26+
27+
activate "Client"
28+
alt Successful case
29+
"Client" -> "Backend" ++ : login + password
30+
"Backend" --> "Backend" : Password is completely ignored
31+
"Backend" --> "Backend" : Check user in internal backend database
32+
"Backend" -> "Backend" : Create user if not exist
33+
"Backend" -[#green]> "Client" -- : Generate and return access_token
34+
35+
else User is blocked
36+
"Client" -> "Backend" ++ : login + password
37+
"Backend" --> "Backend" : Password is completely ignored
38+
"Backend" --> "Backend" : Check user in internal backend database
39+
"Backend" x-[#red]> "Client" -- : 401 Unauthorized
40+
41+
else User is deleted
42+
"Client" -> "Backend" ++ : login + password
43+
"Backend" --> "Backend" : Password is completely ignored
44+
"Backend" --> "Backend" : Check user in internal backend database
45+
"Backend" x-[#red]> "Client" -- : 404 Not found
46+
end
47+
48+
== GET v1/namespaces ==
49+
50+
alt Successful case
51+
"Client" -> "Backend" ++ : access_token
52+
"Backend" --> "Backend" : Validate token
53+
"Backend" --> "Backend" : Check user in internal backend database
54+
"Backend" -> "Backend" : Get data
55+
"Backend" -[#green]> "Client" -- : Return data
56+
57+
else Token is expired
58+
"Client" -> "Backend" ++ : access_token
59+
"Backend" --> "Backend" : Validate token
60+
"Backend" x-[#red]> "Client" -- : 401 Unauthorized
61+
62+
else User is blocked
63+
"Client" -> "Backend" ++ : access_token
64+
"Backend" --> "Backend" : Validate token
65+
"Backend" --> "Backend" : Check user in internal backend database
66+
"Backend" x-[#red]> "Client" -- : 401 Unauthorized
67+
68+
else User is deleted
69+
"Client" -> "Backend" ++ : access_token
70+
"Backend" --> "Backend" : Validate token
71+
"Backend" --> "Backend" : Check user in internal backend database
72+
"Backend" x-[#red]> "Client" -- : 404 Not found
73+
end
74+
75+
deactivate "Client"
76+
@enduml
77+
78+
Configuration
79+
-------------
80+
81+
.. autopydantic_model:: syncmaster.backend.settings.auth.dummy.DummyAuthProviderSettings
82+
.. autopydantic_model:: syncmaster.backend.settings.auth.jwt.JWTSettings

docs/backend/auth/index.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. _backend-auth-providers:
2+
3+
Auth Providers
4+
==============
5+
6+
Syncmaster supports different auth provider implementations. You can change implementation via settings:
7+
8+
.. autopydantic_model:: keycloak.backend.settings.auth.AuthSettings
9+
10+
.. toctree::
11+
:maxdepth: 2
12+
:caption: Auth providers
13+
14+
dummy
15+
keycloak
16+
17+
.. toctree::
18+
:maxdepth: 2
19+
:caption: For developers
20+
21+
custom

docs/backend/auth/keycloak.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.. _backend-auth-ldap:
2+
3+
KeyCloak Auth provider
4+
==================
5+
6+
Description
7+
-----------
8+
9+
TODO:
10+
11+
Strategies
12+
----------
13+
14+
TODO:
15+
16+
Interaction schema
17+
------------------
18+
19+
TODO:
20+
21+
Basic configuration
22+
-------------------
23+
24+
.. autopydantic_model:: syncmaster.settings.auth.keycloak.KeycloakProviderSettings
25+
.. autopydantic_model:: syncmaster.settings.auth.jwt.JWTSettings
26+

docs/backend/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ To start backend server you need to execute following command:
123123

124124
.. code-block:: console
125125
126-
$ python -m horizon.backend --host 0.0.0.0 --port 8000
126+
$ python -m syncmaster.backend --host 0.0.0.0 --port 8000
127127
128128
After server is started and ready, open http://localhost:8000/docs.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
backend/install
1818
backend/architecture
19+
backend/auth/index
1920
backend/openapi
2021
backend/configuration/index
2122

syncmaster/backend/providers/auth/base_provider.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AuthProvider(ABC):
2020
@abstractmethod
2121
def setup(cls, app: FastAPI) -> FastAPI:
2222
"""
23-
This method is called by :obj:`horizon.backend.application_factory`.
23+
This method is called by :obj:`syncmaster.backend.application_factory`.
2424
2525
Here you should add dependency overrides for auth provider,
2626
and return new ``app`` object.
@@ -32,7 +32,7 @@ def setup(cls, app: FastAPI) -> FastAPI:
3232
3333
from fastapi import FastAPI
3434
from my_awesome_auth_provider.settings import MyAwesomeAuthProviderSettings
35-
from horizon.backend.dependencies import Stub
35+
from syncmaster.backend.dependencies import Stub
3636
3737
class MyAwesomeAuthProvider(AuthProvider):
3838
def setup(app):
@@ -63,7 +63,7 @@ async def get_current_user(self, access_token: Any, *args, **kwargs) -> User:
6363
6464
Returns
6565
-------
66-
:obj:`horizon.backend.db.models.User`
66+
:obj:`syncmaster.backend.db.models.User`
6767
Current user object
6868
"""
6969
...

0 commit comments

Comments
 (0)