Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pirates
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
pirates
Commits
de45e175
Commit
de45e175
authored
4 years ago
by
jan.bednarik
Browse files
Options
Downloads
Patches
Plain Diff
Update docs and release version 0.2.0
parent
dc0ff269
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+72
-0
72 additions, 0 deletions
README.md
pirates/urls.py
+5
-0
5 additions, 0 deletions
pirates/urls.py
setup.py
+1
-1
1 addition, 1 deletion
setup.py
with
78 additions
and
1 deletion
README.md
+
72
−
0
View file @
de45e175
# Pirates
Django app na uživatele, týmy a skupiny, s napojením na LDAP a SSO.
[

](https://github.com/psf/black)

## Použití
### Settings
Přidat
`pirates`
do
`INSTALLED_APPS`
.
### Modely
Jsou k dipozici abstraktní modely pro uživatele, tým a organizační skupinu. Ty
lze doplnit o další fieldy specifické pro aplikaci. Příklad:
```
python
from
django.db
import
models
from
pirates.models
import
AbstractUser
class
CustomUser
(
AbstractUser
):
is_friendly
=
models
.
BooleanField
(
default
=
True
)
```
A nezapomenout model pro uživatele nastavit v settings:
```
python
AUTH_USER_MODEL
=
"
myapp.CustomUser
"
```
### URLs
URL patterns (v současné době pouze pro OpenID Connect) jsou definovány v
`pirates.urls`
. Stačí je připojit k URL patterns projektu:
```
python
from
pirates.urls
import
urlpatterns
as
pirates_urlpatterns
urlpatterns
=
[
# URL patterns projektu
# ...
]
+
pirates_urlpatterns
```
### SSO přes OpenID Connect
Implementaci OpenID zajišťuje knihovna
[
mozilla-django-oidc
](
https://github.com/mozilla/mozilla-django-oidc
)
.
V settings projektu je třeba nastavit několik konfiguračních konstant a
autentifikační backend. Příklad settings (s využitím
[
django-environ
](
https://github.com/joke2k/django-environ
)
):
```
python
from
os.path
import
join
import
environ
env
=
environ
.
Env
()
AUTHENTICATION_BACKENDS
=
[
"
pirates.auth.PiratesOIDCAuthenticationBackend
"
]
OIDC_RP_CLIENT_ID
=
env
.
str
(
"
OIDC_RP_CLIENT_ID
"
)
OIDC_RP_CLIENT_SECRET
=
env
.
str
(
"
OIDC_RP_CLIENT_SECRET
"
)
OIDC_RP_REALM_URL
=
env
.
str
(
"
OIDC_RP_REALM_URL
"
)
OIDC_RP_SIGN_ALGO
=
"
RS256
"
OIDC_OP_JWKS_ENDPOINT
=
join
(
OIDC_RP_REALM_URL
,
"
protocol/openid-connect/certs
"
)
OIDC_OP_AUTHORIZATION_ENDPOINT
=
join
(
OIDC_RP_REALM_URL
,
"
protocol/openid-connect/auth
"
)
OIDC_OP_TOKEN_ENDPOINT
=
join
(
OIDC_RP_REALM_URL
,
"
protocol/openid-connect/token
"
)
OIDC_OP_USER_ENDPOINT
=
join
(
OIDC_RP_REALM_URL
,
"
protocol/openid-connect/userinfo
"
)
```
URL patterns pro OpenID Connect už jsou součástí
`pirates.urls`
(viz výše).
This diff is collapsed.
Click to expand it.
pirates/urls.py
+
5
−
0
View file @
de45e175
from
django.urls
import
include
,
path
urlpatterns
=
[
path
(
"
oidc/
"
,
include
(
"
mozilla_django_oidc.urls
"
)),
]
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
de45e175
...
...
@@ -13,7 +13,7 @@ def read(fname):
setup
(
name
=
"
pirates
"
,
version
=
"
0.
1
.0
"
,
version
=
"
0.
2
.0
"
,
license
=
"
MIT
"
,
description
=
"
Django app for users, teamds and groups.
"
,
long_description
=
read
(
"
README.md
"
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment