Skip to content

A web gateway for enterprise internal application supports authentication by scaning QR code with APP

License

Notifications You must be signed in to change notification settings

hanabix/passport

Repository files navigation

CI Publish Docker Latest Coveralls github Codacy Badge

Passport 是一个超轻量级统一认证网关, 面向使用 钉钉 或是 企业微信 的创业团队提供手机扫码登录访问内部服务.

overview diagram

seq diagram

跑起来

curl -LkO https://github.com/zhongl/passport/raw/master/docker-compose.yml 
curl -LkO https://github.com/zhongl/passport/raw/master/app.conf
DOMAIN=foo.bar docker-compose up -d
curl -k -v https://localhost -H 'Host: www.foo.bar' -H 'Cookie: jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJwYXNzcG9ydCIsIm5hbWUiOiJ6aG9uZ2wiLCJleHAiOjE4NjYxNzI3MjV9.FomLr4SgRvHuI6iUnVZc2-Q9YQbNrh4eDWGbM09xoC8'

配置

钉钉

// app.conf
include "dingtalk.conf"

cookie {
    domain = ".company.internal.domain"
    secret = "JWT签名密钥"
}

dingtalk {
    micro {
        appkey = "微应用的appkey"
        secret = "微应用的appsecret"
    }
    
    mobile {
        appid = "移动接入应用的appid"
        secret = "移动接入应用的appSecret"
    }

    authorization.redirect = "https://your.company.domain/authorized"
}
  1. 参见开发企业内部应用, 创建微应用;
  2. 参见扫码登录第三方Web网站, 创建移动接入应用.

企业微信

// app.conf
include "wechat.conf"

cookie {
    domain = ".company.internal.domain"
    secret = "JWT签名密钥"
}

wechat {
    corp = "企业corpid"
    secret = "企业corpsecret"
    agent = "应用的agentid"

    authorization.redirect = "https://your.company.domain/authorized"
}

参见企业内部开发, 创建应用.

Echo调试

若需要在真正部署之前进行调试验证, 可在运行时指定-e:

docker run --rm -it zhongl/passport:latest -e

开启Echo模式, 显示请求文本.

docker run --rm zhongl/passport:latest --help 查看更多帮助

应用集成

扫码登录后, Passport 会产生一个加签过的 JWT Token 作为 Cookie, 其中包含当前用户的认证信息(钉钉和微信略有差异). 此 Cookie 也会在后续的请求中透传到合法目标服务器, 做进一步授权处理.

认证信息参见Platforms.scala

References

About

A web gateway for enterprise internal application supports authentication by scaning QR code with APP

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages