You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bin/structure.jl
+18-5Lines changed: 18 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -9,15 +9,15 @@ buffer = let buffer = IOBuffer(write=true)
9
9
write(buffer, """
10
10
# Internal implementation notes
11
11
12
-
The authentication control flow is implemented as the following state machine, starting from the `NeedAuthentication` state (or `NoAuthentication` if `force=true` is passed to `authenticate`), and finishing in either `Success` or `Failure`.
12
+
The authentication control flow is implemented as the following state machine, starting from the `NeedAuthentication`
13
+
state (or `NoAuthentication` if `force=true` is passed to `authenticate`), and finishing in either `Success` or `Failure`.
13
14
14
15
```mermaid
15
16
---
16
17
title: PkgAuthentication state machine diagram
17
18
---
18
19
19
20
stateDiagram-v2
20
-
direction LR
21
21
22
22
[*] --> NeedAuthentication
23
23
[*] --> NoAuthentication
@@ -33,6 +33,7 @@ buffer = let buffer = IOBuffer(write=true)
33
33
all_targets[m[1]] =strip.(split(m[2], ','))
34
34
end
35
35
end
36
+
choice_index =0
36
37
for state insort(InteractiveUtils.subtypes(PkgAuthentication.State), by=string)
37
38
println(buffer)
38
39
state_str =string(nameof(state))
@@ -41,15 +42,27 @@ buffer = let buffer = IOBuffer(write=true)
41
42
ifisempty(targets) && (state ∉ ignore_errors)
42
43
@warn"Empty targets list for $state"
43
44
elseif!isempty(targets)
44
-
for target in targets
45
-
println(buffer, "$(state_str) --> $(target)")
45
+
46
+
iflength(targets) >1
47
+
choice_index +=1
48
+
println(buffer, " state state$(choice_index) <<choice>>")
Copy file name to clipboardExpand all lines: docs/internals.md
+42-25Lines changed: 42 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,27 @@
1
1
# Internal implementation notes
2
2
3
-
The authentication control flow is implemented as the following state machine, starting from the `NeedAuthentication` state (or `NoAuthentication` if `force=true` is passed to `authenticate`), and finishing in either `Success` or `Failure`.
3
+
The authentication control flow is implemented as the following state machine, starting from the `NeedAuthentication`
4
+
state (or `NoAuthentication` if `force=true` is passed to `authenticate`), and finishing in either `Success` or `Failure`.
4
5
5
6
```mermaid
6
7
---
7
8
title: PkgAuthentication state machine diagram
9
+
theme: 'base'
10
+
themeVariables:
11
+
noteTextColor: '#222'
8
12
---
9
13
10
14
stateDiagram-v2
11
-
direction LR
12
15
13
16
[*] --> NeedAuthentication
14
17
[*] --> NoAuthentication
15
18
16
-
ClaimToken --> ClaimToken
17
-
ClaimToken --> HasNewToken
18
-
ClaimToken --> Failure
19
-
note right of ClaimToken
19
+
state state1 <<choice>>
20
+
ClaimToken --> state1
21
+
ClaimToken --> ClaimToken: retry
22
+
state1 --> HasNewToken
23
+
state1 --> Failure
24
+
note left of ClaimToken
20
25
Starts polling the Pkg server's OAuth token claiming
21
26
endpoint, returning to ClaimToken while the polling is
22
27
happening. Proceeds to HasNewToken if it successfully
@@ -25,10 +30,12 @@ stateDiagram-v2
25
30
end note
26
31
27
32
28
-
HasNewToken --> HasNewToken
29
-
HasNewToken --> Success
30
-
HasNewToken --> Failure
31
-
note right of HasNewToken
33
+
state state2 <<choice>>
34
+
HasNewToken --> state2
35
+
HasNewToken --> HasNewToken: retry
36
+
state2 --> Success
37
+
state2 --> Failure
38
+
note left of HasNewToken
32
39
Takes the token from the previous step and writes it to
33
40
the auth.toml file. In order to handle potential race
34
41
conditions with other writes, it will check that the
@@ -38,43 +45,53 @@ stateDiagram-v2
38
45
if there is an unexpected failure.
39
46
end note
40
47
41
-
HasToken --> NeedRefresh
42
-
HasToken --> Success
43
-
note right of HasToken
48
+
state state3 <<choice>>
49
+
HasToken --> state3
50
+
state3 --> NeedRefresh
51
+
state3 --> Success
52
+
note left of HasToken
44
53
If the token is valid (i.e. not expired, based on the
45
54
expiry times in the auth.toml file), proceeds to Success.
46
55
Otherwise, proceeds to NeedRefresh.
47
56
end note
48
57
49
-
NeedAuthentication --> HasToken
50
-
NeedAuthentication --> NoAuthentication
51
-
note right of NeedAuthentication
58
+
state state4 <<choice>>
59
+
NeedAuthentication --> state4
60
+
state4 --> HasToken
61
+
state4 --> NoAuthentication
62
+
note left of NeedAuthentication
52
63
Checks if a syntactically valid auth.toml token file
53
64
exists for the requested server (but does not check
54
65
whether it has expired or not). Proceeds to HasToken if
55
66
it exists, or NoAuthentication if not.
56
67
end note
57
68
58
-
NeedRefresh --> HasNewToken
59
-
NeedRefresh --> NoAuthentication
60
-
note right of NeedRefresh
69
+
state state5 <<choice>>
70
+
NeedRefresh --> state5
71
+
state5 --> HasNewToken
72
+
state5 --> NoAuthentication
73
+
note left of NeedRefresh
61
74
Attempts to acquire a new access token by using the
62
75
refresh token in the auth.toml. If the refresh succeeds,
63
76
it will proceed to HasNewToken, or to NoAuthentication if
64
77
it fails.
65
78
end note
66
79
67
-
NoAuthentication --> RequestLogin
68
-
NoAuthentication --> Failure
69
-
note right of NoAuthentication
80
+
state state6 <<choice>>
81
+
NoAuthentication --> state6
82
+
state6 --> RequestLogin
83
+
state6 --> Failure
84
+
note left of NoAuthentication
70
85
Attempts to acquire an OAuth challenge from the Pkg
71
86
server. If successful, proceeds to RequestLogin, or to
72
87
Failure otherwise.
73
88
end note
74
89
75
-
RequestLogin --> ClaimToken
76
-
RequestLogin --> Failure
77
-
note right of RequestLogin
90
+
state state7 <<choice>>
91
+
RequestLogin --> state7
92
+
state7 --> ClaimToken
93
+
state7 --> Failure
94
+
note left of RequestLogin
78
95
Presents the in-browser step of the OAuth authentication
79
96
process to the user (e.g. by opening the Pkg server's
80
97
login page in the user's browser). Proceeds to ClaimToken
0 commit comments