Giter VIP home page Giter VIP logo

samples-php's Introduction

PHP Sample Applications for Okta

NOTICE: We're excited about the acquisition of Auth0 to bring you better support in PHP. This repo will be placed into security patch only mode and we will not be adding any further features. If you are looking for an API that is not supported in this library, please call the API directly. Our documentation for the supported Management APIs are located here: https://developer.okta.com/docs/reference/core-okta-api/. Please reach out to the DevForum for any questions.

This repository contains several sample applications that demonstrate various Okta use-cases in your PHP application.

Please find the sample that fits your use-case from the table below.

Sample Description
Okta-Hosted Login A PHP application that will redirect the user to the Okta-Hosted login page of your Org for authentication. The user is redirected back to the PHP application after authenticating.
Custom Login Page A PHP application that uses the Okta Sign-In Widget within the PHP application to authenticate the user.
Resource Server This is a sample API resource server that shows you how to authenticate requests with access tokens that have been issued by Okta.

Requirements

These samples require a few items from you. First, you will need to have a system that can run PHP 7.0+. Websites should be able to be hosted on localhost:8080 and your user should have access to run the command php -S localhost:8080. You will not have to manually run this, but the command you do run in the sample will ultimately run this for you.

We depend on other packages to have the samples run. To install these dependencies, we will be using composer. You can get information on how to install this and run it at their website.

samples-php's People

Contributors

bjr-okta avatar bretterer avatar dependabot[bot] avatar ivanezeigbo-okta avatar oktauploader-okta avatar vijetmahabaleshwar-okta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

samples-php's Issues

Filesystem loader isn't found.

So far, I've been able to do everything up through accessing the login page...
Now, I'm getting issues when starting the okta hosted and custom login.

$ composer server:start
> php -S 127.0.0.1:8080 -t ./ ./index.php
[Mon Dec  7 09:59:01 2020] PHP 7.4.3 Development Server (http://127.0.0.1:8080) started

Good, right? Now I go to localhost:8080 only to find that the page has no content, just some HTML and Body tags. I also get some of this in the terminal:

[Mon Dec  7 10:03:12 2020] 127.0.0.1:39470 Accepted
[Mon Dec  7 10:03:12 2020] PHP Fatal error:  Uncaught Error: Class 'Twig_Loader_Filesystem' not found in /path/to/samples-php-develop/okta-hosted-login/index.php:20
Stack trace:
#0 {main}
  thrown in /path/to/samples-php-develop/okta-hosted-login/index.php on line 20
[Mon Dec  7 10:03:12 2020] 127.0.0.1:39470 Closing

Running on Ubuntu 20.04

Wrong Object Type for Keys

I may be doing something wrong but I ran into an issue with the jwt-verifier where it didn't like the object type being passed in. I'm running PHP 7.4 which may be stricter.

vendor/okta/jwt-verifier/src/JwtVerifier.php

$keys = $this->adaptor->getKeys($this->metaData->jwks_uri);

        foreach($keys as $id => $key) {
            $keys[$id] = new Key($key, 'RS256');
        }
        $decoded =  $this->adaptor->decode($jwt, $keys);

If I don't convert the items explicitly to the Key type I get an error because the array is a list of: OpenSSL key resource

Which seems to be coming from the use of

openssl_pkey_get_public

which is in

vendor/okta/jwt-verifier/src/Adaptors/FirebasePhpJwt.php

in the parseKey function

simple issue when run on localhost.

when I click login button.
it shows this error
HP Fatal error: Uncaught Error: Call to undefined function Jose\KeyConverter\gmp_strval()
and if I refresh,
it shows this message
Could not exchange code for an access token

Debuging "Error fetching access token"

Hello,

I'm not actually a PHP developer, but I'm just trying to help my team.

After the OKTA login successful, we receive the message from the title of this issue.

if(!isset($response->access_token)) {
        die('Error fetching access token');
}

If you are in this situation, on what you should look first? Or how you debug this?

In any case, is it possible that the metadata url of OKTA has been changed recently?

Regards.

/vendor/autoload.php

when i am start to using your recommended simple php file then i have found error failed to open stream: No such file or directory "/vendor/autoload.php"

Redirecting to 404 error on custom login

Hi!

Just wondering if you could please point me in the right direction?
I'm consistently being redirected to a 404 error page on my dev-xxxx-admin.oktapreview.com.
The app loads successfully, I click "login" and am redirected to a login prompt. This correctly stops me if incorrect, but if the credentials are correct I see a 404 error with an attempt at accessing the callback url.

This 404 url ends with scope=openid email
which is encoded with a %2520 in the space.
This appears to be breaking the callback page.

Any advice?

Thanks!

Tutorial is incompatible with default authorization servers - okta-hosted-login

https://github.com/okta/samples-php/tree/develop/okta-hosted-login

This tutorial uses a default authorization server, which works in a free okta dev account. However it depends on okta-jwt-verifier-php which is incompatible with default authorization server in a production account.

It is unclear to me how that is possible, but I am looking for a recommendation on how to set up authentication with OIDC, OKTA, PHP, and the default authorization server, in a production environment.

Can you point me to documentation, or a code example that will work for my use case?

Thanks,
Aidan.

Verification of JWT failed

I'm getting this error when I'm trying to test the examples on Windows 10.

My setup is:
Apache 2.4
PHP 7.4.9

Any ideas why this is happening?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.