Skip to content

Commit a82dede

Browse files
authored
Merge pull request #15 from DilumAluthge/dpa/zero-arg-authenticate-method
Make some breaking changes to the existing one-arg `authenticate(::AbstractString)` method, and add a new zero-arg `authenticate()` method
2 parents 2e6f1f0 + c180c20 commit a82dede

File tree

12 files changed

+401
-123
lines changed

12 files changed

+401
-123
lines changed

.github/workflows/CI.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
name: CI
22
on:
3-
- push
4-
- pull_request
3+
pull_request:
4+
branches:
5+
- master
6+
push:
7+
branches:
8+
- master
9+
tags: '*'
10+
concurrency:
11+
# Skip intermediate builds: all builds except for builds on the `master` branch
12+
# Cancel intermediate builds: only pull request builds
13+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.ref != 'refs/heads/master' || github.run_number }}
14+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
515
jobs:
616
test:
7-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
817
runs-on: ${{ matrix.os }}
18+
timeout-minutes: 60
919
strategy:
1020
fail-fast: false
1121
matrix:
1222
version:
23+
# Parts of this package depend on Pkg internals.
24+
# Because Pkg internals are allowed to change between Julia minor versions,
25+
# we should run CI on each minor version of Julia that we want to support.
1326
- '1.3'
27+
- '1.4'
1428
- '1.5'
29+
- '1.6'
30+
# - '1.7' # TODO: uncomment this line once Julia 1.8 is released
31+
- '~1.8.0-rc1' # TODO: delete this line once Julia 1.8 is released
32+
- '1' # automatically expands to the latest stable 1.x release
1533
- 'nightly'
1634
os:
1735
- ubuntu-latest
@@ -36,4 +54,8 @@ jobs:
3654
${{ runner.os }}-test-
3755
${{ runner.os }}-
3856
- uses: julia-actions/julia-buildpkg@v1
39-
- uses: julia-actions/julia-runtest@v1
57+
- uses: julia-actions/julia-runtest@v1
58+
- uses: julia-actions/julia-processcoverage@v1
59+
- uses: codecov/codecov-action@v2
60+
with:
61+
files: lcov.info

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2020 Julia Computing Inc.
1+
Copyright (c) 2020 Julia Computing Inc. and contributors
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

Project.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "PkgAuthentication"
22
uuid = "4722fa14-9d28-45f9-a1e2-a38605bd88f0"
3-
authors = ["Sebastian Pfitzner"]
4-
version = "1.1.1"
3+
authors = ["Sebastian Pfitzner", "contributors"]
4+
version = "2.0.0-DEV"
55

66
[deps]
77
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
@@ -14,9 +14,3 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1414
Downloads = "1"
1515
JSON = "0.20, 0.21"
1616
julia = "1.3"
17-
18-
[extras]
19-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
20-
21-
[targets]
22-
test = ["Test"]

README.md

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,71 @@
11
# PkgAuthentication
22

3-
Authentication to private Julia package servers
3+
Interactive browser-based authentication to private Julia Pkg servers.
44

5+
## Setup
6+
7+
#### Step 1: Make sure that PkgAuthentication.jl is installed in the default global Julia package environment (`v1.x`)
8+
9+
```julia
10+
julia> delete!(ENV, "JULIA_PKG_SERVER")
11+
12+
julia> import Pkg
13+
14+
julia> Pkg.activate("v$(VERSION.major).$(VERSION.minor)"; shared = true)
15+
16+
julia> Pkg.add("PkgAuthentication")
517
```
6-
authenticate(pkgserver)
718

8-
Starts browser based pkg-server authentication (blocking).
19+
#### Step 2: Set the `JULIA_PKG_SERVER` environment variable
920

10-
`pkgserver` must be a URL pointing to a server that provides the `/pkgserver/challenge`,
11-
`/pkgserver/response`, and `/pkgserver/claimtoken` endpoints.
21+
One easy way to set the `JULIA_PKG_SERVER` environment variable is to add the following
22+
line to your [`startup.jl`](https://docs.julialang.org/en/v1/manual/getting-started/) file:
23+
24+
```julia
25+
ENV["JULIA_PKG_SERVER"] = "my-pkg-server.example.com"
1226
```
1327

14-
## Installation
15-
1. Make sure PkgAuthentication.jl is part of the default Julia environment.
16-
2. Put the following into your `startup.jl` to enable authentication for server as configured in JULIA_PKG_SERVER environment variable.
28+
#### Step 3: Put the following snippet into your [`startup.jl`](https://docs.julialang.org/en/v1/manual/getting-started/) file
29+
1730
```julia
1831
# create a new anonymous module for the init code to not pollute the global namespace
1932
Base.eval(Module(), quote
20-
using PkgAuthentication
21-
PkgAuthentication.install()
33+
import PkgAuthentication
34+
PkgAuthentication.install();
2235
end)
2336
```
2437

38+
With the above snippet, Pkg will automatically prompt you when you need to authenticate.
39+
40+
However, if you want to authenticate immediately (instead of waiting until the first
41+
Pkg operation that needs authentication), you can do so as follows. First, make
42+
sure that you have completed steps 1, 2, and 3 above. Then, open the Julia REPL
43+
and run the following:
44+
45+
```julia
46+
julia> import PkgAuthentication
47+
48+
julia> PkgAuthentication.authenticate();
49+
```
50+
51+
## Adding new registries
52+
53+
If you are using this private Pkg server for the first time, you probably want to
54+
make sure that you add any private registries that might be served by this Pkg server.
55+
56+
First, make sure that you have completed steps 1, 2, and 3 above. Then, open the
57+
Julia REPL and run the following:
58+
59+
```julia
60+
julia> import Pkg
61+
62+
julia> Pkg.Registry.add()
63+
64+
julia> Pkg.Registry.update()
65+
```
66+
2567
## Implementation
2668

2769
Authentication is implemented with the following state machine:
2870

29-
![structure](structure.png)
71+
![State machine](assets/structure.png)
File renamed without changes.

structure.jl renamed to bin/structure.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using LightGraphs, PkgAuthentication, GraphPlot, Cairo, Compose
22

3-
file = joinpath(@__DIR__, "src/PkgAuthentication.jl")
3+
file = joinpath(dirname(@__DIR__), "src", "PkgAuthentication.jl")
44

55
g = SimpleDiGraph()
66
lines = readlines(file)
@@ -19,4 +19,4 @@ for line in lines
1919
end
2020
end
2121
plot = gplot(g, nodelabel=vertices, linetype="curve")
22-
draw(PNG(joinpath(@__DIR__, "structure.png"), 16cm, 16cm), plot)
22+
draw(PNG(joinpath(@__DIR__, "structure.png"), 16cm, 16cm), plot)

0 commit comments

Comments
 (0)