Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADVAPP-363]: Introduce ability to log into knowledge portal #560

Merged
merged 17 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ APP_ENV=local
APP_KEY=
APP_DEBUG=true
LANDLORD_APP_URL=http://advisingapp.local
LANDLORD_APP_HOST=advisingapp.local
APP_URL=${LANDLORD_APP_URL}
SANCTUM_STATEFUL_DOMAINS=test.advisingapp.local
APP_FORCE_HTTPS=false
LANDLORD_API_KEY=

Expand All @@ -28,6 +30,7 @@ AUDIT_QUEUE_CONNECTION=redis
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_CONNECTION=tenant
SESSION_DOMAIN=.${LANDLORD_APP_HOST}

REDIS_HOST=redis
REDIS_PASSWORD=null
Expand Down
47 changes: 46 additions & 1 deletion _ide_helper_models.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ class IdeHelperTenant {}
* @property bool $working_hours_are_enabled
* @property bool $are_working_hours_visible_on_profile
* @property array|null $working_hours
* @property string|null $job_title
* @property string|null $pronouns_id
* @property bool $are_pronouns_visible_on_profile
* @property bool $default_assistant_chat_folders_created
Expand Down Expand Up @@ -502,6 +503,7 @@ class IdeHelperTenant {}
* @method static \Illuminate\Database\Eloquent\Builder|User whereIsEmailVisibleOnProfile($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereIsExternal($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereIsPhoneNumberVisibleOnProfile($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereJobTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereLocale($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereOfficeHours($value)
Expand Down Expand Up @@ -947,8 +949,10 @@ class IdeHelperAssistantChatFolder {}
*
* @property string $id
* @property string $assistant_chat_id
* @property string $message
* @property \AdvisingApp\Assistant\Services\AIInterface\Enums\AIChatMessageFrom $from
* @property string|null $message
* @property string|null $name
* @property array|null $function_call
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \AdvisingApp\Assistant\Models\AssistantChat $chat
Expand All @@ -958,8 +962,10 @@ class IdeHelperAssistantChatFolder {}
* @method static \Illuminate\Database\Eloquent\Builder|AssistantChatMessage whereAssistantChatId($value)
* @method static \Illuminate\Database\Eloquent\Builder|AssistantChatMessage whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|AssistantChatMessage whereFrom($value)
* @method static \Illuminate\Database\Eloquent\Builder|AssistantChatMessage whereFunctionCall($value)
* @method static \Illuminate\Database\Eloquent\Builder|AssistantChatMessage whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|AssistantChatMessage whereMessage($value)
* @method static \Illuminate\Database\Eloquent\Builder|AssistantChatMessage whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|AssistantChatMessage whereUpdatedAt($value)
* @mixin \Eloquent
*/
Expand Down Expand Up @@ -3241,6 +3247,35 @@ class IdeHelperOutboundDeliverable {}
class IdeHelperSubscription {}
}

namespace AdvisingApp\Portal\Models{
/**
* AdvisingApp\Portal\Models\PortalAuthentication
*
* @property Carbon|null $created_at
* @property string $id
* @property string|null $educatable_id
* @property string|null $educatable_type
* @property string|null $code
* @property \AdvisingApp\Portal\Enums\PortalType|null $portal_type
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $educatable
* @method static \AdvisingApp\Portal\Database\Factories\PortalAuthenticationFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|PortalAuthentication newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|PortalAuthentication newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|PortalAuthentication query()
* @method static \Illuminate\Database\Eloquent\Builder|PortalAuthentication whereCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|PortalAuthentication whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|PortalAuthentication whereEducatableId($value)
* @method static \Illuminate\Database\Eloquent\Builder|PortalAuthentication whereEducatableType($value)
* @method static \Illuminate\Database\Eloquent\Builder|PortalAuthentication whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|PortalAuthentication wherePortalType($value)
* @method static \Illuminate\Database\Eloquent\Builder|PortalAuthentication whereUpdatedAt($value)
* @mixin \Eloquent
*/
#[\AllowDynamicProperties]
class IdeHelperPortalAuthentication {}
}

namespace AdvisingApp\Prospect\Models{
/**
* AdvisingApp\Prospect\Models\Prospect
Expand All @@ -3262,6 +3297,10 @@ class IdeHelperSubscription {}
* @property string|null $phone
* @property string|null $address
* @property string|null $address_2
* @property string|null $address_3
* @property string|null $city
* @property string|null $state
* @property string|null $postal
* @property \Illuminate\Support\Carbon|null $birthdate
* @property string|null $hsgrad
* @property string|null $assigned_to_id
Expand Down Expand Up @@ -3318,8 +3357,10 @@ class IdeHelperSubscription {}
* @method static \Illuminate\Database\Eloquent\Builder|Prospect query()
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereAddress($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereAddress2($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereAddress3($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereAssignedToId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereBirthdate($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereCreatedById($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereDeletedAt($value)
Expand All @@ -3334,9 +3375,11 @@ class IdeHelperSubscription {}
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereLastName($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereMobile($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect wherePhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect wherePostal($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect wherePreferred($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereSmsOptOut($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereSourceId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereState($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereStatusId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Prospect withTrashed()
Expand Down Expand Up @@ -4312,6 +4355,8 @@ class IdeHelperProgram {}
* @property-read int|null $subscriptions_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \AdvisingApp\Task\Models\Task> $tasks
* @property-read int|null $tasks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Laravel\Sanctum\PersonalAccessToken> $tokens
* @property-read int|null $tokens_count
* @method static \AdvisingApp\StudentDataModel\Database\Factories\StudentFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|Student newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Student newQuery()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/*
<COPYRIGHT>

Copyright © 2016-2024, Canyon GBS LLC. All rights reserved.

Advising App™ is licensed under the Elastic License 2.0. For more details,
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.

Notice:

- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.

For more information or inquiries please visit our website at
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.

</COPYRIGHT>
*/

namespace AdvisingApp\Portal\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\AdvisingApp\Portal\Models\PortalAuthentication>
*/
class PortalAuthenticationFactory extends Factory
{
public function definition(): array
{
return [
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/*
<COPYRIGHT>

Copyright © 2016-2024, Canyon GBS LLC. All rights reserved.

Advising App™ is licensed under the Elastic License 2.0. For more details,
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.

Notice:

- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.

For more information or inquiries please visit our website at
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.

</COPYRIGHT>
*/

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class () extends Migration {
public function up(): void
{
Schema::create('portal_authentications', function (Blueprint $table) {
$table->uuid('id')->primary();

$table->string('educatable_id')->nullable();
$table->string('educatable_type')->nullable();
$table->string('code')->nullable();
$table->string('portal_type')->nullable();

$table->timestamps();

$table->index(['educatable_type', 'educatable_id']);
});
}
};
19 changes: 19 additions & 0 deletions app-modules/portal/routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@
</COPYRIGHT>
*/

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;
use AdvisingApp\Portal\Http\Middleware\EnsureKnowledgeManagementPortalIsEnabled;
use AdvisingApp\Portal\Http\Controllers\KnowledgeManagement\KnowledgeManagementPortalController;
use AdvisingApp\Portal\Http\Middleware\EnsureKnowledgeManagementPortalIsEmbeddableAndAuthorized;
use AdvisingApp\Portal\Http\Controllers\KnowledgeManagement\KnowledgeManagementPortalSearchController;
use AdvisingApp\Portal\Http\Controllers\KnowledgeManagement\KnowledgeManagementPortalArticleController;
use AdvisingApp\Portal\Http\Controllers\KnowledgeManagement\KnowledgeManagementPortalCategoryController;
use AdvisingApp\Portal\Http\Controllers\KnowledgeManagement\KnowledgeManagementPortalAuthenticateController;
use AdvisingApp\Portal\Http\Controllers\KnowledgeManagement\KnowledgeManagementPortalRequestAuthenticationController;

Route::prefix('api')
->middleware([
Expand All @@ -49,12 +53,27 @@
EnsureKnowledgeManagementPortalIsEmbeddableAndAuthorized::class,
])
->group(function () {
Route::middleware(['auth:sanctum'])->group(function () {
Route::get('/user', function (Request $request) {
return $request->user();
})->name('api.user.auth-check');
});

Route::prefix('portal/knowledge-management')
->name('portal.knowledge-management.')
->group(function () {
Route::get('/', [KnowledgeManagementPortalController::class, 'show'])
->middleware(['signed:relative'])
->name('define');

Route::post('/authenticate/request', KnowledgeManagementPortalRequestAuthenticationController::class)
->middleware(['signed:relative'])
->name('request-authentication');

Route::post('/authenticate/{authentication}', KnowledgeManagementPortalAuthenticateController::class)
->middleware(['signed:relative', EnsureFrontendRequestsAreStateful::class])
->name('authenticate.embedded');

Route::post('/search', [KnowledgeManagementPortalSearchController::class, 'get'])
->middleware(['signed:relative'])
->name('search');
Expand Down
9 changes: 8 additions & 1 deletion app-modules/portal/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,26 @@

use Illuminate\Support\Facades\Route;
use AdvisingApp\Portal\Livewire\RenderKnowledgeManagementPortal;
use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;
use AdvisingApp\Portal\Http\Middleware\EnsureKnowledgeManagementPortalIsEnabled;
use AdvisingApp\Portal\Http\Middleware\EnsureKnowledgeManagementPortalIsEmbeddableAndAuthorized;
use AdvisingApp\Portal\Http\Controllers\KnowledgeManagement\KnowledgeManagementPortalAuthenticateController;

Route::prefix('portals')
->name('portals.')
->name('portal.')
->middleware([
'web',
EnsureFrontendRequestsAreStateful::class,
])
->group(function () {
Route::middleware([
EnsureKnowledgeManagementPortalIsEnabled::class,
EnsureKnowledgeManagementPortalIsEmbeddableAndAuthorized::class,
])->group(function () {
Route::post('/knowledge-management/authenticate/{authentication}', KnowledgeManagementPortalAuthenticateController::class)
->middleware(['signed:relative', EnsureFrontendRequestsAreStateful::class])
->name('knowledge-management.authenticate');

Route::get('/knowledge-management', RenderKnowledgeManagementPortal::class)
->name('knowledge-management.show');
Route::get('/knowledge-management/categories/{category}', RenderKnowledgeManagementPortal::class)
Expand Down
6 changes: 4 additions & 2 deletions app-modules/portal/src/Actions/GeneratePortalEmbedCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public function handle(PortalType $portal): string
PortalType::KnowledgeManagement => (function () {
$scriptUrl = url('js/portals/knowledge-management/advising-app-knowledge-management-portal.js?');

$portalAccessUrl = route('portals.knowledge-management.show');
$portalAccessUrl = route('portal.knowledge-management.show');

$userAuthenticationUrl = route('api.user.auth-check');

$portalDefinitionUrl = URL::to(
URL::signedRoute(
Expand All @@ -69,7 +71,7 @@ public function handle(PortalType $portal): string
$apiUrl = route('portal.knowledge-management.define');

return <<<EOD
<knowledge-management-portal-embed url="{$portalDefinitionUrl}" access-url={$portalAccessUrl} search-url="{$portalSearchUrl}" app-url="{$appUrl}" api-url="{$apiUrl}"></knowledge-management-portal-embed>
<knowledge-management-portal-embed url="{$portalDefinitionUrl}" user-authentication-url={$userAuthenticationUrl} access-url={$portalAccessUrl} search-url="{$portalSearchUrl}" app-url="{$appUrl}" api-url="{$apiUrl}"></knowledge-management-portal-embed>
<script src="{$scriptUrl}"></script>
EOD;
})(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
<COPYRIGHT>

Copyright © 2016-2024, Canyon GBS LLC. All rights reserved.

Advising App™ is licensed under the Elastic License 2.0. For more details,
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.

Notice:

- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.

For more information or inquiries please visit our website at
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.

</COPYRIGHT>
*/

namespace AdvisingApp\Portal\Exceptions;

use Exception;

class EducatableIsNotAuthenticatable extends Exception {}
Loading