Laravel Backpack - separate from admin and normal user after login redirect path - laravel-backpack

What I did
after I successful login the admin user, I visit again to /admin/login, it redirect to /,
even after login user access to /admin/login, it should be redirect to /admin, I do not want to access RouteServiceProvider::HOME, how to detect two different user session?
What I expected to happen
I expect to redirect to "home_link" location 'admin/dashboard'
What happened
It redirect to /
What I've already tried to fix it
I install Laravel/Breeze, I can set it from the RouteServiceProvider
public const HOME = '/';
But it want to separate from admin and normal user, How can I set the it path?
Backpack, Laravel, PHP, DB version
When I run php artisan backpack:version the output is:
PHP VERSION:
PHP 7.4.12 (cli) (built: Oct 29 2020 18:37:21) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.12, Copyright (c), by Zend Technologies
LARAVEL VERSION:
v8.12.3#6707480c5f0db7aa07537f9ad93255b64b65b85e
BACKPACK VERSION:
4.1.26#ae68ca24844929ac38d2e792197551e823c43570

As response from:
https://github.com/Laravel-Backpack/CRUD/issues/3353#issuecomment-734454506
under /app/Http/Middleware/RedirectIfAuthenticated.php
I added a check for a guard 'backpack', then redirect to admin dashboard.
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
if($guard == 'backpack')
return redirect('/admin/dashboard');
return redirect(RouteServiceProvider::HOME);
}
}

Related

Keycloak.js can not get access token when login with Google and Facebook

I'm build a system for our company using Keycloak. I use keycloak.js for by-pass default login page of Keycloak.
function myFunction() {
let kcLogin = keycloak.login;
keycloak.login = (options) => {
options.idpHint = 'facebook';
kcLogin(options).then(auth => {
alert("keycloak Login");
if(auth) {
alert("token" + kc.token);
} else {
alert("auth is null");
}
});
};
keycloak.init({ onLoad: 'login-required' }).then(function(authenticated) {
alert(authenticated ? 'authenticated' : 'not authenticated');
}).catch(function() {
alert('failed to initialize');
});
}
But I can NOT get access token / refresh token after login.
I check: keycloak.token = undefined.
Please help me!
PS: I always get exception of keycloak.init then redirect to facebook login ( or google login )
alert('failed to initialize');
Thank you so much.
Code here: https://github.com/loizenai/SpringBoot-Keycloak-Social-Authentication-Py-Pass-Default-Login/tree/main/SpringBootKeyCloakSocialSignIn
You are trying to configure your backend and frontend with Keycloak.
Either you just have to configure your backend to integrate with your keycloak or Integration your frontend application and your backend will only verify the token.
The current application architecture you are following is an MVC pattern.
Where your spring boot(backend) application controls the integration with Keycloak.
Please refer to this article: Secure spring boot 2 using Keycloak
What you are trying to target follows this kind of architecture pattern:
Secure Vue.js apps with Keycloak | DevNation Tech Talk
In the above reference, I have used the Vue application but you can use your vanilla html/js application as well to integrate with keycloak.
First, try keycloak login flow in your application and then you can enable social login.

Unexpectedly redirecting to root address when request URL has special character in it

I'm facing the issue after upgrading server to RHEL 8.
Here is a php script I wrote to fetch the param:
<?php
if (isset($_GET)) {
echo $_GET['data'];
}
Now:
When I request to the server like: https://example.com?data=test
It prints 'test' perfectly
But, when I request to the server like: https://example.com?data="<title>test</title>"
It redirects to https://example.com and print nothing
Can anyone suggest a solution?

.NET Core Facebook - "Please make sure your redirect_uri is identical"

I'm out of ideas. I have a .NET Core 2.1 web app using Facebook Login. Facebook Login worked just fine until I upgraded from .NET Core 1.1 to 2.1. This works fine locally (localhost), but fails on our staging server (Apache on CentOS, EC2).
Our Facebook Login redirect URI is set up correctly in the Facebook app's login settings: http://example.com/ and https://example.com/ (see screenshot below).
What's interesting is in our .NET Core 1.1 branch, the request to http://example.com/signin-facebook?code=SOME_CODE shows up in the log once. In our .NET Core 2.1 branch, the request shows up twice, back-to-back.
Any idea how to dig more into the Facebook middleware that IdentifyFramework is using under the hood?
Facebook Login Settings:
Debug Log:
.NET Core 2.1.802, CentOS (Linux), EC2 instance
// debug ouput
AuthenticationScheme: Facebook was challenged.
Executed action Foobar.Controllers.AccountController.FacebookLogin
Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 2.1144ms 302
Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://example.com/signin-facebook?code=SOME_LONG_CODE
Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://example.com/signin-facebook?code=SOME_LONG_CODE
Error from RemoteAuthentication: OAuth token endpoint failure: Status: InternalServerError;
Headers: WWW-Authenticate: OAuth "Facebook Platform" "invalid_code"
"Error validating verification code.
Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request"
Error from RemoteAuthentication: OAuth token endpoint failure: Status: InternalServerError;
Headers: WWW-Authenticate: OAuth "Facebook Platform" "invalid_code"
facebook-api-version: v2.12

Magento 2 vhost plesk 17 multi store multi website

I am trying to configure the multi site of magento 2.1.3
Here is the configuration: Plesk Onyx 17.0.17 (CentOS Linux 7.3.1611 (Core)) Magento 2.1.3
I followed the tutorial:
Magento + base url etc ..
Ln -s /var/www/vhosts/domain.com/httpdocs /var/www/vhosts/store2.com/symlink
Chown -h store2: psacln /var/www/vhosts/store2.com/symlink
On plesk: open_basedir on store2.com: /var/www/vhosts/store2.com/symlink:/var/www/vhosts/domain.com/httpdocs:/tmp and directory symlink
But I get: AH00037: Symbolic link not allowed or link not accessible: /var/www/vhosts/store2.com/symlink
Lrwxrwxrwx 1 user psacln 40 Feb 7, 18:55 /var/www/vhosts/store2.com/symlink -> /var/www/vhosts/domain.com/httpdocs
user is the user of the store2
An idea ?
Thanks ALL
Don't allow user of one subscription access to another subscription (at least it's a security violation). Move everything into one subscription.

can I start Lync 2010 client application using the Lync 2010 SDK

in cases where I am using Lync 2010 SDK (which depends on having the Lync 2010 client being installed and operational) in a web application and that client is closed, can I using the Lync 2010 SDK to start client application ?
You can do without using Lync SDK,
Instead you can try out this
bool isRunning = Process.GetProcessesByName("Communicator")
.FirstOrDefault(p => p.MainModule.FileName.StartsWith(#"C:\Program Files (x86)\Microsoft Lync")) != default(Process);
if(!isRunning)
Process.Start("Communicator");
May be this will be helpfull to you.
thnks and regards.
If you have Lync setup for suppressed mode then you can call the BeginInitialize method on the LyncClient object to start up Lync in suppressed mode (aka no user interface).
This documentation describes the BeginInitialize method. Below is an example in C#:
LyncClient lyncClient = LyncClient.GetClient();
if (lyncClient.InSuppressedMode &&
lyncClient.State == ClientState.Uninitialized)
{
lyncClient.BeginInitialize(result => lyncClient.EndInitialize(result),
"Starting Lync");
}