This repository has been archived by the owner on Mar 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
843e4a4
commit 01180b7
Showing
9 changed files
with
93 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
|
||
} |