项目作者: liut

项目描述 :
An OAuth2 server with management for enterprise employees
高级语言: Go
项目地址: git://github.com/liut/staffio.git
创建时间: 2015-07-23T04:54:33Z
项目社区:https://github.com/liut/staffio

开源协议:MIT License

下载


Staffio

An OAuth2 server that provides managed services for enterprise employees.

Features:

  • Employee security information is stored in LDAP.
  • Login authentication service and general membership settings.
  • Reset password using email and mobile phone number.
  • Create edit and delete employees by special members.
  • Maintainable APP Client ID and Secret.
  • Simple content article and link management.
  • Generic OAuth2 authentication and authorization management.
  • Directly CAS implement for V1 and V2.

Objects

Staff

  • uid: Username, required
  • cn: Full Name
  • gn: FirstName
  • sn: LastName, required
  • nickname
  • birthday: YYYYmmdd
  • gender: f, m
  • email: Email
  • mobile: Cell phone number
  • avatarPath: Avatar URI
  • description:
  • joinDate: YYYYmmdd

Group

  • name:
  • description:
  • members: []uid

User (online)

  • uid: Username
  • name: DisplayName

APIs of oauth2

Authorize (browse page)

GET | POST /authorize

Retrieve Token

GET | POST /token

Get Info

GET | POST /info/{topic}

Info topic

  1. me: {me: User}
  2. me+{groupName}: {me: User, group}
  3. grafana or generic: {struct for grafana}

CAS" class="reference-link">APIs of CAS

URI Description
/login credential requestor / acceptor
/logout destroy CAS session (logout)
/validate service ticket validation
/serviceValidate service ticket validation [CAS 2.0]
/proxyValidate TODO service/proxy ticket validation [CAS 2.0]
/proxy TODO proxy ticket service [CAS 2.0]
/p3/serviceValidate TODO service ticket validation [CAS 3.0]
/p3/proxyValidate TODO service/proxy ticket validation [CAS 3.0]

Quick start

Run all components as docker containers

  1. # openldap
  2. docker run --name staffio-ldap -p 389:389 -p 636:636 \
  3. -e LDAP_ADMIN_PASSWORD=mypassword \
  4. -d liut7/staffio-ldap:latest
  5. # postgresql
  6. docker create --name staffio-db-data -v /var/lib/postgresql busybox:1 echo staffio db data
  7. docker run --name staffio-db -p 54322:5432 \
  8. -e DB_PASS=mypassword \
  9. -e TZ=Hongkong \
  10. --volumes-from=staffio-db-data \
  11. -d liut7/staffio-db:latest
  12. # staffio main server
  13. docker run --name staffio -p 3030:3030 \
  14. -e STAFFIO_BACKEND_DSN='postgres://staffio:mypassword@staffio-db/staffio?sslmode=disable' \
  15. -e STAFFIO_LDAP_HOSTS='ldap://slapd' \
  16. -e STAFFIO_LDAP_BASE="dc=example,dc=org" \
  17. -e STAFFIO_LDAP_BIND_DN="cn=admin,dc=example,dc=org" \
  18. -e STAFFIO_LDAP_PASS='mypassword' \
  19. --link staffio-db --link staffio-ldap:slapd \
  20. -d liut7/staffio:latest web
  21. # create a user as first staff and adminstrator
  22. docker exec staffio staffio addstaff -u eagle -p mysecret -n eagleliut --sn liut
  23. docker exec staffio staffio group -g keeper -a eagle
  24. # now can open http://localhost:3030/ in browser
  25. # add a oauth2 client (optional)
  26. docker exec staffio staffio client --add demo --uri http://localhost:3000
  27. # list clients
  28. docker exec staffio staffio client --list
  29. ## for testing database
  30. echo "CREATE DATABASE staffiotest WITH OWNER = staffio ENCODING = 'UTF8';" | docker exec -i staffio-db psql -Upostgres
  31. echo "GRANT ALL PRIVILEGES ON DATABASE staffiotest to staffio;" | docker exec -i staffio-db psql -Upostgres

prepare development

checkout

  1. go get -u github.com/liut/staffio
  2. cp -n .env.example .env

environment

cat .env.example

  1. STAFFIO_HTTP_LISTEN=":3000"
  2. STAFFIO_LDAP_HOSTS=slapd.hostname
  3. STAFFIO_LDAP_BASE="dc=example,dc=org"
  4. STAFFIO_LDAP_BIND_DN="cn=admin,dc=example,dc=org"
  5. STAFFIO_LDAP_PASS="mypassword"
  6. STAFFIO_BACKEND_DSN="postgres://staffio:mypassword@localhost:54322/staffio?sslmode=disable"
  7. STAFFIO_PASSWORD_SECRET="mypasswordsecret"

launch development

  1. go get -u github.com/ddollar/forego
  2. go get -u github.com/liut/rerun
  3. npm install
  4. forego start

deployment

  1. make dist package
  2. scp dist/linux_amd64/staffio remote:/opt/staffio/bin/
  3. make fe-build
  4. rsync -rpt --delete templates htdocs remote:/opt/staffio/

add staff

  1. forego run ./staffio addstaff -u eric -p AF1984 -n George --sn Blair

Plan

  • Peoples and groups sync with WxWork
  • Signin with WxWork
  • Notification
  • Export for backup
  • Batch import or restore from backup
  • I18n