定制 pochocho/okta-saml-sso 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pochocho/okta-saml-sso

Composer 安装命令:

composer require pochocho/okta-saml-sso

包简介

SSO for Laravel with Okta

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provide a simple to use implementation for implementing Okta SAML Login to the app. The package assists in receiving the SAML Response and Getting the

Installation

composer require pochocho/okta-saml-sso

Generate your certificate, if you want to generate a self signed certificate, you can follow the command as an example:

Note: by default, this package expects the certificate and key to be at the root of your projects directory. Remember to add both files to .gitignore

openssl req -x509 -newkey rsa:2048 -nodes -keyout oktasso.key -out oktasso.crt -days 365

Creating and Configuring Okta App

Create your Okta app, Select SAML 2.0 as the Sign-in Method.

in the form the Single sign on URL refers to url in your app that Okta will send a POST request to after successful authentication.

Audience URI is the URL where you are publishing public information about its SAML configuration (the metadata)

Default RelayState is the URL that Okta will redirect to after successfull login.

On this form you can also set the Attribute Statements and map them to profile fields. This package assumes snake_case naming conventions on the attributes (e.g first_name, las_name, email, etc)

After configuring the app, visit the signon tab and click on the "View SAML Setup Instructions", once the page loads download the certificate file and place it in the root of your application call it idp.cert important: do not commit this file to version control

configuration

The following values must be set in hour .env

OKTA_SIGNON_URL: You can get this value from your Okta Admin Dashboard, by going to the "Sign On" tab on your SAML app and clicking on the "View SAML setup Instructions" button. Use the "Identity Provider Single Sign-On URL" value.

LOGIN_REDIRECT_ROUTE:This is the route name where you want your users to be redirected logging in.

You can also publish the configuration file by running

php artisan vendor:publish --tag=okta-saml-sso

The package assumes that a cert and key file exist at the root directory of the project, named oktasso.crt and oktasso.key:

  • OKTA_CERTIFICATE_PATH path to the certificate file
  • OKTA_KEY_PATH path to the key file
  • OKTA_ATTRIBUTE_STATEMENTS Comma separated list of attribute statements setup in Okta (default value: 'first_name','last_name','email','groups')

If your application does not use the User model for authentication, you can configure the model with the OKTA_AUTHENTICATABLE_MODEL key on the env.

Usage

Provided

The easiest way to use the package is by using the provided controllers. The package provides 2 controllers one if you are using encryption, and another if you are not. To get started register the route in the web.php routes file

Route::post('/login', \Pochocho\OktaSamlSso\Http\Controllers\EncryptedLoginController::class)->name('login');

NOTE: Since Okta sends a post request to the app once authentication is completed, we need to ignore the login route from csrf validation. You can do this by adding the login url to the VerifyCsrfToken middleware in the application.

Register the SsoAuthenticate Middleware in the Http Kernel. You can either substitute the auth middleware or create your own.

'auth' => \Pochocho\OktaSamlSso\Http\Middleware\SsoAuthenticate::class,

Add the new middleware to your auth protected routes, try loading a proteted route and you should be redirected to the Okta login flow.

Custom

You can implement your own controller and use the OktaSaml class to handle the assertions from the Okta SAML Response. The class provides two methods one for un-encrypted SAML Responses $oktaSaml->getEntity() and another for encrypted responses $oktaSaml->getEncryptedEntity().

The OktaSaml Class is bound to the IoC Container and can be resolved through dependency injection or by using app()->make(Pochocho\OktaSamlSso\OktaSaml::class);

pochocho/okta-saml-sso 适用场景与选型建议

pochocho/okta-saml-sso 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.61k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 11 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 pochocho/okta-saml-sso 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pochocho/okta-saml-sso 我们能提供哪些服务?
定制开发 / 二次开发

基于 pochocho/okta-saml-sso 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-26