Git Product home page Git Product logo

yapi-plugin-auth2's Introduction

yapi-plugin-auth2

License Node Version NPM Version Downloads

第三方插件,基于Oauth2协议登录,在生成的配置文件中,添加如下配置即可:

  "plugins": [
    {
      "name": "auth2",
      "options": {
        "type": "oauth2",
        "clientId": "your client id",
        "clientSecret": "your client secret",
        "authMethod": "GET",
        "authServer": "http://your.yapiserver",
        "authPath": "登录页面地址",
        "tokenPath": "code换取token接口地址",
        "infoPath": "用户信息接口地址",
        "redirectUri": "http://your.yapiserver/api/plugin/oauth2/callback",
        "userKey": "usernamekey",
        "emailKey": "emailkey",
        "buttonName": "统一登录",
        "authArgs": {
          "login_type": "oa"
        }
      }
    }
  ]

使用注意:

  • Oauth2服务器用户信息需要提供: emailusername两个字段,如果字段名不一致,可以通过emailKeyuserKey设置。

这里面的配置项含义如下:

  • clientId 客户端id
  • clientSecret 客户端秘钥
  • authMethod 调用oauth2服务器地址时的方法,默认GET
  • authServer oauth2服务器地址
  • authPath 授权登录页面地址
  • tokenPath 通过code换取token的接口地址
  • infoPath 通过token获取用户信息的接口地址
  • redirectUri 重定向地址,授权登录页面成功之后携带code跳转的目标地址
  • state OAuth state,默认STATE
  • emailKey 用户信息电子邮件字段key,当值为数组时按优先级尝试获取邮箱
  • userKey 用户信息用户名字段key,当值为数组时按优先级尝试获取用户名
  • buttonName 登录按钮名称,默认OAuth2登录
  • authArgs 附加参数,单层json对象,用于格式化到authPath, tokenPath

yapi-plugin-auth2's People

Contributors

amazing-gao avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

yapi-plugin-auth2's Issues

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.