Painless OAuth 2.0 Server for CodeIgniter 4 🔥

Overview

Heimdall


Code Quality Maintainability Build Codacy Security Scan Releases Minimum PHP version Issues License


Inspired from the Norse mythology, Heimdallr, modernly anglicized as Heimdall is the gatekeeper of Bifröst, the rainbow road connecting Midgard, realm of the humans, to Asgard, the realm of Gods.

In CodeIgniter 4, Heimdall serves as the gatekeeper between the client and resource server. Heimdall gives you an out of the box OAuth 2 authorization protocol implementation to your CodeIgniter's Web Service. Heimdall also comes with some handy extensions such as Open ID Connect support to gives you a simple identity layer on top of the OAuth 2 protocol and a Proof Key for Code Exchange support.

Heimdall implements the standards compliant implementation of an OAuth 2 authorization server written in PHP which makes working with OAuth 2 trivial. You can easily configure an OAuth 2 server to protect your API with access tokens, or allow clients to request new access tokens and refresh them.

This library was created in order to simplify the need of OAuth 2 implementation in your CodeIgniter 4 framework, based on the OAuth 2.0 Server library by thephpleague.

Latest version

See the latest version of Heimdall here.


✍️ Installation

In order to install Heimdall, you have to use Composer.

In the root directory of your CodeIgniter 4 project, fire up a terminal and run:

composer require ezralazuardy/heimdall

Heimdall is now ready to be configured and run in your server.


🚀️ Getting Started

In order to start configuring & implementing Heimdall in your CodeIgniter 4 project, please refer to the documentation.


📖️ Documentation

Read the Heimdall documentation here.


👷️ Contributing

All contributions are welcomed. Please make a pull request so that I can review your changes.

Before start making contributions to Heimdall, please read the contribution guidelines and code of conduct.


🛡️ Security Policy

Read the current Heimdall's security policy here.


🗒️ Side Note

Heimdall is at it's early stage. If you experiencing an error or bug, please report by creating a new issues.


📜 License

Comments
  • Add license scan report and status

    Add license scan report and status

    Your FOSSA integration was successful! Attached in this PR is a badge and license report to track scan status in your README.

    Below are docs for integrating FOSSA license checks into your CI:

    opened by fossabot 3
  • Bugfixes & 1 Enhancement

    Bugfixes & 1 Enhancement

    Using PHP 7.4.12 And CodeIgniter 4.1.1 2 Functionality breaking errors: FIX For "Declaration of Heimdall\Http\Headers::normalizeKey($key) must be compatible with Heimdall\Interfaces\Http\HeadersInterface::normalizeKey($key)" Error FIX For "Return value of Heimdall\Server\HeimdallAuthorizationServer::return() must be an instance of CodeIgniter\HTTP\Response, none returned" Error

    Did follow execution order as best i could but it seems current resource server implementation only validates token, it should return or pass some data to main controller, currently (CI 4.1.1) viable through request header data or global data. By phpleague's docs 'resource server' should return some header attributes but it looks like codeigniter does not support that and is using PSR4, maybe this workaround is not good but i believe it is one of essential functions of this library. ENHANCEMENT "If the access token is valid then attributes as per phpleague's oauth2 docs will be accessible via $this->request->header('authorization')->getValue()"

    opened by klAvAx 3
  • Fix Client Credentials Grant

    Fix Client Credentials Grant

    When you create a Authorization Server using the withClientCredentialsGrant function builder. See https://heimdall.ezralazuardy.com/documentation/client-credentials-grant Error is:

    "title": "Heimdall\\Exception\\HeimdallConfigException",
    "type": "Heimdall\\Exception\\HeimdallConfigException",
    "code": 500,
    "message": "Unknown Heimdall grant type, please recheck your parameter.",
    "file": "vendor/ezralazuardy/heimdall/src/Heimdall.php",
    "line": 56,
    
    enhancement 
    opened by gitHusband 3
  • Suggestion on improvement for PKCE Documentation.

    Suggestion on improvement for PKCE Documentation.

    There seems to be some readability issue or a mistake on the PKCE page (https://heimdall.ezralazuardy.com/documentation/pkce)

    The section labeled Creating code_verifier seems to be talking about code_challenge and the later section labeled Creating code_challenge seemed to be talking about code_verifier. So the titles should be updated to reflect their respective sections.

    Another thing to note here is during my testing: code_verifier seems to be a plain string rather than encrypted SHA-256 by default. So a note should be included for those trying out the PKCE method.

    Also, it would be worth noting on the top of the PKCE documentation that the flag of is_confidential has to be set to false for the PKCE to take effect.

    documentation 
    opened by Dhavalc2012 2
  • Update steverhoades/oauth2-openid-connect-server requirement from ^1.2 to ^2.0

    Update steverhoades/oauth2-openid-connect-server requirement from ^1.2 to ^2.0

    Updates the requirements on steverhoades/oauth2-openid-connect-server to permit the latest version.

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 2
  • [bug] Error :

    [bug] Error : "Unknown Heimdall grant type, please recheck your parameter" on using password grant and client grant

    Describe the bug I've been tried to using this lib and follow the docs correctly but I used password grant and it throws error. The error is "Unknown Heimdall grant type, please recheck your parameter". I don't know what parameter should I recheck. It doesn't give clear explanation. I would greatly greatful if someone would help me with this issue. Thanks

    To Reproduce I'm not quite clear what is this should be about, but I'm debugging via vscode with xdebug, as it can be look at screenshot below. And here's the log

    CRITICAL - 2020-10-03 09:35:04 --> Unknown Heimdall grant type, please recheck your parameter. #0 D:\wamp64\www\cobacoba\app\Libraries\OAuthServer\OAuthServer.php(54): Heimdall\Heimdall::initializeAuthorizationServer(Object(Heimdall\Config\HeimdallAuthorizationConfig), Object(Heimdall\Config\HeimdallAuthorizationGrant)) #1 D:\wamp64\www\cobacoba\app\Controllers\Rest\Authorization.php(17): App\Libraries\OAuthServer\OAuthServer::createAuthorizationServer() #2 D:\wamp64\www\cobacoba\vendor\codeigniter4\framework\system\CodeIgniter.php(890): App\Controllers\Rest\Authorization->__construct() #3 D:\wamp64\www\cobacoba\vendor\codeigniter4\framework\system\CodeIgniter.php(399): CodeIgniter\CodeIgniter->createController() #4 D:\wamp64\www\cobacoba\vendor\codeigniter4\framework\system\CodeIgniter.php(312): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false) #5 D:\wamp64\www\cobacoba\public\index.php(45): CodeIgniter\CodeIgniter->run() #6 {main}

    Expected behavior Know the grant type and generate token

    Screenshots image image

    Desktop (please complete the following information):

    • OS: Windows 10 Home x64
    • PHP version : 7.3.12 (Using WAMPServer)

    Additional context I have no idea

    bug 
    opened by fahmiegerton 2
  • [bug] Using integers for registered date claims is deprecated, please use DateTimeImmutable objects instead

    [bug] Using integers for registered date claims is deprecated, please use DateTimeImmutable objects instead

    Authorization code grant type throws Using integers for registered date claims is deprecated, please use DateTimeImmutable objects instead during token generation because of the changes in lcobucci/jwt:3.4

    league/oauth2-server:8.1.1 and lcobucci/jwt:3.3.3 works fine.

    Steps to reproduce the behavior: composer require ezralazuardy/heimdall //which installs latest versions of league/oauth2-server version 8.2.4 which uses lcobucci/jwt:3.4.5 Use authorization code grant Token generation step gives error

    Expected behavior Generated tokens

    Screenshots image

    bug 
    opened by ergec 1
  • getUserEntityByIdentifier seems is never been called

    getUserEntityByIdentifier seems is never been called

    Hello, First of all thank you very much for Heimdall. Great name for a great library.

    CI 4.1.1 and heimdal works great no problem.

    I tried to implement OIDC by following these steps https://heimdall.ezralazuardy.com/documentation/oidc#enabling-oidc but seems getUserEntityByIdentifier doesn't even get called at all. Is there something missing in documentation?

    I get no errors but the token generated has no profile information.

    I'm using withClientCredentialsGrant BTW.

    opened by ergec 0
  • Multiple Grant Type Support in Heimdall

    Multiple Grant Type Support in Heimdall

    Is your feature request related to a problem? Please describe.

    I want to have multiple grant type in one server, is there any good example to do it?

    Describe the solution you'd like

    I have done it, but with condition from what grant_type value is.

    // function to create a new instance of HeimdallAuthorizationServer
        static function createAuthorizationServer($grant_type = null)
        {
            // creating HeimdallAuthorizationServer config
            $config = Heimdall::withAuthorizationConfig(
                new ClientRepository(),
                new AccessTokenRepository(),
                new ScopeRepository(),
                __DIR__ . '/private.key'
            );
    
            $grant = null;
            switch ($grant_type) {
                case 'client_credentials':
                    $grant = Heimdall::withClientCredentialsGrant('P1Y');
                    break;
                default:
                    // creating HeimdallAuthorizationServer grant
                    $grant = Heimdall::withAuthorizationCodeGrant(
                        new AuthCodeRepository(),
                        new RefreshTokenRepository(),
                        'PT1H',
                        'P6M',
                        'P3M'
                    );
                    break;
            }
    
            // return a new instance of HeimdallAuthorizationServer
            return Heimdall::initializeAuthorizationServer($config, $grant);
        }
    

    Describe alternatives you've considered

    Instead of using condition above, is there any other solution, that can make multiple grant_type support?

    Additional context

    In League Library source code, it is possible to do it. What's about implementation in Heimdall?

    opened by doelmi 0
  • Suggestion to include notice for those who want to use

    Suggestion to include notice for those who want to use "openid" scope in documentation.

    Issue:

    When you try to add the scope of 'openid' scope as shown on the following link (https://heimdall.ezralazuardy.com/documentation/oidc). It throws a message (error) while using token API. (http://localhost:8080/rest/token)

    "Using integers for registered date claims is deprecated, please use DateTimeImmutable objects instead."

    This seems to be caused by the dependency of league/oauth2-server. It uses newer package lcobucci/jwt where there have been major breaking changes. Similiar issue has been noted in laravel passport package. (https://github.com/laravel/passport/issues/1381)

    Solution : This can be resolved by downgrading the package " lcobucci/jwt" to 3.3.3 for the dependency "league/oauth2-server" and then run command composer require lcobucci/jwt:3.3.3

    documentation 
    opened by Dhavalc2012 2
  • Mistake in the documentation snippet for ResourceFilter

    Mistake in the documentation snippet for ResourceFilter

    In the ResourceFilter, in the example, the server instance seems to be wrong. Instead of HeimdallAuthorizationCode, it should be OAuthServer from my understanding on the following link : (https://heimdall.ezralazuardy.com/documentation/implementation).

    image

    documentation 
    opened by Dhavalc2012 0
  • Route fix in documentation

    Route fix in documentation

    Hello, On this page https://heimdall.ezralazuardy.com/documentation/implementation#set-up-the-route-1

    Following route works if you don't use any segments $routes->get('rest/users', 'Rest/Users::getUsers');

    If you want to use segments it has to be like this. (backslash instead of forwarslash between Rest and Users)

    $routes->get('rest/(:segment)/users', 'Rest\Users::getUsers/$1');

    documentation 
    opened by ergec 0
  • Suggestion Coding Standard

    Suggestion Coding Standard

    Is your feature request related to a problem? Please describe. I am happy to see OAuth 2.0 Server by phpleague come to CodeIgniter4, this is nice to start using oauth2, but before i am jump to this i will recomendating to refactor lot of code between source code and documentation following psr2 or maybe follow coding standard by CodeIgniter4, but i will be prefer to using follow psr2.

    Describe the solution you'd like PHP CodeSniffer is nice tool to refactor code.

    Describe alternatives you've considered

    Additional context

    enhancement 
    opened by agungsugiarto 1
Releases(v0.0.4)
Owner
Ezra Lazuardy
guilty beat that got no rhythm
Ezra Lazuardy
PHPoAuthLib provides oAuth support in PHP 7.2+ and is very easy to integrate with any project which requires an oAuth client.

PHPoAuthLib NOTE: I'm looking for someone who could help to maintain this package alongside me, just because I don't have a ton of time to devote to i

David Desberg 1.1k Dec 27, 2022
EAuth extension allows to authenticate users by the OpenID, OAuth 1.0 and OAuth 2.0 providers

EAuth extension allows to authenticate users with accounts on other websites. Supported protocols: OpenID, OAuth 1.0 and OAuth 2.0.

Maxim Zemskov 330 Jun 3, 2022
OAuth 1/2 Provider implementations for chillerlan/php-oauth-core. PHP 7.4+

chillerlan/php-oauth-providers Documentation See the wiki for advanced documentation. Requirements PHP 7.4+ a PSR-18 compatible HTTP client library of

chillerlan 4 Dec 2, 2022
A spec compliant, secure by default PHP OAuth 2.0 Server

PHP OAuth 2.0 Server league/oauth2-server is a standards compliant implementation of an OAuth 2.0 authorization server written in PHP which makes work

The League of Extraordinary Packages 6.2k Jan 4, 2023
Kaiju is an open source verification bot based on Discord's OAuth written in C# and PHP, with the functionality of being able to integrate the user to a new server in case yours is suspended.

What is Kaiju? Kaiju is an open source verification bot for Discord servers, based on OAuth and with permission for the server owner, to be able to mi

in the space 10 Nov 20, 2022
Symfony bundle which provides OAuth 2.0 authorization/resource server capabilities

Symfony bundle which provides OAuth 2.0 authorization/resource server capabilities. The authorization and resource server actors are implemented using the thephpleague/oauth2-server library.

Trikoder 253 Dec 21, 2022
OAuth server implementation for WP API

WP REST API - OAuth 1.0a Server Connect applications to your WordPress site without ever giving away your password. This plugin uses the OAuth 1.0a pr

WordPress REST API Team 314 Dec 10, 2022
Easy integration with OAuth 2.0 service providers.

OAuth 2.0 Client This package provides a base for integrating with OAuth 2.0 service providers. The OAuth 2.0 login flow, seen commonly around the web

The League of Extraordinary Packages 3.4k Dec 31, 2022
PHP 5.3+ oAuth 1/2 Client Library

PHPoAuthLib NOTE: I'm looking for someone who could help to maintain this package alongside me, just because I don't have a ton of time to devote to i

David Desberg 1.1k Dec 27, 2022
OAuth 1 Client

OAuth 1.0 Client OAuth 1 Client is an OAuth RFC 5849 standards-compliant library for authenticating against OAuth 1 servers. It has built in support f

The League of Extraordinary Packages 907 Dec 16, 2022
The first PHP Library to support OAuth for Twitter's REST API.

THIS IS AN MODIFIED VERSION OF ABRAHAMS TWITTER OAUTH CLASS The directories are structured and the class uses PHP5.3 namespaces. Api.php has a new

Ruud Kamphuis 51 Feb 11, 2021
OAuth client integration for Symfony. Supports both OAuth1.0a and OAuth2.

HWIOAuthBundle The HWIOAuthBundle adds support for authenticating users via OAuth1.0a or OAuth2 in Symfony. Note: this bundle adds easy way to impleme

Hardware Info 2.2k Dec 30, 2022
An OAuth 2.0 bridge for Laravel and Lumen [DEPRECATED FOR LARAVEL 5.3+]

OAuth 2.0 Server for Laravel (deprecated for Laravel 5.3+) Note: This package is no longer maintaned for Laravel 5.3+ since Laravel now features the P

Luca Degasperi 2.4k Jan 6, 2023
The most popular PHP library for use with the Twitter OAuth REST API.

TwitterOAuth The most popular PHP library for Twitter's OAuth REST API. See documentation at https://twitteroauth.com. PHP versions listed as "active

Abraham Williams 4.2k Dec 23, 2022
This module is intended to provide oauth authentication to freescout.

OAuth FreeScout This module is intended to provide oauth authentication to freescout. Module was tested on keycloak oauth provider with confidential o

Michael Bolsunovskyi 9 Dec 21, 2022
A Laravel 5 package for OAuth Social Login/Register implementation using Laravel socialite and (optionally) AdminLTE Laravel package

laravel-social A Laravel 5 package for OAuth Social Login/Register implementation using Laravel socialite and (optionally) AdminLTE Laravel package. I

Sergi Tur Badenas 42 Nov 29, 2022
OAuth Service Provider for Laravel 4

OAuth wrapper for Laravel 4 oauth-4-laravel is a simple laravel 4 service provider (wrapper) for Lusitanian/PHPoAuthLib which provides oAuth support i

Dariusz Prząda 693 Sep 5, 2022
OAuth Service Provider for Laravel 5

OAuth wrapper for Laravel 5 oauth-5-laravel is a simple laravel 5 service provider (wrapper) for Lusitanian/PHPoAuthLib which provides oAuth support i

null 2 Sep 19, 2018
The Salla OAuth Client library is designed to provide client applications with secure delegated access to Salla Merchant stores.

Salla Provider for OAuth 2.0 Client This package provides Salla OAuth 2.0 support for the PHP League's OAuth 2.0 Client. To use this package, it will

Salla 14 Nov 27, 2022