Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

App must set security headers to protect against clickjacking #1176

Closed
manasirfan opened this issue Jul 27, 2022 · 9 comments
Closed

App must set security headers to protect against clickjacking #1176

manasirfan opened this issue Jul 27, 2022 · 9 comments

Comments

@manasirfan
Copy link

manasirfan commented Jul 27, 2022

For bug reporting only! If you're posting a feature request or discussion, please ignore.

Expected Behavior

when am review our app from shopify that show this issue before submitting

There was an error installing your app. The app must be installed to perform the security check. We expected OAuth to be initiated at https://app-security.myshopify.com/admin/oauth/authorize but were redirected to https://mysite.com/login. Your app must request installation immediately after clicking "add app." Apps must request shop access during installation, or reinstallation if the app was previously uninstalled from the shop.

Current Behavior

this is my website first user login in our site
image

after login then user go this page and put store url and fetching the products against the store

image

But am not find what's the shopify app are required for approve the app

Failure Information

Please help provide information about the failure if this is a bug.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Step 1
  2. Step 2
  3. ...

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

*Package Version: v17.1
*Laravel Version: v8.75
*PHP Version: v8.1.5

Failure Logs

Please include any relevant log snippets or files here.

@manasirfan
Copy link
Author

Anyone can help me for solving this issue?.
Thanks in advance.

@enmaboya
Copy link
Contributor

You can take an implementation from here
#1178

but it has nothing to do with the package and can be exposed by the application.

@manasirfan
Copy link
Author

Hi, thanks for reply.
Am follow your steps but we changing in the vendor file, therefore changing not add on live please guide me more,
Thanks in advance !

@manasirfan
Copy link
Author

@enmaboya sir kindly help me !

@tanseercena
Copy link

@manasirfan You can check this: #1070 (comment)

I created the same and it fixed the issue.

I hope that this will help you :)

@manasirfan
Copy link
Author

hi @tanseercena am using the same middleware but again rejected, middleware used globally ,kindly solving this issue

protected const HEADER_FORMAT = 'frame-ancestors %s %s';
protected const ADMIN_SHOPIFY_URL = 'https://admin.shopify.com';
public function handle(Request $request, Closure $next)
{
$response = $next($request);
if ($response instanceof Response && !$request->ajax()) {
if ($request->has('shop')) {
$shopDomain = ShopDomain::fromNative($request->get('shop'));
}elseif ($request->user() instanceof User) {
$shopDomain = $request->user()->getDomain();

        }else{
            $shopDomain = ShopDomain::fromRequest($request);

        }

        if ($shopDomain instanceof ShopDomain) {
            $response->header('Content-Security-Policy', sprintf(self::HEADER_FORMAT,'https://'. $shopDomain->toNative(), self::ADMIN_SHOPIFY_URL));
        }

    }
    return $response;
}

@tanseercena
Copy link

@manasirfan Did you add it in web middlewares in Kernal.php?

@manasirfan
Copy link
Author

manasirfan commented Aug 5, 2022

@tanseercena oops am added another middleware not group,please check now its fine ?

 protected $middlewareGroups = [
        'web' => [ 
            \App\Http\Middleware\ContentSecurityPolicy::class,

        ]
];

@Kyon147
Copy link
Collaborator

Kyon147 commented Aug 26, 2022

We wll try and get #1178 into the next release which should help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants