Skip to content

Commit 7f5d345

Browse files
Merge pull request #26 from andyquinterom/rust_backend
WIP: Rust backend
2 parents b7d171f + f58b406 commit 7f5d345

51 files changed

Lines changed: 3281 additions & 1150 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.Rbuildignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@
1111
^README\.Rmd$
1212
^codecov\.yml$
1313
^Makefile$
14+
^src/\.cargo$
15+
^src/rust/vendor$
16+
^src/Makevars$
17+
^src/Makevars\.win$
18+
^Taskfile.yml$
19+
^src/rust/target$

.github/workflows/R-CMD-check.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pull_request:
77
branches: [main, master]
88

9-
name: R-CMD-check.yaml
9+
name: R CMD Check
1010

1111
permissions: read-all
1212

@@ -50,3 +50,5 @@ jobs:
5050
with:
5151
upload-snapshots: true
5252
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
53+
env:
54+
NOT_CRAN: false

.github/workflows/tests.yaml

Lines changed: 0 additions & 56 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ example/.Renviron
5252
docs
5353
inst/doc
5454
.Rproj.user
55+
src/rust/vendor
56+
src/Makevars
57+
src/Makevars.win

DESCRIPTION

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@ Description: Swift and seamless Single Sign-On (SSO) integration. Designed
1313
License: MIT + file LICENSE
1414
URL: https://github.com/ixpantia/tapLock
1515
BugReports: https://github.com/ixpantia/tapLock/issues
16+
Depends: R (>= 4.2.0)
1617
Imports:
17-
curl,
1818
glue,
19-
httr2,
20-
jose,
21-
lubridate,
2219
promises,
23-
purrr,
24-
stats,
2520
stringr,
2621
shiny,
27-
tower (>= 0.2.0)
22+
later,
23+
methods,
24+
tower (>= 0.2.0),
25+
rlang
2826
Suggests:
2927
knitr,
3028
rmarkdown,
@@ -35,3 +33,5 @@ Config/testthat/edition: 3
3533
Encoding: UTF-8
3634
Roxygen: list(markdown = TRUE)
3735
RoxygenNote: 7.3.2
36+
Config/rextendr/version: 0.3.1.9001
37+
SystemRequirements: Cargo (Rust's package manager), rustc, OpenSSL >= 1.0.2

Makefile

Lines changed: 0 additions & 13 deletions
This file was deleted.

NAMESPACE

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
# Generated by roxygen2: do not edit by hand
22

3-
S3method(internal_add_auth_layers,entra_id_config)
4-
S3method(internal_add_auth_layers,google_config)
3+
S3method("$",AsyncFuture)
4+
S3method("$",FutureResult)
5+
S3method("$",OAuth2Runtime)
6+
S3method("[[",AsyncFuture)
7+
S3method("[[",FutureResult)
8+
S3method("[[",OAuth2Runtime)
59
S3method(print,access_token)
610
export(add_auth_layers)
711
export(expires_at)
812
export(expires_in)
9-
export(get_token_field)
13+
export(hello_world)
1014
export(is_expired)
1115
export(is_valid)
12-
export(new_auth0_config)
1316
export(new_entra_id_config)
1417
export(new_google_config)
1518
export(new_openid_config)
1619
export(token)
20+
useDynLib(tapLock, .registration = TRUE)

R/auth.R

Lines changed: 6 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,10 @@
88
#' @keywords internal
99
#' @noRd
1010
access_token <- function(config, token_str) {
11-
UseMethod("access_token")
12-
}
13-
14-
#' @keywords internal
15-
#' @noRd
16-
access_token.google_config <- function(config, token_str) {
17-
token_data <- decode_token(config, token_str)
18-
structure(
19-
list(
20-
access_token = token_str,
21-
exp = lubridate::as_datetime(token_data$exp),
22-
iat = lubridate::as_datetime(token_data$iat),
23-
token_data = token_data
24-
),
25-
class = c("google_token", "access_token")
26-
)
27-
}
28-
29-
#' @keywords internal
30-
#' @noRd
31-
access_token.entra_id_config <- function(config, token_str) {
32-
token_data <- decode_token(config, token_str)
33-
structure(
34-
list(
35-
access_token = token_str,
36-
exp = lubridate::as_datetime(token_data$exp),
37-
iat = lubridate::as_datetime(token_data$iat),
38-
token_data = token_data
39-
),
40-
class = c("entra_id_token", "access_token")
41-
)
42-
}
43-
44-
#' @keywords internal
45-
#' @noRd
46-
access_token.auth0_config <- function(config, token_str) {
47-
token_data <- decode_token(config, token_str)
48-
structure(
49-
list(
50-
access_token = token_str,
51-
exp = lubridate::as_datetime(token_data$exp),
52-
iat = lubridate::as_datetime(token_data$iat),
53-
token_data = token_data
54-
),
55-
class = c("auth0_token", "access_token")
56-
)
11+
if (length(token_str) == 0) {
12+
return(error("No access_token provided"))
13+
}
14+
config$decode_token(token_str)
5715
}
5816

5917
#' @title Print an access token
@@ -112,8 +70,8 @@ is_expired <- function(token) {
11270
#' @return A string containing the Authorization header
11371
#' @keywords internal
11472
#' @noRd
115-
get_bearer <- function(token) {
116-
paste0("Bearer ", token$access_token)
73+
add_bearer <- function(token) {
74+
paste0("Bearer ", token)
11775
}
11876

11977
#' @title Get the access token string
@@ -149,15 +107,3 @@ expires_in <- function(token) {
149107
expires_at <- function(token) {
150108
token$exp
151109
}
152-
153-
#' @title Get the issued at time of an access token
154-
#' @description Gets the issued at time of an access token
155-
#'
156-
#' @param token An access_token object
157-
#' @param field The field to get from the token
158-
#'
159-
#' @return A POSIXct object containing the date and time the token was issued
160-
#' @export
161-
get_token_field <- function(token, field) {
162-
token$token_data[[field]]
163-
}

0 commit comments

Comments
 (0)