-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue: https://issues.redhat.com/browse/AAP-39611 Signed-off-by: Djebran Lezzoum <ldjebran@gmail.com>
- Loading branch information
Showing
20 changed files
with
343 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright Red Hat | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
def preprocessing_filter_spec(endpoints): | ||
filtered = [] | ||
for path, path_regex, method, callback in endpoints: | ||
# do not add internal endpoints to schema | ||
if not path.startswith("/api/v1/service-index"): | ||
filtered.append((path, path_regex, method, callback)) | ||
return filtered |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from ansible_base.resource_registry.registry import ( | ||
ResourceConfig, | ||
ServiceAPIConfig, | ||
SharedResource, | ||
) | ||
from ansible_base.resource_registry.shared_types import UserType | ||
from ansible_base.resource_registry.utils.resource_type_processor import ( | ||
ResourceTypeProcessor, | ||
) | ||
from django.contrib.auth import get_user_model | ||
|
||
|
||
class UserProcessor(ResourceTypeProcessor): | ||
def pre_serialize_additional(self): | ||
# These fields aren't supported in app, so we'll set them to blank | ||
setattr(self.instance, "external_auth_provider", None) | ||
setattr(self.instance, "external_auth_uid", None) | ||
setattr(self.instance, "organizations", []) | ||
setattr(self.instance, "organizations_administered", []) | ||
|
||
return self.instance | ||
|
||
|
||
class APIConfig(ServiceAPIConfig): | ||
custom_resource_processors = {"shared.user": UserProcessor} | ||
service_type = "lightspeed" | ||
|
||
|
||
RESOURCE_LIST = [ | ||
ResourceConfig( | ||
get_user_model(), | ||
shared_resource=SharedResource(serializer=UserType, is_provider=False), | ||
name_field="username", | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from ansible_base.jwt_consumer.common.auth import JWTAuthentication | ||
|
||
|
||
class LightspeedJWTAuthentication(JWTAuthentication): | ||
|
||
def authenticate(self, request): | ||
userdata = super().authenticate(request) | ||
if userdata: | ||
user, _ = userdata | ||
user.aap_user = True | ||
user.save() | ||
return userdata |
38 changes: 38 additions & 0 deletions
38
...i_connect/users/migrations/0015_alter_user_email_alter_user_external_username_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 4.2.18 on 2025-02-11 09:03 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("users", "0014_user_rh_internal_user"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="user", | ||
name="email", | ||
field=models.CharField(default=None, max_length=150, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name="user", | ||
name="external_username", | ||
field=models.CharField(default="", max_length=150), | ||
), | ||
migrations.AlterField( | ||
model_name="user", | ||
name="family_name", | ||
field=models.CharField(default=None, max_length=150, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name="user", | ||
name="given_name", | ||
field=models.CharField(default=None, max_length=150, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name="user", | ||
name="name", | ||
field=models.CharField(default=None, max_length=150, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2.18 on 2025-02-17 08:27 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("users", "0015_alter_user_email_alter_user_external_username_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="user", | ||
name="aap_user", | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.