mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 15:27:47 -02:30
remove default app creation
This commit is contained in:
@@ -79,13 +79,13 @@ Content-Type: application/json
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Authorization using application of grant type `password`
|
## Authorization using application of grant type `password`
|
||||||
Suppose we have an application `curl for admin` with grant type `password`:
|
Suppose we have an application `Default Application` with grant type `password`:
|
||||||
```text
|
```text
|
||||||
{
|
{
|
||||||
"id": 6,
|
"id": 6,
|
||||||
"type": "application",
|
"type": "application",
|
||||||
...
|
...
|
||||||
"name": "curl for admin",
|
"name": "Default Application",
|
||||||
"user": 1,
|
"user": 1,
|
||||||
"client_id": "gwSPoasWSdNkMDtBN3Hu2WYQpPWCO9SwUEsKK22l",
|
"client_id": "gwSPoasWSdNkMDtBN3Hu2WYQpPWCO9SwUEsKK22l",
|
||||||
"client_secret": "fI6ZpfocHYBGfm1tP92r0yIgCyfRdDQt0Tos9L8a4fNsJjQQMwp9569eIaUBsaVDgt2eiwOGe0bg5m5vCSstClZmtdy359RVx2rQK5YlIWyPlrolpt2LEpVeKXWaiybo",
|
"client_secret": "fI6ZpfocHYBGfm1tP92r0yIgCyfRdDQt0Tos9L8a4fNsJjQQMwp9569eIaUBsaVDgt2eiwOGe0bg5m5vCSstClZmtdy359RVx2rQK5YlIWyPlrolpt2LEpVeKXWaiybo",
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
{% ifmeth POST %}
|
|
||||||
|
|
||||||
## DEPRICATED
|
|
||||||
|
|
||||||
# Generate an Auth Token
|
|
||||||
Make a POST request to this resource with `username` and `password` fields to
|
|
||||||
obtain an authentication token to use for subsequent requests.
|
|
||||||
|
|
||||||
Example JSON to POST (content type is `application/json`):
|
|
||||||
|
|
||||||
{"username": "user", "password": "my pass"}
|
|
||||||
|
|
||||||
Example form data to post (content type is `application/x-www-form-urlencoded`):
|
|
||||||
|
|
||||||
username=user&password=my%20pass
|
|
||||||
|
|
||||||
If the username and password provided are valid, the response will contain a
|
|
||||||
`token` field with the authentication token to use and an `expires` field with
|
|
||||||
the timestamp when the token will expire:
|
|
||||||
|
|
||||||
{
|
|
||||||
"token": "8f17825cf08a7efea124f2638f3896f6637f8745",
|
|
||||||
"expires": "2013-09-05T21:46:35.729Z"
|
|
||||||
}
|
|
||||||
|
|
||||||
Otherwise, the response will indicate the error that occurred and return a 4xx
|
|
||||||
status code.
|
|
||||||
|
|
||||||
For subsequent requests, pass the token via the HTTP `Authorization` request
|
|
||||||
header:
|
|
||||||
|
|
||||||
Authorization: Token 8f17825cf08a7efea124f2638f3896f6637f8745
|
|
||||||
|
|
||||||
The auth token is only valid when used from the same remote address and user
|
|
||||||
agent that originally obtained it.
|
|
||||||
|
|
||||||
Each request that uses the token for authentication will refresh its expiration
|
|
||||||
timestamp and keep it from expiring. A token only expires when it is not used
|
|
||||||
for the configured timeout interval (default 1800 seconds).
|
|
||||||
{% endifmeth %}
|
|
||||||
|
|
||||||
{% ifmeth DELETE %}
|
|
||||||
# Delete an Auth Token
|
|
||||||
A DELETE request with the token header set will cause the token to be
|
|
||||||
invalidated and no further requests can be made with it.
|
|
||||||
{% endifmeth %}
|
|
||||||
@@ -63,7 +63,6 @@ from wsgiref.util import FileWrapper
|
|||||||
from awx.main.tasks import send_notifications, handle_ha_toplogy_changes
|
from awx.main.tasks import send_notifications, handle_ha_toplogy_changes
|
||||||
from awx.main.access import get_user_queryset
|
from awx.main.access import get_user_queryset
|
||||||
from awx.main.ha import is_ha_environment
|
from awx.main.ha import is_ha_environment
|
||||||
# from awx.api.authentication import TokenGetAuthentication
|
|
||||||
from awx.api.filters import V1CredentialFilterBackend
|
from awx.api.filters import V1CredentialFilterBackend
|
||||||
from awx.api.generics import get_view_name
|
from awx.api.generics import get_view_name
|
||||||
from awx.api.generics import * # noqa
|
from awx.api.generics import * # noqa
|
||||||
@@ -187,7 +186,6 @@ class InstanceGroupMembershipMixin(object):
|
|||||||
|
|
||||||
class ApiRootView(APIView):
|
class ApiRootView(APIView):
|
||||||
|
|
||||||
# authentication_classes = []
|
|
||||||
permission_classes = (AllowAny,)
|
permission_classes = (AllowAny,)
|
||||||
view_name = _('REST API')
|
view_name = _('REST API')
|
||||||
versioning_class = None
|
versioning_class = None
|
||||||
@@ -212,7 +210,6 @@ class ApiRootView(APIView):
|
|||||||
|
|
||||||
class ApiOAuthAuthorizationRootView(APIView):
|
class ApiOAuthAuthorizationRootView(APIView):
|
||||||
|
|
||||||
# authentication_classes = []
|
|
||||||
permission_classes = (AllowAny,)
|
permission_classes = (AllowAny,)
|
||||||
view_name = _("API OAuth Authorization Root")
|
view_name = _("API OAuth Authorization Root")
|
||||||
versioning_class = None
|
versioning_class = None
|
||||||
@@ -222,13 +219,11 @@ class ApiOAuthAuthorizationRootView(APIView):
|
|||||||
data['authorize'] = drf_reverse('api:authorize')
|
data['authorize'] = drf_reverse('api:authorize')
|
||||||
data['token'] = drf_reverse('api:token')
|
data['token'] = drf_reverse('api:token')
|
||||||
data['revoke_token'] = drf_reverse('api:revoke-token')
|
data['revoke_token'] = drf_reverse('api:revoke-token')
|
||||||
# data['introspect'] = drf_reverse('api:introspect') #TODO: Add Introspect Endpoint
|
|
||||||
return Response(data)
|
return Response(data)
|
||||||
|
|
||||||
|
|
||||||
class ApiVersionRootView(APIView):
|
class ApiVersionRootView(APIView):
|
||||||
|
|
||||||
# authentication_classes = []
|
|
||||||
permission_classes = (AllowAny,)
|
permission_classes = (AllowAny,)
|
||||||
swagger_topic = 'Versioning'
|
swagger_topic = 'Versioning'
|
||||||
|
|
||||||
|
|||||||
@@ -594,7 +594,7 @@ class OAuth2ApplicationAccess(BaseAccess):
|
|||||||
|
|
||||||
class OAuth2TokenAccess(BaseAccess):
|
class OAuth2TokenAccess(BaseAccess):
|
||||||
'''
|
'''
|
||||||
I can read, change or delete an OAuth token when:
|
I can read, change or delete an OAuth2 token when:
|
||||||
- I am a superuser.
|
- I am a superuser.
|
||||||
- I am the admin of the organization of the user of the token.
|
- I am the admin of the organization of the user of the token.
|
||||||
- I am the user of the token.
|
- I am the user of the token.
|
||||||
|
|||||||
@@ -620,12 +620,12 @@ def create_access_token_user_if_missing(sender, **kwargs):
|
|||||||
post_save.connect(create_access_token_user_if_missing, sender=OAuth2AccessToken)
|
post_save.connect(create_access_token_user_if_missing, sender=OAuth2AccessToken)
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=User)
|
# @receiver(post_save, sender=User)
|
||||||
def create_default_oauth_app(sender, **kwargs):
|
# def create_default_oauth_app(sender, **kwargs):
|
||||||
if kwargs.get('created', False):
|
# if kwargs.get('created', False):
|
||||||
user = kwargs['instance']
|
# user = kwargs['instance']
|
||||||
OAuth2Application.objects.create(
|
# OAuth2Application.objects.create(
|
||||||
name='Default application for {}'.format(user.username),
|
# name='Default application for {}'.format(user.username),
|
||||||
user=user, client_type='confidential', redirect_uris='',
|
# user=user, client_type='confidential', redirect_uris='',
|
||||||
authorization_grant_type='password'
|
# authorization_grant_type='password'
|
||||||
)
|
# )
|
||||||
|
|||||||
Reference in New Issue
Block a user