Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
make files
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeykazakov committed Jul 15, 2017
1 parent 843e4a4 commit 01180b7
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .make/Makefile.lnx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/wit
BINARY_CLIENT_BIN=$(INSTALL_PREFIX)/wit-cli
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/auth
BINARY_CLIENT_BIN=$(INSTALL_PREFIX)/auth-cli
GLIDE_BIN=glide
GOAGEN_BIN=$(VENDOR_DIR)/github.com/goadesign/goa/goagen/goagen
GO_BINDATA_BIN=$(VENDOR_DIR)/github.com/jteeuwen/go-bindata/go-bindata/go-bindata
Expand Down
4 changes: 2 additions & 2 deletions .make/Makefile.win
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/wit.exe
BINARY_CLIENT_BIN=$(INSTALL_PREFIX)/wit-cli.exe
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/auth.exe
BINARY_CLIENT_BIN=$(INSTALL_PREFIX)/auth-cli.exe
GLIDE_BIN=glide.exe
GOAGEN_BIN=$(VENDOR_DIR)/github.com/goadesign/goa/goagen/goagen.exe
GO_BINDATA_BIN=$(VENDOR_DIR)/github.com/jteeuwen/go-bindata/go-bindata/go-bindata.exe
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ FROM centos:7
LABEL maintainer "Devtools <[email protected]>"
LABEL author "Konrad Kleine <[email protected]>"
ENV LANG=en_US.utf8
ENV F8_INSTALL_PREFIX=/usr/local/wit
ENV F8_INSTALL_PREFIX=/usr/local/auth

# Create a non-root user and a group with the same name: "wit"
ENV F8_USER_NAME=wit
# Create a non-root user and a group with the same name: "auth"
ENV F8_USER_NAME=auth
RUN useradd --no-create-home -s /bin/bash ${F8_USER_NAME}

COPY bin/wit ${F8_INSTALL_PREFIX}/bin/wit
COPY bin/auth ${F8_INSTALL_PREFIX}/bin/auth
COPY config.yaml ${F8_INSTALL_PREFIX}/etc/config.yaml

# Install little pcp pmcd server for metrics collection
Expand All @@ -18,14 +18,14 @@ RUN yum install -y pcp && yum clean all && \
mkdir -p /etc/pcp /var/run/pcp /var/lib/pcp /var/log/pcp && \
chown -R ${F8_USER_NAME} /etc/pcp /var/run/pcp /var/lib/pcp /var/log/pcp && \
chmod -R ug+rw /etc/pcp /var/run/pcp /var/lib/pcp /var/log/pcp
COPY ./wit+pmcd.sh /wit+pmcd.sh
COPY ./auth+pmcd.sh /auth+pmcd.sh
EXPOSE 44321


# From here onwards, any RUN, CMD, or ENTRYPOINT will be run under the following user
USER ${F8_USER_NAME}

WORKDIR ${F8_INSTALL_PREFIX}
ENTRYPOINT [ "/wit+pmcd.sh" ]
ENTRYPOINT [ "/auth+pmcd.sh" ]

EXPOSE 8080
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export GIT_COMMITTER_NAME
export GIT_COMMITTER_EMAIL

# Used as target and binary output names... defined in includes
CLIENT_DIR=tool/wit-cli
CLIENT_DIR=tool/auth-cli

COMMIT=$(shell git rev-parse HEAD)
GITUNTRACKEDCHANGES := $(shell git status --porcelain --untracked-files=no)
Expand Down
19 changes: 9 additions & 10 deletions account/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/fabric8-services/fabric8-auth/errors"
"github.com/fabric8-services/fabric8-auth/gormsupport"
"github.com/fabric8-services/fabric8-auth/log"
"github.com/fabric8-services/fabric8-auth/workitem"

