robinpowered/php-ntlm
Composer 安装命令:
composer require robinpowered/php-ntlm
包简介
Message encoder/decoder and password hasher for the NTLM authentication protocol
关键字:
README 文档
README
PHP-NTLM is a library that handles the encoding and decoding of messages used in the challenge-and-response flow of the NTLM authentication protocol, while also providing separate injectable credential hashing mechanisms to allow for a more secure version of a credential for storage (rather than storing passwords in "plain-text").
Features
- NTLM client message encoding and decoding
- Multiple text-encoding native-extensions supported
- LM, NTv1, and NTv2 hashing algorithms supported
Requirements
- 64-bit PHP runtime (NTLM negotiation bit flags extend beyond the 32-bit integer size)
- PHP
>=7.1.0
Installation
- Get Composer
- Add
robinpowered/php-ntlmto your Composer required dependencies:composer require robinpowered/php-ntlm - Include the Composer autoloader
Example Usage
// Using Guzzle $client = new Client(); $request = new Request('get', 'https://my-exchange-url.com'); $user_name = 'user_name'; $password = 'password'; $target_name = 'target_name'; $host_name = 'host_name'; $encoding_converter = new MbstringEncodingConverter(); $random_byte_generator = new NativeRandomByteGenerator(); $hasher_factory = HasherFactory::createWithDetectedSupportedAlgorithms(); $negotiate_message_encoder = new NegotiateMessageEncoder($encoding_converter); $challenge_message_decoder = new ChallengeMessageDecoder(); $keyed_hasher_factory = KeyedHasherFactory::createWithDetectedSupportedAlgorithms(); $nt1_hasher = new NtV1Hasher($hasher_factory, $encoding_converter); $nt2_hasher = new NtV2Hasher($nt1_hasher, $keyed_hasher_factory, $encoding_converter); $authenticate_message_encoder = new NtlmV2AuthenticateMessageEncoder( $encoding_converter, $nt2_hasher, $random_byte_generator, $keyed_hasher_factory ); $negotiate_message = $negotiate_message_encoder->encode( $target_name, $host_name ); // Send negotiate message $request->setHeader('Authorization', sprintf('NTLM %s', base64_encode($negotiate_message))); $response = $client->send($request); // Decode returned challenge message $authenticate_headers = $response->getHeaderAsArray('WWW-Authenticate'); foreach ($authenticate_headers as $header_string) { $ntlm_matches = preg_match('/NTLM( (.*))?/', $header_string, $ntlm_header); if (0 < $ntlm_matches && isset($ntlm_header[2])) { $raw_server_challenge = base64_decode($ntlm_header[2]); break; } } $server_challenge = $challenge_message_decoder->decode($raw_server_challenge); $authenticate_message = $authenticate_message_encoder->encode( $user_name, $target_name, $host_name, new Password($password), $server_challenge ); // Send authenticate message $request->setHeader('Authorization', sprintf('NTLM %s', base64_encode($authenticate_message))); $client->send($request);
TODO
- LM hashing
- NTv1 hashing
- NTv2 hashing
- NTLM negotiate message encoding
- NTLM challenge message decoding
- Message structure and data validation
- Negotiate flag decoding
- Server challenge "nonce" handling
- TargetName parsing/handling
- (Optional) TargetInfo parsing/handling
- (Optional) AV_PAIR decoding
- (Optional) Version parsing/handling (for debugging purposes only)
- NTLM authenticate message encoding
- NTLM v1 response support
- NTLM v2 response support
- Extended session security (NTLM2 session key) support
- (Add-on) Encrypted session key exchange support
- Datagram ("connectionless") support
- Tests
License
PHP-NTLM is licensed under the Apache License, Version 2.0.
Copyright 2019 Robin Powered, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
robinpowered/php-ntlm 适用场景与选型建议
robinpowered/php-ntlm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 117.28k 次下载、GitHub Stars 达 16, 最近一次更新时间为 2015 年 08 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Authentication」 「hash」 「NTLM」 「nt」 「lm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 robinpowered/php-ntlm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 robinpowered/php-ntlm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 robinpowered/php-ntlm 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PHP Library to interact with the Exchange SOAP service
Composer based package of https://blogs.msdn.microsoft.com/freddyk/2010/01/19/connecting-to-nav-web-services-from-php/
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
GraphQL authentication for your headless Craft CMS applications.
Laravel middleware to restrict a site or specific routes using HTTP basic authentication
Article CSS-ID Frontend Output Optimization
统计信息
- 总下载量: 117.28k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 29
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2015-08-17