• Stars
    star
    1,541
  • Rank 30,365 (Top 0.6 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 13 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CloudFoundry User Account and Authentication (UAA) Server

slack.cloudfoundry.org

Warning: MFA feature in UAA is currently deprecated and will be removed in a future UAA version.

CloudFoundry User Account and Authentication (UAA) Server

The UAA is a multi tenant identity management service, used in Cloud Foundry, but also available as a stand alone OAuth2 server. Its primary role is as an OAuth2 provider, issuing tokens for client applications to use when they act on behalf of Cloud Foundry users. It can also authenticate users with their Cloud Foundry credentials, and can act as an SSO service using those credentials (or others). It has endpoints for managing user accounts and for registering OAuth2 clients, as well as various other management functions.

UAA Server

The authentication service is uaa. It's a plain Spring MVC webapp. Deploy as normal in Tomcat or your container of choice, or execute ./gradlew run to run it directly from uaa directory in the source tree. When running with gradle it listens on port 8080 and the URL is http://localhost:8080/uaa

The UAA Server supports the APIs defined in the UAA-APIs document. To summarise:

  1. The OAuth2 /oauth/authorize and /oauth/token endpoints

  2. A /login_info endpoint to allow querying for required login prompts

  3. A /check_token endpoint, to allow resource servers to obtain information about an access token submitted by an OAuth2 client.

  4. A /token_key endpoint, to allow resource servers to obtain the verification key to verify token signatures

  5. SCIM user provisioning endpoint

  6. OpenID connect endpoints to support authentication /userinfo. Partial OpenID support.

Authentication can be performed by command line clients by submitting credentials directly to the /oauth/authorize endpoint (as described in UAA-API doc). There is an ImplicitAccessTokenProvider in Spring Security OAuth that can do the heavy lifting if your client is Java.

Use Cases

  1. Authenticate

     GET /login
    

    A basic form login interface.

  2. Approve OAuth2 token grant

     GET /oauth/authorize?client_id=app&response_type=code...
    

    Standard OAuth2 Authorization Endpoint.

  3. Obtain access token

     POST /oauth/token
    

    Standard OAuth2 Authorization Endpoint.

Co-ordinates

Quick Start

Requirements:

  • Java 11

If this works you are in business:

$ git clone git://github.com/cloudfoundry/uaa.git
$ cd uaa
$ ./gradlew run

The apps all work together with the apps running on the same port (8080) as /uaa, /app and /api.

UAA will log to a file called uaa.log which can be found using the following command:-

$ sudo lsof | grep uaa.log

which you should find under something like:-

$TMPDIR/cargo/conf/logs/

Demo of command line usage on local server

First run the UAA server as described above:

$ ./gradlew run

From another terminal you can use curl to verify that UAA has started by requesting system information:

$ curl --silent --show-error --head localhost:8080/uaa/login | head -1
HTTP/1.1 200

For complex requests it is more convenient to interact with UAA using uaac, the UAA Command Line Client.

Debugging local server

To load JDWP agent for UAA jvm debugging, start the server as follows:

./gradlew run -Dxdebug=true

or

./gradlew -Dspring.profiles.active=default,hsqldb,debug run

You can then attach your debugger to port 5005 of the jvm process.

To suspend the server start-up until the debugger is attached (useful for debugging start-up code), start the server as follows:

./gradlew run -Dxdebugs=true

or

./gradlew -Dspring.profiles.active=default,hsqldb,debugs run

Running local UAA server with different databases

./gradlew run runs the UAA server with hsqldb database by default.

MySql

  1. Start the mysql server (e.g. a mysql docker container)
% docker run --name mysql1 -e MYSQL_ROOT_PASSWORD=changeme -d -p3306:3306 mysql
  1. Create the uaa database (e.g. in mysql interactive session)
% mysql -h 127.0.0.1 -u root -p
...
mysql> create database uaa;
  1. Run the UAA server with the mysql profile
% ./gradlew -Dspring.profiles.active=mysql,default run

PostgreSQL

  1. Start the postgresql server (e.g. a postgres docker container)
docker run --name postgres1 -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres
  1. Create the uaa database (e.g. in psql interactive session)
% psql -h 127.0.0.1 -U postgres
create database uaa;
create user root with superuser password 'changeme';
  1. Run the UAA server with the postgresql profile
% ./gradlew -Dspring.profiles.active=postgresql,default run
  1. Once the UAA server started, you can see the tables created in the uaa database (e.g. in psql interactive session)
\c uaa
psql (14.5 (Homebrew), server 15.0 (Debian 15.0-1.pgdg110+1))
WARNING: psql major version 14, server major version 15.
         Some psql features might not work.
You are now connected to database "uaa" as user "postgres".
\d
List of relations
 Schema |             Name              |   Type   | Owner
--------+-------------------------------+----------+-------
 public | authz_approvals               | table    | root
 public | expiring_code_store           | table    | root
 public | external_group_mapping        | table    | root
 public | external_group_mapping_id_seq | sequence | root
 public | group_membership              | table    | root
 public | group_membership_id_seq       | sequence | root
 public | groups                        | table    | root
 public | identity_provider             | table    | root
 public | identity_zone                 | table    | root
 public | mfa_providers                 | table    | root
 public | oauth_client_details          | table    | root
 public | oauth_code                    | table    | root
 public | oauth_code_id_seq             | sequence | root
 public | revocable_tokens              | table    | root
 public | schema_version                | table    | root
 public | sec_audit                     | table    | root
 public | sec_audit_id_seq              | sequence | root
 public | service_provider              | table    | root
 public | spring_session                | table    | root
 public | spring_session_attributes     | table    | root
 public | user_google_mfa_credentials   | table    | root
 public | user_info                     | table    | root
 public | users                         | table    | root
(23 rows)

Running tests

You can run the integration tests with docker

$ run-integration-tests.sh <dbtype>

will create a docker container running uaa + ldap + database whereby integration tests are run against.

Using Gradle to test with postgresql or mysql

The default uaa unit tests (./gradlew test integrationTest) use hsqldb.

To run the unit tests with docker:

$ run-unit-tests.sh <dbtype>

To run a single test

The default uaa unit tests (./gradlew test) use hsqldb.

Start by finding out which gradle project your test belongs to. You can find all project by running

$ ./gradlew projects

To run a specific test class, you can specify the module and the test class.

$ ./gradlew :<project name>:test --tests <TestClass>.<MethodName>

In this example, it's running only the JdbcScimGroupMembershipManagerTests tests in the cloudfoundry-identity-server module:

$ ./gradlew :cloudfoundry-identity-server:test \
--tests "org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupMembershipManagerTests"

or to run all tests in a Class

$ ./gradlew :<project name>:test --tests <TestClass>

You might want to use the full gradle command found at the bottom of the scripts/unit-tests.sh script by prepending the project name to the test command and adding the --tests option.

Building war file

$ ./gradlew :clean :assemble -Pversion=${UAA_VERSION}

Inventory

There are actually several projects here, the main uaa server application, a client library and some samples:

  1. uaa a WAR project for easy deployment

  2. server a JAR project containing the implementation of UAA's REST API (including SCIM) and UI

  3. model a JAR project used by both the client library and server

  4. api (sample) is an OAuth2 resource service which returns a mock list of deployed apps

  5. app (sample) is a user application that uses both of the above

In CloudFoundry terms

  • uaa provides an authentication service plus authorized delegation for back-end services and apps (by issuing OAuth2 access tokens).

  • api is a service that provides resources that other applications may wish to access on behalf of the resource owner (the end user).

  • app is a webapp that needs single sign on and access to the api service on behalf of users.

Running the UAA on Kubernetes

Prerequisites

The Kubernetes deployment is in active development. You should expect frequent (and possibly breaking) changes. This section will be updated as progress is made on this feature set. As of now:

The K8s directory contains ytt templates that can be rendered and applied to a K8s cluster.

In development, this Makefile can be used for common rendering and deployment activities.

In production, you'll most likely want to use ytt directly. Something like this should get you going:

$ ytt -f templates -f values/default-values.yml | kubectl apply -f -

If you'd like to overide some of those values, you can do so by taking advantage of YTT's overlay functionality.

$ ytt -f templates -f values/default-values.yml -f your-dir/production-values.yml | kubectl apply -f -

Of course, you can always abandon the default values altogether and provide your own values file.

Contributing to the UAA

Here are some ways for you to get involved in the community:

  • Join uaa channel on slack.cloudfoundry.org
  • Create github tickets for bugs and new features and comment and vote on the ones that you are interested in.
  • Github is for social coding: if you want to write code, we encourage contributions through pull requests from forks of this repository. If you want to contribute code this way, please reference an existing issue if there is one as well covering the specific issue you are addressing. Always submit pull requests to the "develop" branch. We strictly adhere to test driven development. We kindly ask that pull requests are accompanied with test cases that would be failing if ran separately from the pull request.
  • After you create the pull request, you can check the code metrics yourself
    in Github Actions and on Sonar. The goal for new code should be close to 100% tested and clean code: Quality Gate Status

Connecting UAA to local LDAP Server

Requirements:

To debug UAA and LDAP integrations, we use an OpenLdap docker image from VMWare's Bitnami project

  1. Modify file uaa/src/main/resources/uaa.yml and enable LDAP by uncommenting line 7, spring_profiles: ldap,default,hsqldb
  2. run docker-compose up from directory scripts/ldap
  3. From scripts/ldap verify connectivity to running OpenLdap container by running docker-confirm-ldapquery.sh
  4. Start UAA with ./gradlew run
  5. Navigate to /uaa and log in with LDAP user user01 and password password1

Use below command to clean-up container and volume:

  • docker-compose down --volumes

More Repositories

1

bosh

Cloud Foundry BOSH is an open source tool chain for release engineering, deployment and lifecycle management of large scale distributed services.
Ruby
2,010
star
2

cli

The official command line client for Cloud Foundry
Go
1,733
star
3

java-buildpack-memory-calculator

Cloud Foundry JVM Memory Calculator
Go
602
star
4

gosigar

A Golang implementation of the Sigar API
Go
453
star
5

gorouter

CF Router
Go
429
star
6

java-buildpack

Cloud Foundry buildpack for running Java applications
Ruby
425
star
7

go-diodes

Diodes are ring buffers manipulated via atomics.
Go
411
star
8

cf-java-client

Java Client Library for Cloud Foundry
Java
318
star
9

korifi

Cloud Foundry on Kubernetes
Go
301
star
10

cf-for-k8s

The open source deployment manifest for Cloud Foundry on Kubernetes
Shell
301
star
11

cf-deployment

The canonical open source deployment manifest for Cloud Foundry
Go
279
star
12

stratos

Stratos: Web-based Management UI for Cloud Foundry and Kubernetes
TypeScript
241
star
13

credhub

CredHub centralizes and secures credential generation, storage, lifecycle management, and access
Java
225
star
14

garden

Go Warden
Go
223
star
15

java-buildpack-auto-reconfiguration

Auto-reconfiguration functionality for the Java Buildpack
Java
219
star
16

loggregator-release

Cloud Native Logging
Go
217
star
17

bytefmt

Human readable byte formatter
Go
208
star
18

diego-release

BOSH Release for Diego
HTML
199
star
19

staticfile-buildpack

Deploy static HTML/JS/CSS apps to Cloud Foundry
Go
199
star
20

cloud_controller_ng

Cloud Foundry Cloud Controller
Ruby
181
star
21

bosh-bootloader

Command line utility for standing up a BOSH director on an IAAS of your choice.
Go
176
star
22

bosh-cli

BOSH CLI v2+
Go
174
star
23

nodejs-buildpack

Cloud Foundry buildpack for Node.js
Go
161
star
24

diego-design-notes

Diego Architectural Design Musings and Explications
HTML
142
star
25

php-buildpack

A Cloud Foundry Buildpack for PHP.
Python
142
star
26

bosh-deployment

Collection of BOSH manifests referenced by cloudfoundry/docs-bosh
Shell
125
star
27

python-buildpack

Cloud Foundry buildpack for the Python Language
Go
118
star
28

eirini

Pluggable container orchestration for Cloud Foundry, and a Kubernetes backend
Go
115
star
29

cloud-service-broker

OSBAPI service broker that uses Terraform to provision and bind services. Derived from https://github.com/GoogleCloudPlatform/gcp-service-broker
Go
81
star
30

go-buildpack

Cloud Foundry buildpack for the Go Language
Go
80
star
31

multiapps-cli-plugin

A CLI plugin for Multi-Target Application (MTA) operations in Cloud Foundry
Go
77
star
32

guardian

containers4life
Go
75
star
33

lager

An opinionated logger for Go.
Go
73
star
34

app-autoscaler

Auto Scaling for CF Applications
Go
73
star
35

ibm-websphere-liberty-buildpack

IBM WebSphere Application Server Liberty Buildpack
Ruby
71
star
36

summit-training-classes

Opensourced content for cloud foundry training classes: zero to hero (beginner), bosh/operator, and microservices
JavaScript
69
star
37

cf-acceptance-tests

CF Acceptance tests
Go
68
star
38

cf-networking-release

Container Networking for CloudFoundry
Go
68
star
39

ruby-buildpack

Cloud Foundry buildpack for Ruby, Sinatra and Rails
Go
63
star
40

garden-runc-release

Shell
63
star
41

bosh-google-cpi-release

BOSH Google CPI
Go
62
star
42

bosh-azure-cpi-release

BOSH Azure CPI
Ruby
61
star
43

loggregator

Archived: Now bundled in https://github.com/cloudfoundry/loggregator-release
Go
60
star
44

cf-mysql-release

Cloud Foundry MySQL Release
Go
58
star
45

go-pubsub

Tree based pubsub library for Go.
Go
56
star
46

bosh-agent

BOSH Agent runs on each BOSH deployed VM
Go
56
star
47

docs-book-cloudfoundry

The bookbinder repository for open source Cloud Foundry documentation
HTML
55
star
48

homebrew-tap

Cloud Foundry Homebrew packages
Ruby
53
star
49

multiapps-controller

The server side component (controller) for Multi-Target Application (MTA) for Cloud Foundry
Java
52
star
50

socks5-proxy

This is a go library for starting a socks5 proxy server via SSH
Go
44
star
51

cf-uaac

Ruby
41
star
52

docs-cloudfoundry-concepts

A place for architecture and concept docs
HTML
41
star
53

buildpacks-ci

Concourse CI pipelines for the buildpacks team
HTML
41
star
54

service-fabrik-broker

Cloud Foundry service broker which provisions service instances as Docker containers and BOSH deployments.
JavaScript
40
star
55

grootfs

Garden root file system
Go
40
star
56

routing-release

This is the BOSH release for cloud foundry routers
Ruby
39
star
57

docs-dev-guide

Documentation for application developers who want to deploy their applications to Cloud Foundry
HTML
39
star
58

cf-smoke-tests

Smoke tests for CloudFoundry that are safe to run in a production environment
Go
38
star
59

credhub-cli

CredHub CLI provides a command line interface to interact with CredHub servers
Go
38
star
60

community

Governance and contact information for Cloud Foundry
Python
37
star
61

bosh-linux-stemcell-builder

BOSH Ubuntu Linux stemcells
Ruby
37
star
62

haproxy-boshrelease

A BOSH release for haproxy (based on cf-release's haproxy job)
Ruby
37
star
63

pmc-notes

Agendas and Notes for Cloud Foundry Project Management Committee Meetings
36
star
64

eirini-release

Helm release for Project Eirini
Shell
36
star
65

bosh-s3cli

Go CLI for S3
Go
36
star
66

bpm-release

isolated bosh jobs
Go
35
star
67

libbuildpack

A library for writing buildpacks
Go
34
star
68

cfdot

A command-line tool to interact with a Cloud Foundry Diego deployment.
Go
34
star
69

bosh-openstack-cpi-release

BOSH OpenStack CPI
Ruby
33
star
70

java-test-applications

Applications used for testing the Java buildpack
Java
33
star
71

switchboard

Golang TCP Proxy
JavaScript
33
star
72

docs-bosh

The docs repo for BOSH
HTML
32
star
73

cf-k8s-networking

building a cloud foundry without gorouter....
Go
32
star
74

cflinuxfs2

The official Cloud Foundry app container rootfs
Ruby
31
star
75

pxc-release

BOSH release of Percona Xtradb Cluster
JavaScript
30
star
76

clock

time provider & rich fake for Go
Go
30
star
77

bosh-vsphere-cpi-release

BOSH vSphere CPI
Ruby
30
star
78

os-conf-release

Additional Linux OS configuration release
Go
30
star
79

binary-buildpack

Deploy binaries to Cloud Foundry
Shell
28
star
80

bbs

Internal API to access the database for Diego.
Go
28
star
81

nginx-buildpack

Cloud Foundry buildpack that provides NGINX
Go
28
star
82

jumpbox-deployment

Deploy single vanilla jumpbox machine with BOSH
Shell
28
star
83

bosh-aws-cpi-release

BOSH AWS CPI
Ruby
27
star
84

uaa-release

Bosh Release for the UAA
Ruby
27
star
85

app-autoscaler-release

Automated scaling for apps running on Cloud Foundry
Go
26
star
86

archiver

Utilities for extracting and compressing tgz and zip files.
Go
26
star
87

bosh-backup-and-restore

Go
26
star
88

exemplar-release

Shell
25
star
89

apt-buildpack

Go
25
star
90

diego-notes

Diego Notes
23
star
91

capi-release

Bosh Release for Cloud Controller and friends
HTML
23
star
92

noaa

NOAA is a client library to consume metric and log messages from Doppler.
Go
23
star
93

metric-store-release

Metric Store: A Cloud-Native Time Series Database for Cloud Foundry
Go
23
star
94

cli-plugin-repo

Public repository for community created CF CLI plugins.
Go
23
star
95

cf-deployment-concourse-tasks

Shell
23
star
96

buildpack-packager

Buildpack Packager
Ruby
23
star
97

uaa-cli

CLI for UAA written in Go
Go
22
star
98

galera-healthcheck

A lightweight web server written in Golang to check the health of a node in a Galera cluster
Go
21
star
99

winc

CLI tool for spawning and running containers on Windows according to the OCI specification
Go
21
star
100

docs-buildpacks

HTML
21
star