Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
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
Container Registry
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
AURA
steering
Commits
77f16e10
Commit
77f16e10
authored
3 years ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
Fix indentation
parent
fa40a03c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/management/commands/create_oidc_client.py
+19
-18
19 additions, 18 deletions
program/management/commands/create_oidc_client.py
with
19 additions
and
18 deletions
program/management/commands/create_oidc_client.py
+
19
−
18
View file @
77f16e10
...
@@ -8,34 +8,35 @@ from oidc_provider.models import Client, ResponseType
...
@@ -8,34 +8,35 @@ from oidc_provider.models import Client, ResponseType
class
Command
(
BaseCommand
):
class
Command
(
BaseCommand
):
help
=
'
Sets up an OIDC client / relaying party. For details check out the
'
+
\
help
=
'
Sets up an OIDC client / relaying party. For details check out the
'
+
\
'
section on Relying Parties at https://django-oidc-provider.readthedocs.io
'
'
section on Relying Parties at https://django-oidc-provider.readthedocs.io
'
def
add_arguments
(
self
,
parser
):
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'
name
'
,
type
=
str
,
parser
.
add_argument
(
'
name
'
,
type
=
str
,
help
=
'
A label that you associate with this client
'
)
help
=
'
A label that you associate with this client
'
)
parser
.
add_argument
(
'
client_type
'
,
type
=
str
,
choices
=
[
'
public
'
,
'
confidential
'
],
parser
.
add_argument
(
'
client_type
'
,
type
=
str
,
choices
=
[
'
public
'
,
'
confidential
'
],
help
=
'
The type of client can be either public or confidential
'
)
help
=
'
The type of client can be either public or confidential
'
)
parser
.
add_argument
(
'
--client-id
'
,
type
=
int
,
dest
=
'
client_id
'
,
action
=
'
store
'
,
help
=
'
The client ID
'
)
parser
.
add_argument
(
'
--client-id
'
,
type
=
int
,
dest
=
'
client_id
'
,
action
=
'
store
'
,
help
=
'
The client ID
'
)
parser
.
set_defaults
(
client_id
=
None
)
parser
.
set_defaults
(
client_id
=
None
)
parser
.
add_argument
(
'
--client-secret
'
,
type
=
str
,
dest
=
'
client_secret
'
,
action
=
'
store
'
,
help
=
'
The client secret
'
)
parser
.
add_argument
(
'
--client-secret
'
,
type
=
str
,
dest
=
'
client_secret
'
,
action
=
'
store
'
,
help
=
'
The client secret
'
)
parser
.
set_defaults
(
client_secret
=
None
)
parser
.
set_defaults
(
client_secret
=
None
)
parser
.
add_argument
(
'
--no-require-consent
'
,
dest
=
'
require_consent
'
,
action
=
'
store_false
'
,
parser
.
add_argument
(
'
--no-require-consent
'
,
dest
=
'
require_consent
'
,
action
=
'
store_false
'
,
help
=
'
By default user consent is required. Use this to skip user consent.
'
)
help
=
'
By default user consent is required. Use this to skip user consent.
'
)
parser
.
add_argument
(
'
--no-reuse-consent
'
,
dest
=
'
reuse_consent
'
,
action
=
'
store_false
'
,
parser
.
add_argument
(
'
--no-reuse-consent
'
,
dest
=
'
reuse_consent
'
,
action
=
'
store_false
'
,
help
=
'
By default user consent will be reused. Use this if the user should provide consent on every login.
'
)
help
=
'
By default user consent will be reused. Use this if the user should provide consent on every login.
'
)
parser
.
set_defaults
(
require_consent
=
True
,
reuse_consent
=
True
)
parser
.
set_defaults
(
require_consent
=
True
,
reuse_consent
=
True
)
parser
.
add_argument
(
'
-u
'
,
'
--redirect-uri
'
,
type
=
str
,
action
=
'
append
'
,
parser
.
add_argument
(
'
-u
'
,
'
--redirect-uri
'
,
type
=
str
,
action
=
'
append
'
,
help
=
'
Redirect URI after successful authentication. Can be used more than once.
'
)
help
=
'
Redirect URI after successful authentication. Can be used more than once.
'
)
parser
.
add_argument
(
'
-p
'
,
'
--post-logout-redirect
'
,
type
=
str
,
action
=
'
append
'
,
parser
.
add_argument
(
'
-p
'
,
'
--post-logout-redirect
'
,
type
=
str
,
action
=
'
append
'
,
help
=
'
Post logout redirect URI. Can be used more than once.
'
)
help
=
'
Post logout redirect URI. Can be used more than once.
'
)
parser
.
add_argument
(
'
-s
'
,
'
--scope
'
,
type
=
str
,
action
=
'
append
'
,
parser
.
add_argument
(
'
-s
'
,
'
--scope
'
,
type
=
str
,
action
=
'
append
'
,
help
=
'
Authorized scope values for this client. Can be used more than once.
'
)
help
=
'
Authorized scope values for this client. Can be used more than once.
'
)
parser
.
add_argument
(
'
-r
'
,
dest
=
'
response_types
'
,
action
=
'
append
'
,
parser
.
add_argument
(
'
-r
'
,
dest
=
'
response_types
'
,
action
=
'
append
'
,
choices
=
[
'
code
'
,
'
id_token
'
,
'
id_token token
'
,
'
code token
'
,
'
code id_token
'
,
'
code id_token token
'
],
choices
=
[
'
code
'
,
'
id_token
'
,
'
id_token token
'
,
'
code token
'
,
'
code id_token
'
,
help
=
'
The type of response the client will get.
'
)
'
code id_token token
'
],
help
=
'
The type of response the client will get.
'
)
parser
.
add_argument
(
'
-i
'
,
'
--id-only
'
,
dest
=
'
id_only
'
,
action
=
'
store_true
'
,
parser
.
add_argument
(
'
-i
'
,
'
--id-only
'
,
dest
=
'
id_only
'
,
action
=
'
store_true
'
,
help
=
'
Do not print anything else then the ID of the newly created client
'
+
\
help
=
'
Do not print anything else then the ID of the newly created client
'
+
\
'
(and the client secret in case of confidential clients).
'
)
'
(and the client secret in case of confidential clients).
'
)
parser
.
set_defaults
(
id_only
=
False
)
parser
.
set_defaults
(
id_only
=
False
)
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
...
@@ -50,8 +51,8 @@ class Command(BaseCommand):
...
@@ -50,8 +51,8 @@ class Command(BaseCommand):
client_id
=
random
.
randint
(
100000
,
999999
)
client_id
=
random
.
randint
(
100000
,
999999
)
counter
+=
1
counter
+=
1
if
counter
>
10000
:
if
counter
>
10000
:
raise
CommandError
(
'
Could not find a free client_id. Already
'
+
\
raise
CommandError
(
'
Could not find a free client_id. Already
'
+
'
tried 10000 times. There seems to be something seriously
'
+
\
'
tried 10000 times. There seems to be something seriously
'
+
'
wrong with your setup. Please inspect manually.
'
)
'
wrong with your setup. Please inspect manually.
'
)
try
:
try
:
Client
.
objects
.
get
(
client_id
=
client_id
)
Client
.
objects
.
get
(
client_id
=
client_id
)
...
@@ -87,8 +88,8 @@ class Command(BaseCommand):
...
@@ -87,8 +88,8 @@ class Command(BaseCommand):
)
)
c
.
save
()
c
.
save
()
except
:
except
:
raise
CommandError
(
'
Could not create an OpenID connect client
'
+
\
raise
CommandError
(
'
Could not create an OpenID connect client
'
+
f
'
due to the following error:
{
sys
.
exc_info
()
}
'
)
f
'
due to the following error:
{
sys
.
exc_info
()
}
'
)
if
options
[
'
response_types
'
]:
if
options
[
'
response_types
'
]:
try
:
try
:
...
@@ -96,8 +97,8 @@ class Command(BaseCommand):
...
@@ -96,8 +97,8 @@ class Command(BaseCommand):
r
=
ResponseType
.
objects
.
get
(
value
=
r_value
)
r
=
ResponseType
.
objects
.
get
(
value
=
r_value
)
c
.
response_types
.
add
(
r
)
c
.
response_types
.
add
(
r
)
except
:
except
:
raise
CommandError
(
'
Client was stored, but could not set response_types
'
+
\
raise
CommandError
(
'
Client was stored, but could not set response_types
'
+
f
'
due to the following error:
{
sys
.
exc_info
()
}
'
)
f
'
due to the following error:
{
sys
.
exc_info
()
}
'
)
if
show_results
:
if
show_results
:
if
options
[
"
id_only
"
]:
if
options
[
"
id_only
"
]:
...
...
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