Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-NRF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-NRF
Commits
729bc313
Commit
729bc313
authored
Dec 24, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cpp-jwt lib for OAuth2 authorization
parent
463ea1a6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
163 additions
and
25 deletions
+163
-25
build/scripts/build_helper.nrf
build/scripts/build_helper.nrf
+54
-1
src/nrf_app/CMakeLists.txt
src/nrf_app/CMakeLists.txt
+2
-0
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+4
-0
src/nrf_app/nrf_jwt.cpp
src/nrf_app/nrf_jwt.cpp
+53
-0
src/nrf_app/nrf_jwt.hpp
src/nrf_app/nrf_jwt.hpp
+49
-0
src/oai-nrf/CMakeLists.txt
src/oai-nrf/CMakeLists.txt
+1
-24
No files found.
build/scripts/build_helper.nrf
View file @
729bc313
...
...
@@ -265,6 +265,56 @@ install_nghttp2_from_git() {
return 0
}
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_cpp_jwt_from_git() {
if [ $1 -eq 0 ]; then
read -p "Do you want to install Cpp-jwt ? <y/N> " prompt
OPTION=""
else
prompt='y'
OPTION="-y"
fi
if [ $2 -eq 0 ]; then
debug=0
else
debug=1
fi
if [[ $prompt =~ [yY](es)* ]]
then
$SUDO apt-get install $OPTION \
libgtest-dev \
libssl-dev
ret=$?;[[ $ret -ne 0 ]] && return $ret
GIT_URL=https://github.com/arun11299/cpp-jwt.git
echo "Install Cpp-jwt from $GIT_URL"
pushd $OPENAIRCN_DIR/build/ext
echo "Downloading Cpp-jwt"
if [[ $OPTION =~ [yY](es)* ]]
then
$SUDO rm -rf cpp-jwt
fi
git clone $GIT_URL
cd cpp-jwt && git checkout master
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
mkdir _build && cd _build
cmake ..
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
make
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd
fi
return 0
}
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
...
...
@@ -402,7 +452,10 @@ check_install_nrf_deps() {
install_nghttp2_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
install_cpp_jwt_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
return 0
}
#-------------------------------------------------------------------------------
...
...
src/nrf_app/CMakeLists.txt
View file @
729bc313
...
...
@@ -20,6 +20,7 @@
################################################################################
include_directories
(
${
SRC_TOP_DIR
}
/../build/ext/spdlog/include
)
include_directories
(
${
SRC_TOP_DIR
}
/../build/ext/cpp-jwt
)
include_directories
(
${
SRC_TOP_DIR
}
/api-server/api
)
include_directories
(
${
SRC_TOP_DIR
}
/api-server/impl
)
include_directories
(
${
SRC_TOP_DIR
}
/api-server/model
)
...
...
@@ -33,6 +34,7 @@ add_library (NRF STATIC
nrf_subscription.cpp
nrf_client.cpp
nrf_search_result.cpp
nrf_jwt.cpp
task_manager.cpp
nrf_event.cpp
)
...
...
src/nrf_app/nrf_app.cpp
View file @
729bc313
...
...
@@ -41,6 +41,7 @@
#include "nrf_client.hpp"
#include "nrf_config.hpp"
#include "nrf_search_result.hpp"
#include "nrf_jwt.hpp"
using
namespace
oai
::
nrf
::
app
;
using
namespace
oai
::
nrf
::
model
;
...
...
@@ -49,6 +50,7 @@ using namespace std::chrono;
extern
nrf_app
*
nrf_app_inst
;
extern
nrf_config
nrf_cfg
;
nrf_client
*
nrf_client_inst
=
nullptr
;
nrf_jwt
*
nrf_jwt_inst
=
nullptr
;
//------------------------------------------------------------------------------
nrf_app
::
nrf_app
(
const
std
::
string
&
config_file
,
nrf_event
&
ev
)
...
...
@@ -60,6 +62,7 @@ nrf_app::nrf_app(const std::string &config_file, nrf_event &ev)
try
{
nrf_client_inst
=
new
nrf_client
();
nrf_jwt_inst
=
new
nrf_jwt
();
}
catch
(
std
::
exception
&
e
)
{
Logger
::
nrf_app
().
error
(
"Cannot create NRF_APP: %s"
,
e
.
what
());
throw
;
...
...
@@ -1004,3 +1007,4 @@ bool nrf_app::find_search_result(const std::string &search_id,
return
false
;
}
}
src/nrf_app/nrf_jwt.cpp
0 → 100644
View file @
729bc313
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nrf_jwt.cpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2020
\email: tien-thinh.nguyen@eurecom.fr
*/
#include "nrf_jwt.hpp"
#include <iostream>
#include "jwt/jwt.hpp"
using
namespace
oai
::
nrf
::
app
;
void
nrf_jwt
::
test_jwt
(){
using
namespace
jwt
::
params
;
auto
key
=
"secret"
;
//Secret to use for the algorithm
//Create JWT object
jwt
::
jwt_object
obj
{
algorithm
(
"HS256"
),
payload
({{
"some"
,
"payload"
}}),
secret
(
key
)};
//Get the encoded string/assertion
auto
enc_str
=
obj
.
signature
();
std
::
cout
<<
enc_str
<<
std
::
endl
;
//Decode
auto
dec_obj
=
jwt
::
decode
(
enc_str
,
algorithms
({
"HS256"
}),
secret
(
key
));
std
::
cout
<<
dec_obj
.
header
()
<<
std
::
endl
;
std
::
cout
<<
dec_obj
.
payload
()
<<
std
::
endl
;
}
src/nrf_app/nrf_jwt.hpp
0 → 100644
View file @
729bc313
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nrf_jwt.hpp
* \brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2020
\email: tien-thinh.nguyen@eurecom.fr
*/
#ifndef FILE_NRF_JWT_HPP_SEEN
#define FILE_NRF_JWT_HPP_SEEN
namespace
oai
{
namespace
nrf
{
namespace
app
{
class
nrf_jwt
{
private:
public:
void
test_jwt
();
};
}
// namespace app
}
// namespace nrf
}
// namespace oai
#endif
/* FILE_NRF_JWT_HPP_SEEN */
src/oai-nrf/CMakeLists.txt
View file @
729bc313
...
...
@@ -209,7 +209,6 @@ if(GIT_FOUND)
)
endif
()
add_definitions
(
"-DPACKAGE_VERSION=
\"
Branch:
${
GIT_BRANCH
}
Abrev. Hash:
${
GIT_COMMIT_HASH
}
Date:
${
GIT_COMMIT_DATE
}
\"
"
)
add_definitions
(
"-DPACKAGE_BUGREPORT=
\"
openaircn-user@lists.eurecom.fr
\"
"
)
...
...
@@ -233,7 +232,6 @@ include(CheckLibraryExists)
include
(
CheckSymbolExists
)
include
(
CheckTypeSize
)
###############################################################################
# Debug and build related options
###############################################################################
...
...
@@ -241,7 +239,6 @@ include(CheckTypeSize)
add_boolean_option
(
DISPLAY_LICENCE_INFO False
"If a module has a licence banner to show"
)
add_boolean_option
(
LOG_OAI False
"Thread safe logging utility"
)
# System packages that are required
# We use either the cmake buildin, in ubuntu are in: /usr/share/cmake*/Modules/
# or cmake provide a generic interface to pkg-config that widely used
...
...
@@ -264,13 +261,7 @@ endif(STATIC_LINKING)
ADD_SUBDIRECTORY
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../src/common
${
CMAKE_CURRENT_BINARY_DIR
}
/common
)
ADD_SUBDIRECTORY
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../src/common/utils
${
CMAKE_CURRENT_BINARY_DIR
}
/utils
)
#ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/pfcp ${CMAKE_CURRENT_BINARY_DIR}/pfcp)
#ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/udp ${CMAKE_CURRENT_BINARY_DIR}/udp)
ADD_SUBDIRECTORY
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../src/api-server
${
CMAKE_CURRENT_BINARY_DIR
}
/api-server
)
#ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/nas ${CMAKE_CURRENT_BINARY_DIR}/nas)
#ENABLE_TESTING()
#ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/test ${CMAKE_CURRENT_BINARY_DIR}/test)
################################################################################
# Specific part for oai_nrf folder
...
...
@@ -280,30 +271,16 @@ include_directories(${SRC_TOP_DIR}/nrf_app)
include_directories
(
${
SRC_TOP_DIR
}
/oai_nrf
)
include_directories
(
${
SRC_TOP_DIR
}
/common
)
include_directories
(
${
SRC_TOP_DIR
}
/common/utils
)
#include_directories(${SRC_TOP_DIR}/common/utils/bstr)
#include_directories(${SRC_TOP_DIR}/pfcp)
#include_directories(${SRC_TOP_DIR}/udp)
include_directories
(
${
SRC_TOP_DIR
}
/../build/ext/spdlog/include
)
include_directories
(
${
SRC_TOP_DIR
}
/../build/ext/cpp-jwt
)
include_directories
(
${
SRC_TOP_DIR
}
/api-server
)
include_directories
(
${
SRC_TOP_DIR
}
/api-server/api
)
include_directories
(
${
SRC_TOP_DIR
}
/api-server/impl
)
include_directories
(
${
SRC_TOP_DIR
}
/api-server/model
)
#include_directories(${SRC_TOP_DIR}/nas)
#include_directories(${SRC_TOP_DIR}/nas/ies)
#include_directories(${SRC_TOP_DIR}/nas/mm)
#include_directories(${SRC_TOP_DIR}/nas/mm/msg)
#include_directories(${SRC_TOP_DIR}/nas/sm)
#include_directories(${SRC_TOP_DIR}/nas/sm/msg)
#include_directories(${SRC_TOP_DIR}/nas/security)
#include_directories(${SRC_TOP_DIR}/ngap)
#include_directories(${SRC_TOP_DIR}/ngap/asn1c)
#include_directories(${SRC_TOP_DIR}/ngap/ies)
add_executable
(
nrf
${
SRC_TOP_DIR
}
/oai-nrf/main.cpp
${
SRC_TOP_DIR
}
/oai-nrf/options.cpp
# ${SRC_TOP_DIR}/itti/itti.cpp
# ${SRC_TOP_DIR}/itti/itti_msg.cpp
)
IF
(
STATIC_LINKING
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment