Download the PHP package milpa/oauth-providers without Composer

On this page you can find all versions of the php package milpa/oauth-providers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package oauth-providers

Milpa

# Milpa OAuth Providers > **Seven zero-dependency OAuth 2.0 / social-login providers** for the Milpa PHP framework — Google, GitHub, GitLab, Facebook, Apple, Twitch, and the Telegram Login Widget. Pure protocol: build the authorization URL, exchange the code, get back a typed, immutable `UserInfo` DTO. No storage, no sessions, no framework coupling — bring your own. [![CI](https://github.com/getmilpa/oauth-providers/actions/workflows/ci.yml/badge.svg)](https://github.com/getmilpa/oauth-providers/actions/workflows/ci.yml) [![Packagist](https://img.shields.io/packagist/v/milpa/oauth-providers.svg)](https://packagist.org/packages/milpa/oauth-providers) [![PHP](https://img.shields.io/badge/php-%E2%89%A5%208.3-777bb4.svg)](https://www.php.net/) [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE) [![Docs](https://img.shields.io/badge/docs-API%20reference-blue.svg)](https://getmilpa.github.io/oauth-providers/) `milpa/oauth-providers` implements the OAuth 2.0 authorization-code flow (plus Apple's JWT-`id_token` variant and Telegram's HMAC-signed widget) against seven identity providers, each behind its own typed contract in `Milpa\OAuth\Contracts`. Every provider does exactly three things: build an authorization URL, exchange a code for a token, and normalize the provider's response into an immutable DTO. **No Doctrine, no HTTP client, no session, no `milpa/core`** — this package is `curl` and `openssl` against seven third-party APIs, nothing else. Persisting the user, issuing your own session, and generating/storing the CSRF `state` are entirely your host application's job. ## Install ## Quick example Build an authorization URL for GitHub with a CSRF-protection `state`, then handle the callback: Every OAuth provider (`GoogleOAuthService`, `GitHubOAuthService`, `GitLabOAuthService`, `FacebookOAuthService`, `AppleOAuthService`, `TwitchOAuthService`) implements the same two-method shape: `getAuthUrl(string $redirectUri, ?string $state = null): string` and `exchangeCode(string $code, string $redirectUri): UserInfo`. Swapping providers means swapping the class you construct — the calling code above is identical for all six. ## The `state` parameter — CSRF protection is on you Every OAuth provider's `getAuthUrl()` accepts an optional `?string $state`. When given, it is appended to the authorization URL as-is and the provider echoes it back **unmodified** — on the callback's query string for Google/GitHub/GitLab/Facebook/Twitch, in the `form_post` body for Apple (`response_mode=form_post`). **This package generates, stores, and verifies nothing.** It only transports whatever string you pass. Without a `state` round-trip, your callback route has no way to tell a legitimate redirect from an attacker who crafted their own `code` and pointed a victim's browser at your callback URL (a login CSRF). The standard mitigation, entirely your responsibility: 1. Generate a random, unguessable value before redirecting — `bin2hex(random_bytes(16))`, not `uniqid()` or anything predictable. 2. Store it server-side, scoped to the user's session (PHP session, signed cookie, or a short-lived cache entry keyed by a nonce). 3. On the callback, compare the stored value against the one the provider echoed back using `hash_equals()` (constant-time — a plain `===` leaks timing information), and reject the request if they don't match, **before** calling `exchangeCode()`. Skipping `state` doesn't break anything — every provider works fine with `null` — but it removes your only defense against login CSRF. Always pass one in a browser-facing flow. ## Telegram: HMAC verification, not an authorization code `TelegramAuthService` has a different, single-method contract — `verify(array $data): TelegramUserInfo` — because the [Telegram Login Widget](https://core.telegram.org/widgets/login) is not the authorization-code flow the other six providers use. There is no `getAuthUrl()`, no redirect, no `code` to exchange: the widget runs entirely in the browser and POSTs a signed JSON payload (`id`, `first_name`, `auth_date`, `hash`, …) straight to your callback. `verify()` reconstructs Telegram's own signature and rejects anything that doesn't match, exactly as [Telegram's docs](https://core.telegram.org/widgets/login#checking-authorization) specify: 1. Every field **except `hash`** is sorted by key and joined as `"{$key}={$value}"` lines with `\n`, producing the `data_check_string`. 2. The secret key is `SHA-256(bot_token)` (raw bytes, not hex). 3. The expected signature is `HMAC-SHA-256(data_check_string, secret_key)`, compared to the payload's `hash` with `hash_equals()` — never `===`. 4. `auth_date` must be within the last 24 hours, or `verify()` throws even with a correctly-signed payload (stale widget sessions are rejected). A correctly signed, fresh payload round-trips to a `TelegramUserInfo`; anything else — a tampered field, a hash signed with the wrong bot token, an expired `auth_date`, or missing `id`/`auth_date`/`hash` — throws `\RuntimeException` with a message naming which check failed: Because `verify()` is pure HMAC arithmetic with no network call, it is the one provider method this package's own test suite exercises end-to-end without mocking `curl` — see `tests/Providers/TelegramAuthServiceTest.php`. ## Providers at a glance | Provider | Class | Constructor | Notes | |---|---|---|---| | Google | `GoogleOAuthService` | `clientId, clientSecret` | Requests `access_type=offline` + `prompt=consent` so a refresh token is issued every time. | | GitHub | `GitHubOAuthService` | `clientId, clientSecret` | Scopes `read:user user:email`. | | GitLab | `GitLabOAuthService` | `clientId, clientSecret, instanceUrl = ''` | `instanceUrl` defaults to `https://gitlab.com`; pass your self-hosted base URL (e.g. `https://git.mycompany.com`) to support a private instance. `getInstanceUrl()` reads it back. | | Facebook | `FacebookOAuthService` | `appId, appSecret` | Uses Graph API v21.0. | | Apple | `AppleOAuthService` | `clientId, teamId, keyId, privateKey` | Signs its own JWT `client_secret` from your `.p8` private key; user info comes from the `id_token`, not a userinfo endpoint. Apple sends the user's **name only on the first authorization** — persist it then, or it's gone. Uses `response_mode=form_post`, so `code` arrives via POST body, not the query string. | | Twitch | `TwitchOAuthService` | `clientId, clientSecret` | Scope `user:read:email`; the Helix userinfo call additionally requires a `Client-Id` header alongside the bearer token (handled internally). | | Telegram | `TelegramAuthService` | `botToken` | Not OAuth 2.0 — see [Telegram: HMAC verification](#telegram-hmac-verification-not-an-authorization-code) above. | Each `getAuthUrl()`/`exchangeCode()` provider throws `\RuntimeException` immediately if constructed with empty credentials, before making any network call. ## Requirements - PHP **≥ 8.3** - `ext-curl` — every OAuth provider's token/userinfo calls - `ext-openssl` — `AppleOAuthService` only, to sign its JWT client secret No Composer dependencies beyond PHP itself: this package does not require `milpa/core` or any other Milpa package. ## Documentation **Full API reference: [getmilpa.github.io/oauth-providers](https://getmilpa.github.io/oauth-providers/)** — generated straight from the source DocBlocks and dressed with the Milpa design system. ## Contributing Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md). Please report security issues via [SECURITY.md](SECURITY.md), and note that this project follows a [Code of Conduct](CODE_OF_CONDUCT.md). ## License [Apache-2.0](LICENSE) © Rodrigo Vicente - TeamX Agency. --- Milpa is designed, built, and maintained by **[Rodrigo Vicente - TeamX Agency](https://teamx.agency/?utm_source=github&utm_medium=readme&utm_campaign=milpa&utm_content=oauth-providers)**.

All versions of oauth-providers with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package milpa/oauth-providers contains the following files

Loading the files please wait ...