"github.com/goadesign/goa"
"github.com/jinzhu/gorm"
Expand All @@ -24,15 +23,15 @@ import (
// User describes a User account. A few identities can be assosiated with one user account
type User struct {
gormsupport.Lifecycle
ID uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"` // This is the ID PK field
Email string `sql:"unique_index"` // This is the unique email field
FullName string // The fullname of the User
ImageURL string // The image URL for the User
Bio string // The bio of the User
URL string // The URL of the User
Company string // The (optional) Company of the User
Identities []Identity // has many Identities from different IDPs
ContextInformation workitem.Fields `sql:"type:jsonb"` // context information of the user activity
ID uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"` // This is the ID PK field
Email string `sql:"unique_index"` // This is the unique email field
FullName string // The fullname of the User
ImageURL string // The image URL for the User
Bio string // The bio of the User
URL string // The URL of the User
Company string // The (optional) Company of the User
Identities []Identity // has many Identities from different IDPs
ContextInformation map[string]interface{} `sql:"type:jsonb"` // context information of the user activity
}

// TableName overrides the table name settings in Gorm to force a specific table name
Expand Down
2 changes: 1 addition & 1 deletion wit+pmcd.sh → auth+pmcd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ exec /usr/libexec/pcp/bin/pmcd -l /dev/no-such-file -f -A -H $PCP_HOSTNAME
sleep 5 # give time for pmcd's startup messages, so it doesn't intermix with ALM's


exec bin/wit ${1+"$@"}
exec bin/auth ${1+"$@"}
19 changes: 0 additions & 19 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,8 @@ http.address: 0.0.0.0:8080
# HTTP Cache-Control
#------------------------

cachecontrol.workitems: max-age=2
cachecontrol.workitemtypes: max-age=2
cachecontrol.workitemlinks: max-age=2
cachecontrol.workitemlinktypes: max-age=2
cachecontrol.spaces: max-age=2
cachecontrol.iterations: max-age=2
cachecontrol.areas: max-age=2
cachecontrol.users: max-age=2
cachecontrol.collaborators: max-age=2
cachecontrol.comments: max-age=2
cachecontrol.filters: max-age=86400 # 1 day
# data returned from '/api/user' must not be cached by intermediate proxies,
# but can only be kept in the client's local cache.
cachecontrol.user: private,max-age=2
Expand All @@ -51,16 +42,6 @@ cachecontrol.user: private,max-age=2
developer.mode.enabled: false
log.level: info

# Whether you want to create the common work item types such as bug, feature, ...
populate.commontypes: true

#------------------------
# Features
#------------------------

# Enable remote Work Item feature
feature.workitem.remote: false

# ----------------------------
# Authentication configuration
# ----------------------------
Expand Down
2 changes: 1 addition & 1 deletion design/collaborators.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
)

var _ = a.Resource("collaborators", func() {
a.Parent("space")
a.BasePath("/collaborators")

a.Action("list", func() {
Expand All @@ -15,6 +14,7 @@ var _ = a.Resource("collaborators", func() {
)
a.Description("List collaborators for the given space ID.")
a.Params(func() {
a.Param("spaceID", d.UUID, "ID of the space")
a.Param("page[offset]", d.String, "Paging start position")
a.Param("page[limit]", d.Integer, "Paging size")
})
Expand Down
71 changes: 71 additions & 0 deletions tool/auth-cli/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package main

import (
"fmt"
"github.com/fabric8-services/fabric8-auth/client"
"github.com/fabric8-services/fabric8-auth/tool/cli"
goaclient "github.com/goadesign/goa/client"
"github.com/spf13/cobra"
"net/http"
"os"
"time"
)

func main() {
// Create command line parser
app := &cobra.Command{
Use: "auth-cli",
Short: `CLI client for the auth service`,
}

// Create client struct
httpClient := newHTTPClient()
c := client.New(goaclient.HTTPClientDoer(httpClient))

// Register global flags
app.PersistentFlags().StringVarP(&c.Scheme, "scheme", "s", "", "Set the requests scheme")
app.PersistentFlags().StringVarP(&c.Host, "host", "H", "openshift.io", "API hostname")
app.PersistentFlags().DurationVarP(&httpClient.Timeout, "timeout", "t", time.Duration(20)*time.Second, "Set the request timeout")
app.PersistentFlags().BoolVar(&c.Dump, "dump", false, "Dump HTTP request and response.")

// Register signer flags
var key, format string
app.PersistentFlags().StringVar(&key, "key", "", "API key used for authentication")
app.PersistentFlags().StringVar(&format, "format", "Bearer %s", "Format used to create auth header or query from key")

// Parse flags and setup signers
app.ParseFlags(os.Args)
jwtSigner := newJWTSigner(key, format)

// Initialize API client
c.SetJWTSigner(jwtSigner)
c.UserAgent = "auth-cli/1.0"

// Register API commands
cli.RegisterCommands(app, c)

// Execute!
if err := app.Execute(); err != nil {
fmt.Fprintf(os.Stderr, err.Error())
os.Exit(-1)
}
}

// newHTTPClient returns the HTTP client used by the API client to make requests to the service.
func newHTTPClient() *http.Client {
// TBD: Change as needed (e.g. to use a different transport to control redirection policy or
// disable cert validation or...)
return http.DefaultClient
}

// newJWTSigner returns the request signer used for authenticating
// against the jwt security scheme.
func newJWTSigner(key, format string) goaclient.Signer {
return &goaclient.APIKeySigner{
SignQuery: false,
KeyName: "Authorization",
KeyValue: key,
Format: format,
}

}

0 comments on commit 01180b7

Please sign in to comment.